|
| 1 | +import { tmpdir } from "node:os"; |
1 | 2 | // ONE CASE, ITS OWN FILE — the same remedy proxy-holder-handover.test.mjs |
2 | 3 | // applies to itself, and for the same measured reason. |
3 | 4 | // |
|
10 | 11 | // mutation-checked; it needed isolating, not deleting. |
11 | 12 | // |
12 | 13 | // node gives each FILE its own process, which is the whole mechanism. |
13 | | -import { describe, it } from "node:test"; |
| 14 | +import { after, describe, it } from "node:test"; |
14 | 15 | import assert from "node:assert/strict"; |
15 | 16 | import http from "node:http"; |
16 | 17 | import net from "node:net"; |
17 | 18 | import { spawn } from "node:child_process"; |
18 | | -import { readFileSync } from "node:fs"; |
| 19 | +import { mkdtempSync, readFileSync, rmSync } from "node:fs"; |
19 | 20 | import { fileURLToPath } from "node:url"; |
20 | 21 | import { dirname, join } from "node:path"; |
21 | 22 | import { OURS, cmdOf, freePort, listeners } from "./proc-helpers.mjs"; |
22 | 23 |
|
| 24 | +// A PRIVATE TMPDIR FOR THE WHOLE FILE. Every launcher spawned here inherits |
| 25 | +// process.env, and the launcher writes cache-fix-proxy-<port>.sha256 under |
| 26 | +// os.tmpdir() on each spawn — so without this the run leaves those records in |
| 27 | +// the shared /tmp, one per spawn. Set once rather than at each spawn site: the |
| 28 | +// env is inherited, so this also covers sites added later. |
| 29 | +const FILE_TMP = mkdtempSync(join(tmpdir(), "ccf-so-")); |
| 30 | +process.env.TMPDIR = FILE_TMP; |
| 31 | +after(() => { try { rmSync(FILE_TMP, { recursive: true, force: true }); } catch { /* gone */ } }); |
| 32 | + |
23 | 33 | const here = dirname(fileURLToPath(import.meta.url)); |
24 | 34 | const launcherPath = join(here, "..", "bin", "claude-via-proxy.mjs"); |
25 | 35 | const serverPath = join(here, "..", "proxy", "server.mjs"); |
|
0 commit comments