diff --git a/tests/unit/check-docs-counts-err-seam.test.ts b/tests/unit/check-docs-counts-err-seam.test.ts index 39d7a1fc592..e56ce398d8e 100644 --- a/tests/unit/check-docs-counts-err-seam.test.ts +++ b/tests/unit/check-docs-counts-err-seam.test.ts @@ -1,5 +1,8 @@ -import { afterEach, describe, it } from "node:test"; +import { after, afterEach, describe, it } from "node:test"; import assert from "node:assert/strict"; +import fs from "node:fs"; +import os from "node:os"; +import path from "node:path"; import { buildChecks, runCountsGate, @@ -86,10 +89,18 @@ describe("readCodeFacts failure is reported as a strict failure", () => { // The gate itself no longer reports that failure as documentation drift: facts that cannot be // collected are an INFRASTRUCTURE failure (exit 2), so a host too loaded to run the tsx probe // can never be mistaken for docs that need editing. +// +// The gate runs against an empty root: a real STRICT drift still wins over the infrastructure +// verdict (exit 1), and a feature branch that adds a migration or a provider carries such a +// drift by design (derived values are refreshed at release). Against the working tree, these +// assertions would depend on the branch they run on. +const emptyRoot = fs.mkdtempSync(path.join(os.tmpdir(), "docs-counts-err-seam-")); +after(() => fs.rmSync(emptyRoot, { recursive: true, force: true })); + describe("the release gate classifies a facts failure as infrastructure", () => { it("exits 2 with an infrastructure verdict, not a STRICT drift", () => { __setSpawnSyncForTest(failingProbe); - const r = runCountsGate({ mode: "release" }) as GateResult; + const r = runCountsGate({ mode: "release", root: emptyRoot }) as GateResult; assert.equal(r.mode, "release"); assert.equal(r.exitCode, 2, `expected exit 2 (infrastructure), got ${r.exitCode}`); assert.ok(r.infra, "the result must carry the infrastructure failure"); @@ -111,7 +122,7 @@ describe("the release gate classifies a facts failure as infrastructure", () => signal: "SIGKILL", }) as never ); - const r = runCountsGate({ mode: "release" }) as GateResult; + const r = runCountsGate({ mode: "release", root: emptyRoot }) as GateResult; assert.equal(r.exitCode, 2); assert.match(JSON.stringify(r.infra), /timeout/i); });