diff --git a/crates/clap-host/src/scan.rs b/crates/clap-host/src/scan.rs index 6bfbadd6..9edec8f5 100644 --- a/crates/clap-host/src/scan.rs +++ b/crates/clap-host/src/scan.rs @@ -150,7 +150,9 @@ mod tests { fn tmp(name: &str) -> PathBuf { let d = std::env::temp_dir().join(format!("soundcraft-clap-scan-{name}-{}", std::process::id())); let _ = std::fs::remove_dir_all(&d); - std::fs::create_dir_all(&d).unwrap(); + // Created exclusively: a folder still there after the cleanup (someone else's) would + // let a link inside it redirect the test's writes. + std::fs::create_dir(&d).unwrap(); d } diff --git a/xtask/src/version.rs b/xtask/src/version.rs index d469c2e9..510b060f 100644 --- a/xtask/src/version.rs +++ b/xtask/src/version.rs @@ -197,8 +197,11 @@ mod tests { #[test] fn a_failed_update_restores_the_manifest() { - let root = std::env::temp_dir().join(format!("xtask-version-restore-{}", std::process::id())); - std::fs::create_dir_all(&root).unwrap(); + // Created exclusively: a folder already there (planted, or left by a failed run) would be + // someone else's, and a link inside it could redirect the writes below. + let nanos = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map_or(0, |d| d.subsec_nanos()); + let root = std::env::temp_dir().join(format!("xtask-version-restore-{}-{nanos}", std::process::id())); + std::fs::create_dir(&root).unwrap(); let path = root.join("Cargo.toml"); std::fs::write(&path, MANIFEST).unwrap(); let err = set(&root, &path, MANIFEST, "2.0.0", || Err("cargo update failed".into())).unwrap_err();