Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

Commit 83d4fda

Browse files
baozhoutaoclaude
andauthored
test(scripts): hoist the whole-repository scan out of check-unused-dependencies' timed window (#8543)
The three tests in `check-unused-dependencies.test.ts`'s `this repository` block each called `analyze(repoRoot)` and then read one field of the result. That is the same whole-repository walk — 47 manifests, >1000 files — paid for three times, each pass inside a bounded assertion window. On the push lane the suite runs under v8 coverage instrumentation, and there a single pass crosses vitest's 15 s `testTimeout`. All three tests then fail with `Test timed out in 15000ms` while the gate they exercise is green. Because the coverage thresholds live only on the merged 4-shard report — the shard legs override them to zero — one red shard skips the merge and the thresholds are never evaluated on that commit at all. Hoist the scan to module scope as `REPOSITORY_SCAN`, where the cost lands in the import phase that no `testTimeout` governs. Not a `beforeAll`, which would trade the 15 s `testTimeout` for the narrower 10 s `hookTimeout` — the same reasoning that moved `check-doc-links.test.ts`'s corpus walk to `ANCHOR_CORPUS`. No timeout was raised and no assertion was weakened: the three tests read the same three fields of the same verdict they read before. Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr Co-authored-by: Claude <noreply@anthropic.com>
1 parent 389902e commit 83d4fda

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

‎scripts/__tests__/check-unused-dependencies.test.ts‎

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,30 @@ describe('scope', () => {
374374

375375
// ── 7. this repository ───────────────────────────────────────────────────────
376376

377+
/**
378+
* One whole-repository scan, shared by the three tests below.
379+
*
380+
* `analyze(repoRoot)` walks every package in the release group — 47 manifests
381+
* and >1000 files — and the three assertions read three different fields of the
382+
* SAME verdict, so a call per test paid for the identical walk three times, each
383+
* time inside a bounded assertion window. On the push lane, where the suite runs
384+
* under v8 coverage instrumentation, a single pass crosses vitest's 15 s
385+
* `testTimeout`: all three tests then fail with `Test timed out in 15000ms`
386+
* while the gate itself is green, and because the coverage thresholds live only
387+
* on the merged 4-shard report, one red shard means the coverage gate does not
388+
* run at all (objectui#8479).
389+
*
390+
* Module scope, not `beforeAll`: the import phase is governed by no timeout,
391+
* whereas a hook would trade the 15 s `testTimeout` for the narrower 10 s
392+
* `hookTimeout`. Same reasoning, same file family as `check-doc-links.test.ts`'s
393+
* `ANCHOR_CORPUS` (objectui#8419). No timeout is raised and no assertion is
394+
* weakened — each test asserts exactly what it asserted before.
395+
*/
396+
const REPOSITORY_SCAN = analyze(repoRoot);
397+
377398
describe('this repository', () => {
378399
it('is green: every gated declaration has a consumer', () => {
379-
const { findings } = analyze(repoRoot);
400+
const { findings } = REPOSITORY_SCAN;
380401
expect(findings).toEqual([]);
381402
});
382403

@@ -392,14 +413,14 @@ describe('this repository', () => {
392413
});
393414

394415
it('scans a population big enough for the verdict to mean something', () => {
395-
const { counters } = analyze(repoRoot);
416+
const { counters } = REPOSITORY_SCAN;
396417
expect(counters.packages).toBeGreaterThanOrEqual(30);
397418
expect(counters.gatedDeclared).toBeGreaterThanOrEqual(200);
398419
expect(counters.files).toBeGreaterThanOrEqual(1000);
399420
});
400421

401422
it('keeps the non-gated fields VISIBLE rather than absorbed', () => {
402-
const { measured } = analyze(repoRoot);
423+
const { measured } = REPOSITORY_SCAN;
403424
// Not an equality: these move with the tree. The pin is that the gate still
404425
// MEASURES them — a zero here would mean the reporting quietly stopped.
405426
expect(measured.peerDependencies).toBeGreaterThan(0);

0 commit comments

Comments
 (0)