EB-1: fix flaky apply_env tests racing on shared EB_* env vars #35
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/apply-env-test-pollution-EB-1"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes the intermittent
check.ymlfailure (EB-1, run #87) wheretests::apply_env_prefix_updates_pattern_and_filenameassertedleft "My.Prefix+1" != right "MyPrefix"atsrc/main.rs:1431.Root cause
The four
apply_env_*unit tests mutate the process-globalEB_*environment variables viaenv::set_var. Rust runs unit tests in parallel by default, so whenapply_env_prefix_updates_pattern_and_filename(writesEB_SAVE_FILENAME_PREFIX=MyPrefix) andapply_env_prefix_with_special_chars_escapes_in_pattern(writesEB_SAVE_FILENAME_PREFIX=My.Prefix+1) run concurrently, they race on the same variable. The first test then reads the second test's value, producing the observed assertion failure. This is test pollution, not a defect in the prefix-sanitization logic itself.Fix
Guard the four
apply_envtests with a sharedENV_MUTEXso no two run concurrently. Mutex poisoning is ignored viainto_inner()so a genuine test panic surfaces as its own failure rather than cascading into the others. TheRangeConfig::set_from_envtests already use unique per-test variable names and do not touch shared state, so they need no lock.Note
The commit also syncs
Cargo.lock(explorer-bookmarks0.3.3 -> 0.4.0) to match the version already declared inCargo.toml;cargoregenerated it during the build. No dependency changes.Verification
cargo fmt --checkcleancargo clippy --all-targets -- -D warningsclean (matches CI)cargo testrun 10x consecutively: 36 passed, 0 failed each time#EB-1