diff --git a/crates/aura-cli/tests/project_nodes.rs b/crates/aura-cli/tests/project_nodes.rs index cccba91..561bdd1 100644 --- a/crates/aura-cli/tests/project_nodes.rs +++ b/crates/aura-cli/tests/project_nodes.rs @@ -18,6 +18,39 @@ fn aura(args: &[&str], cwd: &Path) -> std::process::Output { .expect("spawn aura") } +/// Property (#258): a test sandbox must not outlive its run — `temp_cwd` must +/// hand back a run-STABLE path that lives off the `env::temp_dir()` tmpfs, so +/// its own pre-create `remove_dir_all` reclaims the previous run instead of +/// stranding one `aura-nodes-*` directory per test-binary invocation. +/// +/// The helper today keys the name on `std::process::id()`, so every run mints a +/// new path the wipe can never match: >50 000 leaked dirs filled a 16 GiB tmpfs +/// to 100%. The in-repo remedy is the knob-lab scaffold's (commit 84e1075, sibling +/// `project_sweep_campaign.rs`): a fixed name under `CARGO_TARGET_TMPDIR`. This +/// pins that property at one representative site — the assertion reads the path +/// value only, so it is deterministic and does not depend on any external state. +#[test] +fn temp_cwd_sandbox_does_not_leak_under_env_temp_dir() { + let sandbox = temp_cwd("leakguard"); + // Read the path value, then reclaim immediately so a red run of this very + // test does not itself add to the leak it describes. + let path = sandbox.clone(); + let _ = std::fs::remove_dir_all(&sandbox); + + let pid = std::process::id().to_string(); + assert!( + !path.to_string_lossy().contains(&pid), + "sandbox name embeds the pid ({pid}), so no later run's pre-create wipe \ + can reclaim it — one directory leaks per run: {}", + path.display(), + ); + assert!( + !path.starts_with(std::env::temp_dir()), + "sandbox lives under env::temp_dir() — the tmpfs the >50k-dir leak filled: {}", + path.display(), + ); +} + #[test] fn nodes_new_scaffolds_a_sibling_crate_and_attaches_it() { let cwd = temp_cwd("attach");