Skip to content

fix(luggage): serialize shim-writing idempotency tests to close fork/exec race - #459

Merged
joshjhall merged 1 commit into
mainfrom
fix/456-flaky-idempotency-tests
May 11, 2026
Merged

fix(luggage): serialize shim-writing idempotency tests to close fork/exec race#459
joshjhall merged 1 commit into
mainfrom
fix/456-flaky-idempotency-tests

Conversation

@joshjhall

Copy link
Copy Markdown
Owner

Summary

  • Adds serial_test = \"3\" to crates/luggage [dev-dependencies].
  • Marks the three shim-writing tests in crates/luggage/src/installer/idempotency.rs (matching_version_returns_true, nonmatching_version_returns_false, rust_tool_id_resolves_to_rustc_binary) with #[serial_test::serial].
  • Closes the parallel-cargo test fork/exec race (rust-lang/rust#100904) where an in-flight fs::write FD raised the inode's i_writecount while another thread fork()+execve()'d a shim — child got ETXTBSY. CI run 25649484773 caught one variant on main post-feat(containers-common): broaden Zed extensions on dev_tools and docker #453.

The two tests that don't write a shim (missing_binary_returns_false, primary_binary_defaults_to_tool_id) are left parallel — they don't participate in the race. Production code (already_installed, primary_binary) is unchanged.

Test plan

  • cargo test -p luggage --lib installer::idempotency — 25 consecutive iterations, all green
  • cargo test -p luggage — full crate suite green (lib + integration + doc)
  • cargo clippy -p luggage --tests -- -D warnings — clean
  • Pre-commit hooks (cargo-lint, cargo-deny, osv-scanner, cargo-test, taplo, gitleaks, conform) — all green
  • CI Rust Tests (stibbons) — ubuntu-latest green on this PR
  • (Post-merge AC) Three consecutive main runs green to confirm

Closes #456

🤖 Generated with Claude Code

…exec race

The four `installer::idempotency` tests that write a shell shim and then
`Command::output()` it intermittently failed under parallel `cargo test` due
to the well-known fork+ETXTBSY race (rust-lang/rust#100904): one thread's
in-flight write FD raises the inode's i_writecount while another thread
forks for execve, and the child gets ETXTBSY.

Add `serial_test` as a dev-dependency and mark the three shim-writing tests
(`matching_version_returns_true`, `nonmatching_version_returns_false`,
`rust_tool_id_resolves_to_rustc_binary`) with `#[serial_test::serial]` so
their write+exec windows cannot overlap. Verified by running
`cargo test -p luggage --lib installer::idempotency` 25x consecutively —
all green. Full `cargo test -p luggage` and `cargo clippy -p luggage --tests
-- -D warnings` also clean.

The two tests that don't write a shim (`missing_binary_returns_false`,
`primary_binary_defaults_to_tool_id`) are left parallel — they don't
participate in the race.

Closes #456

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@joshjhall
joshjhall merged commit 7b7c9b6 into main May 11, 2026
13 checks passed
@joshjhall
joshjhall deleted the fix/456-flaky-idempotency-tests branch May 11, 2026 18:36
joshjhall added a commit that referenced this pull request May 17, 2026
…c race (#481)

The three `installer::validate` tests that write a shell shim and then
`Command::output()` it intermittently fail under parallel `cargo test`
due to the same fork+ETXTBSY race (rust-lang/rust#100904) that #459
fixed for `installer::idempotency`: one thread's in-flight write FD
raises the inode's i_writecount while another thread forks for execve,
and the child gets ETXTBSY. Validate's tests use the identical
`write_shim` pattern but were never serialized.

Observed in CI run 25982111224 on the merge-to-main of #479, where
`mismatched_output_returns_validation_failed` failed with
`assertion failed: message.contains("1.95.0")` — the shim's exec
returned an ETXTBSY error message that, naturally, doesn't contain
the target version string. Ubuntu's faster fork/exec exposes the race
more reliably than macOS / Windows.

Mark all three shim-writing tests (`matching_output_passes`,
`mismatched_output_returns_validation_failed`,
`propagates_env_to_subprocess`) with `#[serial_test::serial]`. The
crate's `serial_test` dev-dependency was already added in #459.
Verified by running `cargo test -p luggage --lib installer::validate`
25x consecutively — all green.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky idempotency tests in luggage race under parallel cargo test

1 participant