diff --git a/packages/testkit/test/helpers.ts b/packages/testkit/test/helpers.ts index f61e4ad4..547ae835 100644 --- a/packages/testkit/test/helpers.ts +++ b/packages/testkit/test/helpers.ts @@ -3,7 +3,7 @@ // Import this before anything that pulls in @peppa/runner (statically or via @peppa/bot): // runner modules read PEPPA_TMUX_SOCKET / PEPPA_HOME when they load. import { execFileSync } from "node:child_process"; -import { mkdirSync, mkdtempSync, readFileSync, existsSync, writeFileSync } from "node:fs"; +import { mkdirSync, mkdtempSync, readFileSync, existsSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join, resolve } from "node:path"; import { fileURLToPath } from "node:url"; @@ -43,6 +43,9 @@ export async function teardown() { try { execFileSync("tmux", ["-L", process.env.PEPPA_TMUX_SOCKET!, "kill-server"], { stdio: "ignore" }); } catch {} + // Every run left its temp dir behind (~1 GB after a few hundred runs filled the disk); + // PEPPA_KEEP_TEST_TMP=1 keeps it for debugging. + if (!process.env.PEPPA_KEEP_TEST_TMP) rmSync(TMP, { recursive: true, force: true }); } export async function waitFor(label: string, fn: () => Promise, timeoutMs = 25000): Promise {