Problem
test_run_with_telemetry_end_to_end in crates/chaffra-cli/src/main.rs intermittently fails in CI with:
called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }
Root cause
The test calls std::env::set_current_dir(dir.path()) to force the churn state file to be written in a temp directory. set_current_dir mutates process-global state. When cargo test runs tests in parallel (default), any other test that relies on the current working directory — or any test whose TempDir is being resolved relative to cwd — can race with this mutation.
The test passes reliably in isolation (cargo test -- test_run_with_telemetry_end_to_end) but fails non-deterministically under parallel execution.
Observed in
Preferred fix
Remove the set_current_dir call entirely. Instead, pass an explicit state file path to run_with_telemetry (or inject it via config/environment) so the test doesn't need to manipulate global process state. This eliminates the race without requiring --test-threads=1.
Alternatives
#[serial] attribute (from serial_test crate) on tests that mutate cwd
- Run this test with
--test-threads=1 in a separate CI step
#[ignore] with a link to this issue (least preferred)
Problem
test_run_with_telemetry_end_to_endincrates/chaffra-cli/src/main.rsintermittently fails in CI with:Root cause
The test calls
std::env::set_current_dir(dir.path())to force the churn state file to be written in a temp directory.set_current_dirmutates process-global state. Whencargo testruns tests in parallel (default), any other test that relies on the current working directory — or any test whose TempDir is being resolved relative to cwd — can race with this mutation.The test passes reliably in isolation (
cargo test -- test_run_with_telemetry_end_to_end) but fails non-deterministically under parallel execution.Observed in
27103847718,27105300165Preferred fix
Remove the
set_current_dircall entirely. Instead, pass an explicit state file path torun_with_telemetry(or inject it via config/environment) so the test doesn't need to manipulate global process state. This eliminates the race without requiring--test-threads=1.Alternatives
#[serial]attribute (fromserial_testcrate) on tests that mutate cwd--test-threads=1in a separate CI step#[ignore]with a link to this issue (least preferred)