From 7de2643243e5b7cdf49abb86d1a12368168df320 Mon Sep 17 00:00:00 2001 From: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> Date: Tue, 25 Aug 2026 08:05:31 +0000 Subject: [PATCH] test(router-eval): give spawned CLI children an explicit DATA_DIR The router-eval CLI test spawns the CLI with spawnSync and asserts stderr stays empty. NODE_TEST_CONTEXT is inherited by those children, so since #10432 (guard #10428) resolveWritableDataDir() detects a test context with no DATA_DIR and warns on stderr before falling back to a throwaway dir - 194 chars that broke three cases. Pass an isolated DATA_DIR in the child env (the resolution the guard message itself prescribes) instead of loosening the assertions. --- tests/unit/router-eval-cli.test.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 }, }); }