tests: every test dir is removed when its test ends, pass or panic
Many test helpers removed their temp dir only before the test, or only on pass, so runs left them behind: 117,000 filled /tmp (RAM here) and stopped a mutation run. Each now holds a guard that removes the dir on drop, unwind included; servers started on a test dir hold its guard until they stop. A full cargo test --workspace leaves 0 dirs (859 before). just sweep-test-tmp stays for runs killed mid-test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T3gXMVt7XJPi6ens1or9Dj
This commit is contained in:
44 files changed
+952
-163
No files matched your search
@@ -68,6 +68,16 @@ struct Books {
|
||||
toml: PathBuf,
|
||||
}
|
||||
|
||||
/// The books dir and the folders beside it go when the test ends, pass or
|
||||
/// panic.
|
||||
impl Drop for Books {
|
||||
fn drop(&mut self) {
|
||||
if let Some(base) = self.dir.parent() {
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn books(tag: &str) -> Books {
|
||||
let base =
|
||||
std::env::temp_dir().join(format!("ledger-mcp-tin-files-{}-{tag}", std::process::id()));
|
||||
|
||||
Reference in new issue
Block a user