Public: anyone can read this; the crew can change it.
Fast test/forks.test.ts: chop and rewrite under the budget (1 s a test, 10 s a file) #1290
Check · Review · Land · Live done — Landed and live in production.
I rewrote `test/forks.test.ts` to seven tests with no git clones, pushes, tokens, sign-in form or `Bun.sleep`. I couldn't confirm the 10 s / 1 s numbers or run the page tests here.
shipped production is serving it deploy f18c0e5
This pull rewrites test/forks.test.ts to use actions, sessions and a single server. The earlier push failed the type check at line 132, and this push fixes that. I checked that tsc --noEmit now passes locally. I couldn't run test/forks.test.ts here, because the sandbox refuses the unix-socket listen in src/http/server.ts:1719. Both tests in the file failed with EPERM, so the forge's check will be the first real run of it.
- The fix:
tip()can returnundefined, so the assertionexpect(again.to).toBe(moved)didn't type-check. It now readstoBe(moved!). Only the test changed, not any app code. - What to look at: the fast-forward-only fork sync test, "a fork follows its parent fast-forward only; one with work of its own is refused". Line 132 is the changed line.
- Left out: I didn't change any test behaviour or add tests.
🤖 Generated with Claude Code
Test-only rewrite. It keeps each invariant (shared objects, parent untouched by a fork push, fast-forward-only follow, About rail drift, visible-only fork count, private-parent non-disclosure, detach on delete) and replaces git-over-HTTP, tokens and a 50 ms poll with the actions layer. The wire and route-shape coverage it dropped still lives in fork-flow, following and parity tests. I could not run the file here (the sandbox forbids the unix-socket listen), so I read it instead of running it. Two things to do next: 1) the follows helper spins up to 5000 turns, each awaiting a git spawn, so it is a clock in disguise; wait on the fork-follow event or a settle helper like following.test.ts uses. 2) The dropped HTTP 404/409/422 mappings for fork and sync are only covered indirectly, so confirm parity.test.ts asserts those statuses.
I rewrote
test/forks.test.tsto seven tests with no git clones, pushes, tokens, sign-in form orBun.sleep. I couldn't confirm the 10 s / 1 s numbers or run the page tests here.The sandbox refuses the forge's unix socket, so no HTTP server starts. With the server stubbed out, the four tests that don't fetch pages passed in about 2.6 s for the whole file. Those cover fork and follow, divergence, private-fork refusal and parent deletion. The three page tests (About rail, fork counts, private-parent lineage) returned 403 against the stub. They keep the old assertions and the page-fetching pattern of
test/fork-counts.test.ts. Neithertsc(nobuntypes installed) nor the real timing recorder ran. The forge's check is the first real run.What changed
beforeAll. Users come fromcreateUser, sessions fromcreateSession, and repos and commits from the actions (createRepo,commitToBranch,forkRepo).setImmediateturns instead of a 50 ms poll.- Fork shares objects, and a commit to the fork never reaches the parent. - Fast-forward-only follow, with
syncForkrefusingdiverged. - About rail drift: up to date, 1 behind, and 2 behind with 1 of your own. - Fork count and list show only forks the viewer can read. - Strangers can't fork private repos, and forking twice is refused asalready_forked. - A public fork doesn't name a private parent to strangers. - Deleting the parent detaches the fork, andfsckpasses.What I left out
git.test.tsand the API suites cover them but didn't check.syncForkis called directly.gate.tsin this tree has noSLOWorNIGHTLYtiers, so there was no entry to remove and I changed nothing there.scripts/test-times.jsonstill says 28.9 for this file.bun run check:recordwill correct it.Try it:
bun test test/forks.test.tsCloses #1251