test: split the three oversized format-matrix specs (#651)

Vitest shards by file and runs a file's tests serially in one fork, so a single spec set the floor for the whole Integration job no matter how many shards or forks it got. Cost-aware sharding (#650) balanced the shards but could not get under that floor.

Split the three specs that exceeded it: format-matrix-comprehensive (1365s) into 4 by describe, format-matrix (1130s) into 4 with Cross-format matrix striped over FORMAT_SAMPLES, and format-matrix-generated (779s) into 3 striped over TOOLS. Largest spec is now 370s. Each preamble moved verbatim into a sibling .shared.ts exposing setupMatrixApp().

Integration shards went from 20m59s/17m55s/16m33s/9m19s to 11m44s/12m31s/10m37s/11m1s.

Coverage checked, not assumed: the set of test names collected by vitest list is byte-identical across the split, 2151 before and 2151 after. Per-shard totals matched the baseline exactly at 9903 tests, 9435 passed, 468 skipped.
This commit is contained in:
SnapOtter
2026-07-27 00:36:51 +08:00
committed by GitHub
parent d91abc8a23
commit d9978525fe
19 changed files with 3365 additions and 2947 deletions
+13 -10
View File
@@ -19,12 +19,14 @@ function integrationSpecs(): string[] {
return out.sort();
}
const HEAVYWEIGHTS = [
"tests/integration/generated/format-matrix-comprehensive.test.ts",
"tests/integration/generated/format-matrix.test.ts",
"tests/integration/generated/format-matrix-generated.test.ts",
"tests/integration/generated/format-matrix-exotic.test.ts",
];
/**
* The four costliest specs, read from the table rather than hardcoded so this
* survives specs being split, renamed, or reweighted.
*/
const HEAVYWEIGHTS = Object.entries(FILE_COST_SECONDS)
.sort(([, a], [, b]) => b - a)
.slice(0, 4)
.map(([file]) => file);
describe("partitionByCost", () => {
// The whole point of the helper: a shard must never silently drop a spec.
@@ -95,9 +97,10 @@ describe("partitionByCost", () => {
});
describe("costOf", () => {
it("returns the measured cost for a known-heavy spec", () => {
const known = "tests/integration/generated/format-matrix-comprehensive.test.ts";
expect(costOf(known)).toBe(FILE_COST_SECONDS[known]);
it("returns the measured cost for every listed spec", () => {
for (const [file, seconds] of Object.entries(FILE_COST_SECONDS)) {
expect(costOf(file)).toBe(seconds);
}
});
it("falls back to a default for unmeasured specs", () => {
@@ -105,7 +108,7 @@ describe("partitionByCost", () => {
});
it("matches regardless of leading slash or absolute prefix", () => {
const known = "tests/integration/generated/format-matrix.test.ts";
const known = HEAVYWEIGHTS[0];
expect(costOf(`/${known}`)).toBe(costOf(known));
expect(costOf(path.join(repoRoot, known))).toBe(costOf(known));
});