fix(test): anchor all test sandboxes on reclaimable pid-free names
Every hand-rolled test-sandbox helper keyed its directory on
std::process::id() under env::temp_dir(), so the pre-create wipe never
matched a prior run's path: one directory stranded per helper site per
test-binary invocation, >50k dirs / 15.5 GiB on the 16 GiB tmpfs by
2026-07-13.
The remedy extends commit 84e1075's knob-lab pattern to every site:
fixed, tag-keyed, PID-FREE names under the build-tree tmp anchor, each
site keeping its pre-create remove_dir_all — which now genuinely
reclaims the previous run. Integration/bench targets use
env!("CARGO_TARGET_TMPDIR"); src-internal unit-test helpers (cargo sets
that var only for integration/bench targets) derive the same anchor
from env!("CARGO_MANIFEST_DIR") + ../../target/tmp. Residue is bounded
to one directory per site, on disk instead of the tmpfs, per checkout.
One deliberate exception: project_new.rs's tmp() stays under
env::temp_dir() because two of its tests (new_outside_a_work_tree_*)
need a base genuinely detached from any git work tree, and target/
lives inside the checkout's work tree. Its name carries a per-checkout
hash discriminator instead, so concurrently running checkouts (which
share /tmp) cannot race on the fixed name while each run still
reclaims its predecessor.
tempfile-RAII was considered and rejected (issue #258 decision log):
it cannot cover the process-lifetime OnceLock scaffolds (statics never
drop), adds a dependency, and still strands kill-leftovers on the
tmpfs.
Verified: full workspace suite green (incl. the new RED regression
test temp_cwd_sandbox_does_not_leak_under_env_temp_dir), clippy clean,
sandboxes observed under target/tmp with stable names across runs.
Stale pre-fix PID-keyed dirs in /tmp are not swept by this change and
age out only by manual cleanup.
closes #258
This commit is contained in:
@@ -5321,7 +5321,8 @@ mod tests {
|
||||
#[test]
|
||||
fn reproduce_family_re_derives_every_member_bit_identically() {
|
||||
// a unique temp runs store so the on-disk family + blueprint store do not collide.
|
||||
let dir = std::env::temp_dir().join(format!("aura-repro-{}", std::process::id()));
|
||||
let dir = std::path::Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../../target/tmp"))
|
||||
.join("aura-repro");
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
std::fs::create_dir_all(&dir).expect("temp dir");
|
||||
let reg = Registry::open(dir.join("runs.jsonl"));
|
||||
@@ -5366,7 +5367,8 @@ mod tests {
|
||||
// under a NON-default vol-stop regime (a campaign risk-regime cell, or wf/mc/
|
||||
// generalize with --stop-length/--stop-k) must still reproduce bit-identically;
|
||||
// silently re-running it under the default Vol{3,2.0} reports a spurious DIVERGED.
|
||||
let dir = std::env::temp_dir().join(format!("aura-repro-stop-{}", std::process::id()));
|
||||
let dir = std::path::Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../../target/tmp"))
|
||||
.join("aura-repro-stop");
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
std::fs::create_dir_all(&dir).expect("temp dir");
|
||||
let reg = Registry::open(dir.join("runs.jsonl"));
|
||||
@@ -5434,7 +5436,8 @@ mod tests {
|
||||
/// vol proxy).
|
||||
#[test]
|
||||
fn reproduce_family_re_derives_a_costed_member_bit_identically() {
|
||||
let dir = std::env::temp_dir().join(format!("aura-repro-cost-{}", std::process::id()));
|
||||
let dir = std::path::Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../../target/tmp"))
|
||||
.join("aura-repro-cost");
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
std::fs::create_dir_all(&dir).expect("temp dir");
|
||||
let reg = Registry::open(dir.join("runs.jsonl"));
|
||||
@@ -5489,7 +5492,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn reproduce_family_re_derives_every_mc_member_bit_identically() {
|
||||
let dir = std::env::temp_dir().join(format!("aura-repro-mc-{}", std::process::id()));
|
||||
let dir = std::path::Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../../target/tmp"))
|
||||
.join("aura-repro-mc");
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
std::fs::create_dir_all(&dir).expect("temp dir");
|
||||
let reg = Registry::open(dir.join("runs.jsonl"));
|
||||
@@ -5590,7 +5594,8 @@ mod tests {
|
||||
/// must show. Sweep / walk-forward labels still echo their params (covered elsewhere).
|
||||
#[test]
|
||||
fn reproduce_mc_member_labels_carry_the_seed() {
|
||||
let dir = std::env::temp_dir().join(format!("aura-repro-mc-seed-{}", std::process::id()));
|
||||
let dir = std::path::Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../../target/tmp"))
|
||||
.join("aura-repro-mc-seed");
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
std::fs::create_dir_all(&dir).expect("temp dir");
|
||||
let reg = Registry::open(dir.join("runs.jsonl"));
|
||||
|
||||
@@ -588,7 +588,9 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn discover_walks_up_to_aura_toml() {
|
||||
let tmp = std::env::temp_dir().join(format!("aura-disc-{}", std::process::id()));
|
||||
let tmp = std::path::Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../../target/tmp"))
|
||||
.join("aura-disc");
|
||||
let _ = std::fs::remove_dir_all(&tmp);
|
||||
let nested = tmp.join("a/b/c");
|
||||
std::fs::create_dir_all(&nested).unwrap();
|
||||
assert_eq!(discover_from(&nested), None);
|
||||
@@ -611,7 +613,9 @@ mod tests {
|
||||
/// and stamps commit-only provenance.
|
||||
#[test]
|
||||
fn data_only_project_loads_without_a_crate() {
|
||||
let tmp = std::env::temp_dir().join(format!("aura-dataonly-{}", std::process::id()));
|
||||
let tmp = std::path::Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../../target/tmp"))
|
||||
.join("aura-dataonly");
|
||||
let _ = std::fs::remove_dir_all(&tmp);
|
||||
std::fs::create_dir_all(&tmp).unwrap();
|
||||
std::fs::write(tmp.join("Aura.toml"), "[paths]\nruns = \"runs\"\n").unwrap();
|
||||
let p = load(&tmp, false).expect("data-only load");
|
||||
@@ -632,7 +636,9 @@ mod tests {
|
||||
/// changes the data location depending on the caller's working directory.
|
||||
#[test]
|
||||
fn data_path_resolves_a_relative_paths_data_against_the_project_root() {
|
||||
let tmp = std::env::temp_dir().join(format!("aura-datarel-{}", std::process::id()));
|
||||
let tmp = std::path::Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../../target/tmp"))
|
||||
.join("aura-datarel");
|
||||
let _ = std::fs::remove_dir_all(&tmp);
|
||||
std::fs::create_dir_all(&tmp).unwrap();
|
||||
std::fs::write(tmp.join("Aura.toml"), "[paths]\ndata = \"data\"\n").unwrap();
|
||||
let p = load(&tmp, false).expect("data-only load");
|
||||
@@ -643,7 +649,9 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn two_nodes_pointers_refuse_with_multi_crate() {
|
||||
let tmp = std::env::temp_dir().join(format!("aura-multi-{}", std::process::id()));
|
||||
let tmp = std::path::Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../../target/tmp"))
|
||||
.join("aura-multi");
|
||||
let _ = std::fs::remove_dir_all(&tmp);
|
||||
std::fs::create_dir_all(&tmp).unwrap();
|
||||
std::fs::write(tmp.join("Aura.toml"), "[nodes]\ncrates = [\"a\", \"b\"]\n").unwrap();
|
||||
let e = load(&tmp, false).unwrap_err();
|
||||
@@ -653,7 +661,9 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn a_broken_nodes_pointer_names_the_pointer() {
|
||||
let tmp = std::env::temp_dir().join(format!("aura-badptr-{}", std::process::id()));
|
||||
let tmp = std::path::Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../../target/tmp"))
|
||||
.join("aura-badptr");
|
||||
let _ = std::fs::remove_dir_all(&tmp);
|
||||
std::fs::create_dir_all(&tmp).unwrap();
|
||||
std::fs::write(tmp.join("Aura.toml"), "[nodes]\ncrates = [\"../nope\"]\n").unwrap();
|
||||
let e = load(&tmp, false).unwrap_err();
|
||||
@@ -671,7 +681,9 @@ mod tests {
|
||||
/// that (`load` still refuses → CLI exit 1).
|
||||
#[test]
|
||||
fn a_missing_nodes_pointer_dir_refuses_without_the_cargo_metadata_leak() {
|
||||
let tmp = std::env::temp_dir().join(format!("aura-missingptr-{}", std::process::id()));
|
||||
let tmp = std::path::Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../../target/tmp"))
|
||||
.join("aura-missingptr");
|
||||
let _ = std::fs::remove_dir_all(&tmp);
|
||||
std::fs::create_dir_all(&tmp).unwrap();
|
||||
// `missing-node-crate` is never created — the pointer target is absent.
|
||||
std::fs::write(
|
||||
|
||||
@@ -488,7 +488,9 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn scaffold_project_refuses_existing_destination() {
|
||||
let tmp = std::env::temp_dir().join(format!("aura-pscaf-{}", std::process::id()));
|
||||
let tmp = std::path::Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../../target/tmp"))
|
||||
.join("aura-pscaf");
|
||||
let _ = std::fs::remove_dir_all(&tmp);
|
||||
std::fs::create_dir_all(tmp.join("x")).unwrap();
|
||||
let spec = project_scaffold_spec("x", &tmp).unwrap();
|
||||
let e = scaffold_project(&spec).unwrap_err();
|
||||
@@ -498,7 +500,9 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn scaffold_node_crate_refuses_existing_dir_and_missing_engine() {
|
||||
let tmp = std::env::temp_dir().join(format!("aura-scaf-{}", std::process::id()));
|
||||
let tmp = std::path::Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../../target/tmp"))
|
||||
.join("aura-scaf");
|
||||
let _ = std::fs::remove_dir_all(&tmp);
|
||||
std::fs::create_dir_all(&tmp).unwrap();
|
||||
// existing destination
|
||||
let mut spec = scaffold_spec("x", None, None, &tmp).unwrap();
|
||||
|
||||
@@ -895,10 +895,9 @@ mod tests {
|
||||
/// that silently, before the dispatch rewire ever exercises the path live.
|
||||
#[test]
|
||||
fn register_generated_g_stores_documents_the_campaign_can_actually_resolve() {
|
||||
let dir = std::env::temp_dir().join(format!(
|
||||
"aura-verb-sugar-generalize-registry-test-{}",
|
||||
std::process::id()
|
||||
));
|
||||
let dir = std::path::Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../../target/tmp"))
|
||||
.join("aura-verb-sugar-generalize-registry-test");
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let reg = aura_registry::Registry::open(dir.join("runs.jsonl"));
|
||||
|
||||
@@ -1047,10 +1046,9 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn register_generated_wf_stores_documents_the_campaign_can_actually_resolve() {
|
||||
let dir = std::env::temp_dir().join(format!(
|
||||
"aura-verb-sugar-walkforward-registry-test-{}",
|
||||
std::process::id()
|
||||
));
|
||||
let dir = std::path::Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../../target/tmp"))
|
||||
.join("aura-verb-sugar-walkforward-registry-test");
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let reg = aura_registry::Registry::open(dir.join("runs.jsonl"));
|
||||
let ax = wf_axes();
|
||||
@@ -1140,10 +1138,9 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn register_generated_mc_stores_documents_the_campaign_can_actually_resolve() {
|
||||
let dir = std::env::temp_dir().join(format!(
|
||||
"aura-verb-sugar-mc-registry-test-{}",
|
||||
std::process::id()
|
||||
));
|
||||
let dir = std::path::Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../../target/tmp"))
|
||||
.join("aura-verb-sugar-mc-registry-test");
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let reg = aura_registry::Registry::open(dir.join("runs.jsonl"));
|
||||
let ax = wf_axes();
|
||||
|
||||
Reference in New Issue
Block a user