fix(ecc2): report test config root cleanup failures instead of ignoring them

Addresses review feedback on #3277: the Drop impl for the per-thread test
config root discarded remove_dir_all errors, against the AGENTS.md rule
"Never silently swallow errors".

The root is now created up front when a test thread first asks for it, so
it always exists at cleanup. remove_dir_all can then only fail for a real
reason, and any failure is reported on stderr with no NotFound special
case. Creation failure panics in test setup.

No red step: this changes failure reporting only, which has no observable
test behaviour. Full suite: 491 passed, 0 failed, 1 ignored, and no scratch
directories left behind.

Refs #3276

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011Y54kLgLGzLGqAxwLMFEc9
This commit is contained in:
Toni AlataloandClaude Sonnet 5.5 committed 2026-10-01 17:17:04 +09:30
1 parent 708d621372
commit 2b993291d4
1 file changed
+12 -4
+12 -4
View File
@@ -525,14 +525,22 @@ impl Config {
impl Drop for TestConfigRoot {
fn drop(&mut self) {
let _ = std::fs::remove_dir_all(&self.0);
if let Err(error) = std::fs::remove_dir_all(&self.0) {
eprintln!(
"failed to remove test config root {}: {error}",
self.0.display()
);
}
}
}
thread_local! {
static ROOT: TestConfigRoot = TestConfigRoot(
std::env::temp_dir().join(format!("ecc2-test-config-{}", uuid::Uuid::new_v4())),
);
static ROOT: TestConfigRoot = {
let root = std::env::temp_dir()
.join(format!("ecc2-test-config-{}", uuid::Uuid::new_v4()));
std::fs::create_dir_all(&root).expect("create test config root");
TestConfigRoot(root)
};
}
ROOT.with(|root| root.0.clone())