// autoRunner.test.ts's OWN settings.json, imported FIRST by it: a module of // its own because getPaths() memoizes on its first call, and some module the // test imports makes that call while it loads — an env var set in the test's // body would come too late. // // computeLeafPending reads getSettings(). With no SETTINGS_FILE that is the // checkout's own settings.json: the operator's in the primary checkout (a // transcription tree with leaves), none in a fresh worktree (the runner lanes' // built-in EMPTY tree) — so two tests passed in one checkout and failed in the // other. This is the minimal tree they need: one catch-all leaf on each runner // lane (the digest and backfill lanes default to one already). import { mkdtempSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import path from "node:path"; const dir = mkdtempSync(path.join(tmpdir(), "auto-runner-settings-")); process.env.SETTINGS_FILE = path.join(dir, "settings.json"); const CATCH_ALL_ROOT = { id: "root", mode: "strict", weight: 1, maxWorkers: null, children: [{ id: "all", match: { type: "all" }, weight: 1, maxWorkers: null }], }; writeFileSync( process.env.SETTINGS_FILE, JSON.stringify({ autoQueue: { transcription: { root: CATCH_ALL_ROOT }, download: { root: CATCH_ALL_ROOT } } }), ); process.on("exit", () => rmSync(dir, { recursive: true, force: true }));