fix(tests): give git-worktree fixtures unique sibling paths#357
Merged
Conversation
Four tests in integration_worktree.rs created their worktree at a fixed
`<system-temp>/worktree-feature` (and `worktree{1,2}`) sibling path. nextest
runs each test in its own process, so concurrent worktree tests collided on
that single shared path — one process's `git worktree add`/cleanup interfered
with another's, leaving the worktree's `.git` file missing during the walk-up.
`resolve_workspace_root` then found no git root and returned the subdirectory
unchanged. This surfaced as an intermittent Windows failure
(`test_resolve_workspace_root_detects_worktree`, from-subdir assertion), where
the slower/locking filesystem widens the race window.
Derive each worktree's sibling name from the main repo's unique TempDir
basename so parallel test processes never share a path. Behavior is otherwise
identical (still a sibling of the main repo, still canonicalized).
Verified: 5/5 pass locally and across repeated nextest runs.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019vhr7Tcf8ybvSZSE1owqBT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes an intermittent Windows CI failure in
test_resolve_workspace_root_detects_worktree(from-subdir assertion) — surfaced while validating #180's PR2 (unrelated code; the Windows re-run went green, confirming a flake).Root cause
Four tests in
crates/core/tests/integration_worktree.rscreated their worktree at a fixed shared path:main_path.join("../worktree-feature")resolves to<system-temp>/worktree-feature(and../worktree1/../worktree2) regardless of the unique per-test TempDir. nextest runs each test in its own process, so concurrent worktree tests collided on that one path — one process'sgit worktree add/cleanup clobbered another's worktree directory, so during the walk-up the worktree's.gitfile was missing.resolve_workspace_rootthen found no git root and returned the subdirectory unchanged:Windows' slower, file-locking filesystem widens the race window, which is why it flaked there and not on Linux/macOS.
Fix
Derive each worktree's sibling name from the main repo's unique TempDir basename (
main_path.file_name()), so parallel test processes never share a worktree path. Behavior is otherwise unchanged (still a sibling of the main repo, still canonicalized before use).Testing
cargo fmt --all -- --check✓cargo clippy --all-targets --all-features -- -D warnings✓cargo nextest run -E 'binary(=integration_worktree)'— 5/5 pass, repeated 3× with no flake ✓🤖 Generated with Claude Code