mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
main's copy of this test still does git I/O inside a unit test:
const baseSrc = git(['show', 'origin/main:' + FILE]);
Runners check out a shallow single ref, so origin/main does not resolve and the
test dies with 'fatal: invalid object name origin/main'. Every PR into main
fails Unit Tests (7/8) on it — today that is #7313, #7315, #7316, #7334, #7336
and #7337, six PRs red on a defect none of them introduced. #7313 has no other
red at all.
release/v3.8.49 already carries a fix (2e42b8efc, #7174: try/catch, fetch
origin/main on demand, t.skip() when unreachable), but it only reaches main at
release time — so main stays broken for the whole cycle. Cherry-picking it would
also import a new problem: PR Test Policy classifies t.skip() as a silenced
assertion, which we watched it correctly catch on #7300 today.
This is the hermetic version instead (ported from #7327, which does the same for
the release branch): read the file straight off disk, compare against an empty
base so baseTaut/baseExtTaut are 0 — the strictest possible comparison point —
and call evaluateMasking() directly. No git ref, no fetch, no skip, nothing the
runner's checkout depth can break.
The #6634 regression stays covered: the guard's logic lives in
SELF_TEST_FIXTURE_RE (check-test-masking.mjs:337), not in the test. Proven both
ways on main before committing — neutralise SELF_TEST_FIXTURE_RE to /$^/ and
the test FAILS; restore it and it passes 2/2, with check-test-masking.mjs left
byte-identical.
Co-authored-by: growab <nekron@icloud.com>
88 lines
3.7 KiB
TypeScript
88 lines
3.7 KiB
TypeScript
/**
|
|
* Regression test for issue #6634 ("release/v3.8.47 branch not green — nightly
|
|
* release-green found HARD failures"). The nightly's "Test-masking
|
|
* (weakened-assert guard)" HARD failure was a SELF-REFERENTIAL false positive:
|
|
* tests/unit/check-test-masking.test.ts legitimately embeds tautology-pattern
|
|
* string literals (e.g. `expect(true).toBe(true);`, `assert.equal(1, 1);`) as
|
|
* FIXTURES to exercise countBareTautologies()/scanBareTautologies() — the same
|
|
* literal text that the diff-based subcheck (evaluateMasking(), fed by
|
|
* countTautologies()/countExtendedTautologies()) treated as "new tautologies in
|
|
* the file itself" because those counters are dumb regex scans of raw source
|
|
* text, blind to "this is inside a fixture string, not real assertion code".
|
|
*
|
|
* scanBareTautologies() already special-cases this exact file
|
|
* (`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, 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 fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
import {
|
|
countTautologies,
|
|
countExtendedTautologies,
|
|
evaluateMasking,
|
|
} from "../../scripts/check/check-test-masking.mjs";
|
|
|
|
const FILE = "tests/unit/check-test-masking.test.ts";
|
|
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", () => {
|
|
// 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 = [
|
|
{
|
|
file: FILE,
|
|
baseAsserts: 0, // irrelevant to this assertion — only tautology counters matter
|
|
headAsserts: 0,
|
|
baseTaut: countTautologies(baseSrc),
|
|
headTaut: countTautologies(headSrc),
|
|
baseExtTaut: countExtendedTautologies(baseSrc),
|
|
headExtTaut: countExtendedTautologies(headSrc),
|
|
},
|
|
];
|
|
|
|
const flags = evaluateMasking(perFile, new Set());
|
|
|
|
assert.deepEqual(
|
|
flags,
|
|
[],
|
|
"check-test-masking.test.ts's own literal tautology fixtures (added for #6404) must be " +
|
|
"excluded from the diff-based weakening check the same way scanBareTautologies() already " +
|
|
"excludes this file from the absolute-floor scan — otherwise the gate's own regression " +
|
|
"test permanently self-flags as a HARD release-green failure whenever new fixtures are added."
|
|
);
|
|
});
|
|
|
|
test("#6634: unrelated files still get flagged for genuinely new tautologies (guard is file-scoped, not global)", () => {
|
|
const perFile = [
|
|
{
|
|
file: "tests/unit/some-other-file.test.ts",
|
|
baseAsserts: 5,
|
|
headAsserts: 5,
|
|
baseTaut: 0,
|
|
headTaut: 1,
|
|
baseExtTaut: 0,
|
|
headExtTaut: 1,
|
|
},
|
|
];
|
|
|
|
const flags = evaluateMasking(perFile, new Set());
|
|
|
|
assert.equal(flags.length, 2, "a non-fixture file must still trip both tautology signals");
|
|
assert.match(flags[0], /nova\(s\) 1 tautologia\(s\) assert\.ok\(true\)/);
|
|
assert.match(flags[1], /nova\(s\) 1 tautologia\(s\) estendida/);
|
|
});
|