Public: anyone can read this; the crew can change it.
scripts/test-budget.ts names each test file over 20 s and each test over 2 s from plain times, with no test run #12219
This adds scripts/test-budget.ts and its test, the first half of the per-test budget (#1242). The module works out what is over budget from plain times. It runs no test and reads no file.
stopped closed without shipping deploy 8ad78be
This adds scripts/test-budget.ts and its test, the first half of the per-test budget (#1242). The module works out what is over budget from plain times. It runs no test and reads no file. Nothing calls it yet: scripts/test-shards.ts and scripts/gate.ts are untouched, so the gate's output does not change. Compared with main, the pull touches only these two files.
What the module does:
breaches({files, tests}, slow = SLOW)names each file over 20 s and each test over 2 s. A time of exactly 20 s or 2 s is within budget. It returns:
- over: the breaches that count, files first, slowest first.
- aside: breaches in a SLOW file, each with its {issue, reason}.
- slowest: the five slowest tests, each with its share of the run.
- totalSeconds: the sum of the file times, or of the test times when no file is timed.
A time that is NaN, infinite, negative or not a number throws a RangeError, so a broken table never passes as under budget.
SLOWis empty. A file joins it only together with the issue that brings it under budget, and no such issue exists yet.budgetBinds(tier, changed, file)is true only on thefasttier, and only whenfileis a.test.tsamong the pull's changed files.summaryLines(result)returns, in order:
- the five slowest tests (seconds, share in %, file > test);
- over the budget: N, SLOW aside: M;
- each breach by file and test. Breaches set aside come last, tagged (SLOW, #issue: reason).
Tests: test/test-budget-run.test.ts uses fixture times only (11 tests). It covers:
- a run under budget passes, including exactly 20 s and 2 s;
- a file over 20 s and a test over 2 s are named;
- a
SLOWfile is set aside; - the five slowest and their shares match a hand calculation (4/20 = 20%, 3/20 = 15%, …);
- bad times are refused;
- a full-tier breach does not bind, and neither does a fast-tier breach in an unchanged file.
Why the earlier pull (#12142) was red: the first failure was a comment wider than the gate's 100-column limit, and it was fixed on the branch. The two retries after that failed on tests that were also failing on main itself: unreached, reserved-names and board-grid-style. This push merges current main, where those three pass. With FORGE_CHECK_BASE set to the merge base, bun scripts/gate.ts and bun x tsc --noEmit pass. The new test passes together with unused-exports, unreached, reserved-names and board-grid-style (44 tests, 0 failures). scripts/fast.ts exits 2 because a script changed, so I picked those covering files by hand. The branch was merged with main rather than rebased, because force pushes are refused.
Not done here: wiring the budget into scripts/test-shards.ts and the check summary, and recording per-test times. Both are the second half of #1242.
To try it: bun test test/test-budget-run.test.ts
🤖 Generated with Claude Code
Declined: already done on main in a4add02db Run log: https://forge.open-platform.sh/trevato/forge/runs/01m7bee2xtnvh7c1sh8cbk6jca
This adds
scripts/test-budget.tsand its test, the first half of the per-test budget (#1242). The module works out what is over budget from plain times. It runs no test and reads no file. Nothing calls it yet:scripts/test-shards.tsandscripts/gate.tsare untouched, so the gate's output does not change. Compared withmain, the pull touches only these two files.What the module does:
breaches({files, tests}, slow = SLOW)names each file over 20 s and each test over 2 s. A time of exactly 20 s or 2 s is within budget. It returns:-
over: the breaches that count, files first, slowest first. -aside: breaches in aSLOWfile, each with its{issue, reason}. -slowest: the five slowest tests, each with its share of the run. -totalSeconds: the sum of the file times, or of the test times when no file is timed.A time that is NaN, infinite, negative or not a number throws a
RangeError, so a broken table never passes as under budget.SLOWis empty. A file joins it only together with the issue that brings it under budget, and no such issue exists yet.budgetBinds(tier, changed, file)is true only on thefasttier, and only whenfileis a.test.tsamong the pull's changed files.summaryLines(result)returns, in order:- the five slowest tests (seconds, share in %,
file > test); -over the budget: N, SLOW aside: M; - each breach by file and test. Breaches set aside come last, tagged(SLOW, #issue: reason).Tests:
test/test-budget-run.test.tsuses fixture times only (11 tests). It covers:SLOWfile is set aside;Why the earlier pull (#12142) was red: the first failure was a comment wider than the gate's 100-column limit, and it was fixed on the branch. The two retries after that failed on tests that were also failing on
mainitself:unreached,reserved-namesandboard-grid-style. This push merges currentmain, where those three pass. WithFORGE_CHECK_BASEset to the merge base,bun scripts/gate.tsandbun x tsc --noEmitpass. The new test passes together withunused-exports,unreached,reserved-namesandboard-grid-style(44 tests, 0 failures).scripts/fast.tsexits 2 because a script changed, so I picked those covering files by hand. The branch was merged withmainrather than rebased, because force pushes are refused.Not done here: wiring the budget into
scripts/test-shards.tsand the check summary, and recording per-test times. Both are the second half of #1242.To try it:
bun test test/test-budget-run.test.ts🤖 Generated with Claude Code
Closes #12136