Public: anyone can read this; the crew can change it.

Four test files are red only when the whole suite runs: one file lowers a global and the next inherits it #310

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Closes #302

shipped production is serving it deploy a5415ba

opened this

Closes #302

commented

Fixes tests that went red only when another file ran before them in the same run: files changed a process global and never put it back. Each leak below was reproduced as a pair in one process, before and after the fix, using the machine's own FORGE_URL.

Which file was leaking what

  • Log floor → test/web.test.ts: 25 files called setLogLevel("error") when loaded and never restored it. With git-ssh.test.ts before it, the test "a mismatched origin is refused and logged with both origins" found no warn line.
  • firstFetchRetry.ms = [50] → test/fork-flow.test.ts: view-source.test.ts and origins-security-auth.test.ts left it lowered. "a mirror whose git is not ready yet is fetched again" then retried before its seed arrived.
  • The machine's FORGE_URL → origins-security-auth and origins-oauth: on a crew machine every code exchange failed redirect_uri mismatch. origins-security-auth only cleared the variable in afterAll. origins-oauth only passed in the full run because web-origins.test.ts deleted FORGE_URL for every file after it. Both now clear it for their own run, and web-origins puts it back.
  • test/tui-workflows.test.ts: the lowered retry made the race more likely, but the file also flaked alone (2 of 8 runs). It waited for the "Mirroring" card, which is taken down as soon as the job finishes and can come and go between two looks. main has since switched to waiting for the outcome; the merge keeps that. On top of it, the harness records every screen pushed, so the test still asserts the card was shown without racing it.

What changed

  • Source (no behaviour change):

- logLevel() in src/kernel/log.ts reads the current floor. - FIRST_FETCH_RETRY_MS in src/origins/mirror.ts names the default waits.

  • New test/helpers/globals.ts: quietLogs(), fastFirstFetch() and withoutEnv(...). Each sets the global in beforeAll and puts back what it found in afterAll, for the scope it is called from. Every test that borrowed one now uses them.
  • Restore test: test/helpers.test.ts checks that after each helper's scope, the log floor, retry waits and environment read back what they were. It is in the gate, so the next file that forgets to restore is caught there.

Test changes The only assertions that changed are in tui-workflows, and that test was wrong: it sampled a card that disappears when its job finishes. No other assertion changed and nothing is skipped.

Still red in the full run Everything left red outside the gate belongs to #290–#294. The web-origins pin toggle and web-code failures are also red on their own, so they are not leaks either (they look like #291's dashboard assertions). bun run check passes: 445 tests across 23 files. On the first gate run after merging main, one test in studio.test.ts failed ("the studio home does not wait on the decider", a timing test). It passed 3 of 3 alone and on the gate re-run, and this branch doesn't touch that file.

Try it: bun test test/git-ssh.test.ts test/web.test.ts, bun test test/view-source.test.ts test/fork-flow.test.ts, and bun test test/origins-security-auth.test.ts with FORGE_URL set.

🤖 Generated with Claude Code

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs