Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

test(ci): make the #6634 selfref guard hermetic — main's copy hard-fails every PR (#7341)

Diego Rodrigues de Sa e Souza0065f1b7f03d
diff --git a/tests/unit/check-test-masking-selfref-6634.test.ts b/tests/unit/check-test-masking-selfref-6634.test.ts
index 6d91a2e7c2..b233a008f2 100644
--- a/tests/unit/check-test-masking-selfref-6634.test.ts
+++ b/tests/unit/check-test-masking-selfref-6634.test.ts
@@ -14,12 +14,14 @@
* (`if (file.endsWith("check-test-masking.test.ts")) continue;` in
* scripts/check/check-test-masking.mjs) for precisely this reason — this test
* asserts evaluateMasking() now applies the same exclusion for its diff-based
- * tautology counters, using the real base(origin/main)/head(HEAD) diff of
+ * tautology counters, against the REAL current source of
* tests/unit/check-test-masking.test.ts.
*/
import test from "node:test";
import assert from "node:assert/strict";
-import { execFileSync } from "node:child_process";
+import fs from "node:fs";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
import {
countTautologies,
@@ -28,16 +30,17 @@ import {
} from "../../scripts/check/check-test-masking.mjs";
const FILE = "tests/unit/check-test-masking.test.ts";
-
-function git(args: string[]): string {
- return execFileSync("git", args, { encoding: "utf8" });
-}
+const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
test("#6634: check-test-masking.test.ts's own tautology fixtures must not self-flag as weakening", () => {
- // origin/main predates the #6404 fixtures (countBareTautologies/scanBareTautologies
- // tests) that legitimately embed tautology-pattern literals as string fixtures.
- const baseSrc = git(["show", "origin/main:" + FILE]);
- const headSrc = git(["show", "HEAD:" + FILE]);
+ // Read the REAL current source from disk rather than a git ref: the Unit Tests
+ // job checks out a shallow/single-ref tree with no origin/main, so `git show
+ // origin/main:<file>` failed the shard before it ever exercised the masking
+ // behavior under test. An empty base models the file's pre-#6404 state (no
+ // fixtures), which maximizes headTaut - baseTaut — the strictest input for the
+ // exclusion this test asserts.
+ const baseSrc = "";
+ const headSrc = fs.readFileSync(path.join(REPO_ROOT, FILE), "utf8");
const perFile = [
{