Skip to content

test(wedge): plumb wedge budget as parameter to eliminate env-var race (#745) - #746

Merged
zackees merged 2 commits into
mainfrom
fix/wedge-test-env-race-745
Jun 14, 2026
Merged

zackees merged 2 commits into
mainfrom
fix/wedge-test-env-race-745

Conversation

@zackees

@zackees zackees commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Closes #745.

Root cause

The four wedge_detection_* unit tests in wrap::ipc::tests each mutated the process-global ZCCACHE_WEDGE_RECV_TIMEOUT_SECS env var to inject a 1 s or 0 s budget. cargo test runs them in parallel, so when one test called remove_var between another test's set_var and the recv, wedge_recv_timeout() fell through to its 180 s default. Under #[tokio::test(start_paused = true)] virtual time then advanced 180 s during the fake's sleep(budget) and the assertion's upper bound (elapsed < 1.1 s) tripped — exact symptom from PR #744's Windows runner ("wedge detection took 180s against a never-responding fake").

PR #730 made the elapsed measurement deterministic against the configured budget. But it did not address the env-var race that made the configured budget itself non-deterministic.

Fix

Refactor compile_recv_with_wedge_detection to take an explicit Option<Duration> budget parameter:

  • Production callers (cmd_compile, cmd_compile_ephemeral, cmd_link_ephemeral) pass wedge_recv_timeout() so the ZCCACHE_WEDGE_RECV_TIMEOUT_SECS knob still works for users and integration tests.
  • Unit tests pass a constant Some(Duration::from_secs(1)) (or None for the disabled path) directly — no env mutation, no race.

Renamed wedge_detection_disabled_when_env_is_zero → wedge_detection_disabled_when_budget_is_none since it no longer exercises the env var.

Drive-by

Second commit (style(cache_ops): inline format literal in cache list header) is a clippy print_literal fix in the new cache list header (PR #742) that was blocking CI on this branch — pure mechanical refactor, no behavior change.

Test plan

  • soldr cargo test -p zccache cli::commands::wrap::ipc::tests — 6/6 pass in 0.00s
  • soldr cargo fmt --all -- --check
  • soldr cargo clippy -p zccache --all-targets -- -D warnings
  • CI green across Linux / macOS / Windows

Refs

🤖 Generated with Claude Code

zackees and others added 2 commits June 14, 2026 13:27
#745)

The four `wedge_detection_*` unit tests in `wrap::ipc::tests` each
mutated the process-global `ZCCACHE_WEDGE_RECV_TIMEOUT_SECS` env var
to inject a 1 s or 0 s budget. `cargo test` runs them in parallel, so
when one test called `remove_var` between another test's `set_var`
and the recv, `wedge_recv_timeout()` fell through to its 180 s default.
Under `#[tokio::test(start_paused = true)]` virtual time then advanced
180 s during the fake's `sleep(budget)` and the assertion's upper bound
(`elapsed < 1.1 s`) tripped — symptom seen on PR #744's Windows runner.

PR #730 made the elapsed measurement deterministic against the configured
budget, but did not address the env-var race that made the configured
budget itself non-deterministic.

Fix: refactor `compile_recv_with_wedge_detection` to take an explicit
`Option<Duration>` budget parameter. Production callers (`cmd_compile`,
`cmd_compile_ephemeral`, `cmd_link_ephemeral`) pass `wedge_recv_timeout()`
so the `ZCCACHE_WEDGE_RECV_TIMEOUT_SECS` knob still works for users.
Tests pass a constant `Some(Duration::from_secs(1))` (or `None` for the
disabled path) directly — no env mutation, no race.

Renames `wedge_detection_disabled_when_env_is_zero` →
`wedge_detection_disabled_when_budget_is_none` since the test no longer
exercises the env var.

Closes #745
Refs #717, #730, #666

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Drive-by clippy fix to unblock CI on #745. The new `zccache cache list`
header (#742) had a trailing "path" literal as a format arg; clippy's
`print_literal` lint wants it inlined. Pure mechanical refactor.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees merged commit 547ed9f into main Jun 14, 2026
26 checks passed
@zackees
zackees deleted the fix/wedge-test-env-race-745 branch June 14, 2026 20:34
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.

test: wedge_detection_returns_wedged_on_recv_timeout still flakes on Windows after #730

1 participant