From 2b993291d40b23fd38349fe7d10f316ba0883b4e Mon Sep 17 00:00:00 2001 From: Toni Alatalo Date: Thu, 1 Oct 2026 17:17:04 +0930 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_011Y54kLgLGzLGqAxwLMFEc9 --- ecc2/src/config/mod.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ecc2/src/config/mod.rs b/ecc2/src/config/mod.rs index 38fd467a1..d8211b30a 100644 --- a/ecc2/src/config/mod.rs +++ b/ecc2/src/config/mod.rs @@ -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())