From 6fae7b03b745db32cbcfaeba7d86ef165fdbcddc Mon Sep 17 00:00:00 2001 From: Toni Alatalo Date: Thu, 1 Oct 2026 17:28:06 +0930 Subject: [PATCH] test(ecc2): assert test config roots differ across threads Addresses review feedback on #3277 (CodeRabbit): the existing test only checked that Config::config_path() is stable within one thread. Nothing guarded the property that makes parallel tests safe, that each test thread gets its own root. If config_root() regressed to one shared directory, the existing tests would still pass while parallel tests that save a config raced on the same file. The code already behaves correctly, so the new test passes as written. To show it can fail, I temporarily made config_root() return one process-wide root (a OnceLock around the thread-local) and ran it: $ cargo test config_path_under_test_is_distinct # with that mutation running 1 test test config::tests::config_path_under_test_is_distinct_across_test_threads ... FAILED failures: ---- config::tests::config_path_under_test_is_distinct_across_test_threads stdout ---- thread 'config::tests::config_path_under_test_is_distinct_across_test_threads' panicked at src/config/mod.rs:1167:9: assertion `left != right` failed left: "/ecc2-test-config-958aace6-2774-481f-a50c-7684c5189e20/ecc2/config.toml" right: "/ecc2-test-config-958aace6-2774-481f-a50c-7684c5189e20/ecc2/config.toml" failures: config::tests::config_path_under_test_is_distinct_across_test_threads test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 492 filtered out; finished in 0.00s The mutation is reverted and is not part of this commit. With the real code: $ cargo test config_path_under_test_is_distinct test config::tests::config_path_under_test_is_distinct_across_test_threads ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 492 filtered out $ cargo test # full suite test result: ok. 492 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out Refs #3276 Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_011Y54kLgLGzLGqAxwLMFEc9 --- ecc2/src/config/mod.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ecc2/src/config/mod.rs b/ecc2/src/config/mod.rs index d8211b30a..160a5e26b 100644 --- a/ecc2/src/config/mod.rs +++ b/ecc2/src/config/mod.rs @@ -1157,6 +1157,15 @@ focus_metrics = "e" assert_eq!(Config::config_path(), Config::config_path()); } + #[test] + fn config_path_under_test_is_distinct_across_test_threads() { + let current = Config::config_path(); + let other = std::thread::spawn(Config::config_path) + .join() + .expect("config path thread should complete"); + assert_ne!(current, other); + } + #[test] fn primary_config_path_uses_xdg_style_location() { let path = Config::config_path();