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 #12209

opened this

Closed 18d 22h ago

This adds scripts/test-budget.ts and its test, the first half of the per-test budget (#1242). The pull's diff is still only these two files; this push merges current main into the branch. Nothing calls the module yet.

Notes

opened this

This adds scripts/test-budget.ts and its test, the first half of the per-test budget (#1242). The pull's diff is still only these two files; this push merges current main into the branch. Nothing calls the module yet. scripts/test-shards.ts and scripts/gate.ts are unchanged, so the gate's output stays the same.

The module:

  • breaches({files, tests}, slow = SLOW): names each file over 20 s and each test over 2 s. A time exactly at a limit is within budget. Breaches in a SLOW file are set aside with their {issue, reason}. It also returns the five slowest tests with their share of the run.
  • Bad times are refused: a time that is NaN, infinite or negative throws a RangeError, so a broken table can't pass as under budget.
  • SLOW is empty: no issue exists yet to rewrite a slow file, so none is listed.
  • budgetBinds(tier, changed, file): true only on the fast tier, and only for a .test.ts among the pull's changed files.
  • summaryLines(result): writes the five slowest, then over the budget: N, SLOW aside: M, then each breach by file and test.

Tests: test/test-budget-run.test.ts uses fixture times only. It covers:

  • a run under budget, including the exact limits;
  • a file over 20 s and a test over 2 s being named;
  • a SLOW file being set aside;
  • the shares checked against a hand calculation;
  • bad times being refused;
  • a breach on the full tier, or in an unchanged file on the fast tier, not binding.

Why the earlier check was red, and why it may be red again: the 52 failures on pull #12142 came from main, not from this change. On origin/main at a20d391ac, with this change absent, four tests fail on their own:

  • test/unreached.test.ts: nothing imports src/crew/week_burn.ts.
  • test/now-fit.test.ts: the /now page still uses class="truncate".
  • test/design-audit.test.ts: the audit has 105 entries for 106 pages.
  • test/settings-routes.test.ts: a route outside settings is in the settings block.

Nothing in those tests reaches the two new files. Try 3 went beyond the issue's scope by editing docs to fix them; I left them alone, as the issue says to touch nothing else. They need their own fix on main, and until then this pull's check will fail on them too.

Checks run here: bun scripts/gate.ts and bun x tsc --noEmit pass. test/test-budget-run.test.ts and test/unused-exports.test.ts pass (14 tests).

🤖 Generated with Claude Code

Closes #12136

commented

This adds scripts/test-budget.ts and its test, the first half of the per-test budget (#1242). The pull's diff is still only these two files; this push merges current main into the branch. Nothing calls the module yet. scripts/test-shards.ts and scripts/gate.ts are unchanged, so the gate's output stays the same.

The module:

  • breaches({files, tests}, slow = SLOW): names each file over 20 s and each test over 2 s. A time exactly at a limit is within budget. Breaches in a SLOW file are set aside with their {issue, reason}. It also returns the five slowest tests with their share of the run.
  • Bad times are refused: a time that is NaN, infinite or negative throws a RangeError, so a broken table can't pass as under budget.
  • SLOW is empty: no issue exists yet to rewrite a slow file, so none is listed.
  • budgetBinds(tier, changed, file): true only on the fast tier, and only for a .test.ts among the pull's changed files.
  • summaryLines(result): writes the five slowest, then over the budget: N, SLOW aside: M, then each breach by file and test.

Tests: test/test-budget-run.test.ts uses fixture times only. It covers:

  • a run under budget, including the exact limits;
  • a file over 20 s and a test over 2 s being named;
  • a SLOW file being set aside;
  • the shares checked against a hand calculation;
  • bad times being refused;
  • a breach on the full tier, or in an unchanged file on the fast tier, not binding.

Why the earlier check was red, and why it may be red again: the 52 failures on pull #12142 came from main, not from this change. On origin/main at a20d391ac, with this change absent, four tests fail on their own:

  • test/unreached.test.ts: nothing imports src/crew/week_burn.ts.
  • test/now-fit.test.ts: the /now page still uses class="truncate".
  • test/design-audit.test.ts: the audit has 105 entries for 106 pages.
  • test/settings-routes.test.ts: a route outside settings is in the settings block.

Nothing in those tests reaches the two new files. Try 3 went beyond the issue's scope by editing docs to fix them; I left them alone, as the issue says to touch nothing else. They need their own fix on main, and until then this pull's check will fail on them too.

Checks run here: bun scripts/gate.ts and bun x tsc --noEmit pass. test/test-budget-run.test.ts and test/unused-exports.test.ts pass (14 tests).

🤖 Generated with Claude Code

commented

Declined: I can't make this pull's check green without leaving the issue's scope. The 55 failures come from main itself, not from this pull. Run log: https://forge.open-platform.sh/trevato/forge/runs/01m7bb5rxp2tmy4hfn7dethv1e

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs