mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
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:
@@ -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));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user