From a741dd407afeff42575a3b84ef43f28400bc504d Mon Sep 17 00:00:00 2001 From: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> Date: Sun, 15 Nov 2026 09:29:24 -0300 Subject: [PATCH] test(check): isolate the docs-counts infra verdict test from the tree The release-mode infra tests ran the counts gate against the working tree. A real STRICT drift wins over the infrastructure verdict (exit 1 before exit 2), and since derived values are refreshed only at release, any feature branch that adds a migration or a provider carries such a drift by design. On #20271 (two new migrations) both tests failed with "expected exit 2 (infrastructure), got 1". Run the gate against an empty temp root, so the only failure left is the stubbed facts probe. The assertions are unchanged. --- tests/unit/check-docs-counts-err-seam.test.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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); });