Skip to content

test(ci): retry transient wt-spawn ENOENT in the integration suite - #3119

Closed
worktrunk-bot wants to merge 1 commit into
mainfrom
fix/flaky-wt-spawn-enoent-27741371446
Closed

worktrunk-bot wants to merge 1 commit into
mainfrom
fix/flaky-wt-spawn-enoent-27741371446

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Problem

The macOS test job on #3097 failed once with a hard spawn error, then passed on re-run:

FAIL [ 0.272s] integration_tests::step_alias::test_config_alias_show_lists_all
thread '…' panicked at insta-cmd-0.7.0/src/spawn.rs:105:27:
called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }
…
Summary [297.211s] 3949 tests run: 3948 passed (1 leaky), 1 failed

The NotFound (ENOENT) comes from spawning the built wt binary. Integration tests spawn it by absolute path (target/debug/wt, via wt_bin()); if the file is momentarily absent at spawn time the test fails hard, and terminate-after = 1 then fails the whole run with no recourse.

Diagnosis

The known cause of a target/debug/wt non-existence window is real cargo rebuilding it — cargo unlinks and re-links the output file on every invocation (a ~4% non-existence window measured locally), which races a concurrent spawn(target/debug/wt). This mechanism is already documented in the repo, in the test_source_flag_forwards_errors comment in tests/integration_tests/shell_wrapper.rs.

I searched the suite exhaustively for any path that still runs real cargo against wt during a test run. Every one is already shielded:

  • the --source wrapper path (cargo run --bin wt) stubs cargo so it execs the existing binary instead of relinking (shell_wrapper.rs);
  • the hook/alias tests that configure cargo … commands (merge.rs, user_hooks.rs) mock cargo via create_mock_cargo;
  • the remaining cargo … strings are display/completion/approval tests that never execute the command.

So this is not a reproducible relink race in the suite. What remains is a rare, environment-level transient spawn failure (the run also reported 1 leaky), which I can't reproduce on demand.

Fix

A bounded nextest retry, scoped to binary(integration) — the only tests that spawn wt by path:

[[profile.default.overrides]]
filter = "binary(integration)"
retries = 2

This is proportionate to a transient and doesn't weaken coverage: a real assertion failure fails all attempts, while a spawn flake that passes on retry is reported as flaky (visible) rather than silently swallowed. Lib/bin/doctest tests call into the library in-process and can't hit this, so they're left untouched.

Testing

  • cargo nextest list/run parse the new override cleanly (nextest rejects unknown override keys, so a bad config would error) and test_config_alias_show_lists_all passes.

I couldn't reproduce the original flake locally (it's rare and macOS-specific), so this is a mitigation rather than a root-cause elimination — the deterministic relink sources were already eliminated in earlier work. Happy to take a different direction if you'd prefer to chase the residual transient further rather than retry it.

Integration tests spawn the built `wt` binary by absolute path
(`target/debug/wt`). If the file is momentarily absent at spawn time the
test fails hard with `Os { code: 2, kind: NotFound }` from insta-cmd's
spawn, and `terminate-after = 1` then fails the whole run.

The known cause of that window is real `cargo` rebuilding `wt` (unlink +
re-link on every invocation, a ~4% non-existence window measured locally;
see the test_source_flag_forwards_errors comment in shell_wrapper.rs).
Every in-suite path that could run real cargo against `wt` is already
shielded (stub cargo for the --source path; create_mock_cargo for the
hook/alias tests), so this is not a reproducible relink race in the suite.
What remains is a rare environment-level transient, observed once on macOS
CI (test_config_alias_show_lists_all, in a run that also reported 1 leaky).

A bounded retry scoped to binary(integration) is the proportionate fix: it
doesn't weaken coverage (a real assertion failure fails all attempts), and
a spawn flake that passes on retry is reported as flaky rather than
silently swallowed. Only integration tests spawn `wt` by path; lib/bin/
doctest tests call into the library in-process and cannot hit this.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.

2 participants