diff --git a/tests/unit/router-eval-cli.test.ts b/tests/unit/router-eval-cli.test.ts index a5c0332f7d..8e44a7fe59 100644 --- a/tests/unit/router-eval-cli.test.ts +++ b/tests/unit/router-eval-cli.test.ts @@ -8,7 +8,7 @@ // limitation, not a defect in the code under test: the OmniRoute runtime itself // cascades to node:sqlite/sql.js when better-sqlite3 is unavailable. See // tests/unit/_helpers/betterSqlite3Availability.ts for a guard helper. -import test from "node:test"; +import test, { after } from "node:test"; import assert from "node:assert/strict"; import { mkdtempSync, readFileSync, writeFileSync, rmSync } from "node:fs"; import { tmpdir } from "node:os"; @@ -18,9 +18,19 @@ import Database from "better-sqlite3"; const scriptPath = "scripts/router-eval/index.ts"; +// #10432 (guard #10428) made every process that detects a test context but has no +// explicit DATA_DIR warn on stderr before falling back to a throwaway dir. +// `NODE_TEST_CONTEXT` is inherited by the children spawned below, so the CLI printed +// that warning and broke the "stderr stays empty" assertions. Give every child its own +// DATA_DIR — the exact resolution the guard message prescribes — instead of loosening +// the assertions. +const cliDataDir = mkdtempSync(join(tmpdir(), "router-eval-cli-datadir-")); +after(() => rmSync(cliDataDir, { recursive: true, force: true })); + function runCli(args: string[]) { return spawnSync(process.execPath, ["--import", "tsx", scriptPath, ...args], { encoding: "utf8", + env: { ...process.env, DATA_DIR: cliDataDir }, }); }