No CI job ran any scale tier, and every tier past pr compares timings only on the baseline CPU. The pr tier checks counts, bounds and growth shape; it now includes S2 composition, since S0/S1 stay under the noise floor and let a quadratic accumulation through. The ungated-test check reads tier paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
100 lines
3.5 KiB
TypeScript
100 lines
3.5 KiB
TypeScript
import { readFileSync } from "node:fs";
|
|
import { readFile } from "node:fs/promises";
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import { loadCiGateContract } from "../../scripts/contracts/ci-gates.ts";
|
|
import {
|
|
gatedTestPaths,
|
|
listTestFiles,
|
|
parseUngatedTestExclusions,
|
|
ungatedTestFailures,
|
|
} from "../../scripts/lib/ungated-tests.ts";
|
|
|
|
/**
|
|
* 12-04 / 09-11. A test file only protects anything if a CI gate runs it.
|
|
* Several directories were reachable only from local scripts, and nothing
|
|
* noticed a new one.
|
|
*/
|
|
async function repositoryInputs() {
|
|
const contract = await loadCiGateContract(process.cwd());
|
|
const packageDocument = JSON.parse(await readFile("package.json", "utf8")) as {
|
|
scripts: Record<string, string>;
|
|
};
|
|
return {
|
|
testFiles: await listTestFiles(process.cwd()),
|
|
gatedPaths: gatedTestPaths(
|
|
packageDocument.scripts,
|
|
contract.commands.map(({ script }) => script),
|
|
(file) => readFileSync(file, "utf8"),
|
|
),
|
|
exclusions: parseUngatedTestExclusions(
|
|
JSON.parse(await readFile("config/ci/ungated-tests.json", "utf8")),
|
|
),
|
|
};
|
|
}
|
|
|
|
describe("ungated test files", () => {
|
|
it("runs every test file in a CI gate or names why it does not", async () => {
|
|
expect(ungatedTestFailures(await repositoryInputs())).toEqual([]);
|
|
});
|
|
|
|
it.each([
|
|
"tests/features/feature-module.test.ts",
|
|
"tests/architecture/observability-boundaries.test.ts",
|
|
"tests/release/old-asset-reachability.test.ts",
|
|
"tests/scripts/verify-extreme-scale.test.ts",
|
|
"tests/scale/browser-soak.contract.test.ts",
|
|
"tests/e2e/app-shell.spec.ts",
|
|
// 11-03: the CPU-independent scale PR tier runs in FE-GATE-005.
|
|
"tests/scale/growth-regression.test.ts",
|
|
"tests/scale/traffic/amplification-metrics.test.ts",
|
|
])("gates %s", async (file) => {
|
|
const inputs = await repositoryInputs();
|
|
expect(ungatedTestFailures({ ...inputs, testFiles: [file] })).toEqual([]);
|
|
expect(inputs.exclusions.some(({ path }) => path === file)).toBe(false);
|
|
});
|
|
|
|
it("reads the Vitest paths of a scale tier the gate command runs (11-03)", () => {
|
|
expect(
|
|
gatedTestPaths({ gate: "node scripts/scale/run-scale-profile.ts pr" }, ["gate"], () => ""),
|
|
).toEqual(expect.arrayContaining(["tests/scale/growth-regression.test.ts", "tests/scale/traffic"]));
|
|
expect(
|
|
gatedTestPaths({ gate: "node scripts/scale/run-scale-profile.ts pr" }, ["gate"], () => ""),
|
|
).not.toContain("tests/scale/session");
|
|
});
|
|
|
|
it("rejects a new test directory that no gate runs", async () => {
|
|
const inputs = await repositoryInputs();
|
|
expect(
|
|
ungatedTestFailures({
|
|
...inputs,
|
|
testFiles: [...inputs.testFiles, "tests/new-area/new-area.test.ts"],
|
|
}),
|
|
).toEqual([
|
|
"test file is not run by any CI gate command and is not in config/ci/ungated-tests.json: tests/new-area/new-area.test.ts",
|
|
]);
|
|
});
|
|
|
|
it("rejects an exclusion that a gate already runs", async () => {
|
|
const inputs = await repositoryInputs();
|
|
expect(
|
|
ungatedTestFailures({
|
|
...inputs,
|
|
exclusions: [...inputs.exclusions, { path: "tests/unit/ungated-tests.test.ts", reason: "stale" }],
|
|
}),
|
|
).toEqual([
|
|
"ungated test exclusion is stale; a CI gate runs it: tests/unit/ungated-tests.test.ts",
|
|
]);
|
|
});
|
|
|
|
it("requires a reason for every exclusion", () => {
|
|
expect(() =>
|
|
parseUngatedTestExclusions({
|
|
schemaVersion: 1,
|
|
entries: [{ path: "tests/scale/benchmark.test.ts", reason: " " }],
|
|
}),
|
|
).toThrow(/reason/u);
|
|
});
|
|
});
|