Hermes points TMPDIR at ~/.hermes/cache/scratch, so every Desktop test run's leftovers pile up there until the 24h idle pruner catches them: one day on a dev host left 688 playwright-tracing-*, 152 playwright-artifacts-*, 75 hermes-e2e-mock-* sandboxes and ~600 small vitest mkdtemp dirs. - Playwright (main + core configs): e2e/run-tmp.ts gives the run one temp root that workers, Electron and the backend inherit via TMPDIR, and removes it when the runner exits. Covers the stack-trace dirs the Electron tracing patch orphans (2 per launch, even on green runs), sandboxes a failed/timed-out setup never cleans, and Playwright's own artifact dirs. A SIGKILLed run now leaves one pw-* dir for the pruner. The update suite keeps os.tmpdir(): its seeded install is reused across runs and bakes its path into AF_UNIX sockets. - vitest (apps/desktop): globalSetup does the same for the run; one `--project electron` run left 54 dirs from tests that never remove what they mkdtemp.
25 lines
961 B
TypeScript
25 lines
961 B
TypeScript
/**
|
|
* One temp root per Playwright run, removed when the runner exits.
|
|
*
|
|
* Playwright (artifact and stack-trace dirs), the Electron app, its backend
|
|
* and every sandbox mkdtemp under os.tmpdir(), and a run that fails or times
|
|
* out in setup leaves all of it behind (a clean run of two specs left eight
|
|
* `playwright-tracing-*` dirs). Workers and the apps they launch inherit
|
|
* TMPDIR, so everything lands here; a SIGKILLed run leaves one dir, not dozens.
|
|
*
|
|
* Config modules load in the runner and again in each worker; only the first
|
|
* (runner) load creates the root.
|
|
*/
|
|
import fs from 'node:fs'
|
|
import os from 'node:os'
|
|
import path from 'node:path'
|
|
|
|
if (!process.env.HERMES_E2E_RUN_TMP) {
|
|
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'pw-'))
|
|
process.env.HERMES_E2E_RUN_TMP = root
|
|
process.env.TMPDIR = root
|
|
process.env.TEMP = root
|
|
process.env.TMP = root
|
|
process.on('exit', () => fs.rmSync(root, { recursive: true, force: true }))
|
|
}
|