Repository navigation
test(worktree): check concurrent create names, not which create reached Git first - #35457
Conversation
|
STATUS: ready. Head 247ae36. Reproduced deterministically (a delayed base-name realpath gives the exact CI assertion); fixed by asserting names rather than add-call order. Checks: tc, typecheck:ci, code-quality, anti-slop, oxlint, ast-grep scan and gates; 41/41 passing x3. Review: e9-reviewer. |
|
No actionable comments were generated in the recent review.
|
[Low impact] This test-only change appears safe to merge. SummaryRemoves a timing-dependent assertion from the concurrent worktree creation test.
Reviews (1) · Last reviewed commit: "Merge branch 'main' into nwparker/worktr..." · Reviewed by Greptile |
ELI5
A test starts two worktree creates with the same name at once. It checks that one gets the name and the other gets the next free one ("app" and "app-2"). It assumed the create that won the name would also be the first to reach Git. Each create first resolves its folder path on disk, and on a busy CI runner the other one can finish that first. The test then read the names in the wrong order and failed. It now checks which names were given out, not who got to Git first.
What Changed
Before:
runtime-local-worktree-create.test.ts› "runtime concurrent creates on one name › gives the second create of app / nautilus its next candidate" failed at random withexpected 'app-2' to be 'app'(ornautilus-2/nautilus). Seen on #35414 (job 123139684188, shard 4/5) and #35385 (job 123152224174, shard 5/5).After: the test asserts that exactly one of the two Git adds used the requested name, and that the other used the next candidate (
app-2, or a tier-2 creature name for generated names). The rest is unchanged, including the check that the name is free again afterwards.Mechanism:
holdInFlightWorktreeCreate. That awaits a realfs.promises.realpathwalk over the candidate path's ancestors (resolveCreatePathAlias) before it reaches the mockedaddWorktree.app-2create can calladdWorktreefirst, which flipsmock.calls[0].Why
The product guarantees distinct names and that the base name goes to one create. It does not promise which create reaches Git first, so the test now asserts what is promised.
Reproduced deterministically: with a 50 ms delay injected before the base-name create's
realpath, both cases fail with the exact CI assertion. With this change both pass under that delay. The delay was local only and is not committed.Alternatives considered: mocking
realpathwould hide a real ordering, and tests should not depend on thread-pool timing.Flag-off: test-only.
User-risk: none.
Linked Issue
CI flake triage (unit shards blocking merges).
Visual Proof
N/A. Test-only.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
The file passes 41/41 three runs in a row.
With the injected delay: 2 failed before the change, 41/41 after.
Checks run:
pnpm tc,pnpm run typecheck:ci,pnpm run check:code-quality:changed, anti-slop oxlint, oxlint, ast-grep scan and gates.Review
Agent skill upstream boundary
Notes
None.
Status
Ready for review.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)