From 05565ee8a2a54b340305cde25eb93c7fb69e21c5 Mon Sep 17 00:00:00 2001 From: claude Date: Mon, 13 Jul 2026 19:40:59 +0200 Subject: [PATCH] =?UTF-8?q?test:=20red=20for=20#258=20=E2=80=94=20temp=5Fc?= =?UTF-8?q?wd=20sandbox=20leaks=20one=20dir=20per=20run=20into=20/tmp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The helper keys its sandbox on std::process::id() under env::temp_dir(), so the pre-create wipe never matches a prior run's path: one directory strands per test-binary invocation on the 16 GiB tmpfs (>50k dirs by 2026-07-13). The test pins the property at one representative site: the returned path embeds no PID and lives off env::temp_dir(). refs #258 --- crates/aura-cli/tests/project_nodes.rs | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) 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");