You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test: fix hostile-decoy env race flaking the setup-matrix and e2e suites (#135)
CI flake (seen twice: setup_matrix_pypi
host_guard::poetry_check_recognizes_structural_hook_host, exit 2 with a
clap --help hint): several test binaries set hostile ambient env decoys
PROCESS-WIDE (std::env::set_var) to prove the child-env scrub in their
run helpers works, while sibling tests run on parallel threads. The
scrub snapshots std::env::vars_os() and then spawns; a set_var landing
between a sibling's snapshot and its spawn reaches the child un-scrubbed
and (for SOCKET_STRICT=banana etc.) aborts its arg parse with exit 2.
Mechanism proven RED/GREEN by making the schedule deterministic: a 10ms
delay before the decoy set (simulating the late thread start CI hits)
plus a 25ms window between snapshot and spawn fails 2/3 host_guard
tests on EVERY run without the fix, and 0/5 runs with it (probes not
committed).
Fix, applied to every binary that mutates process env with >1 test
(setup_matrix_{pypi,npm,deno,maven,nuget}, e2e_safety_cow,
e2e_vendor_pypi_build):
- #[serial_test::serial] on every test in the binary — serial only
excludes other #[serial] tests, so annotating just the mutator would
fix nothing
- smc::DecoyGuard, an RAII setter that removes the decoys on drop, so a
panicking assertion can't leave the process env poisoned for the tests
that run after it (npm and nuget previously never removed their decoys
at all)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
0 commit comments