Merge #1032: M8: save-format tests keep their temp folders apart (@MortenHusted)

This commit is contained in:
bflatastic
2026-10-24 09:23:24 +07:00
+5 -1
View File
@@ -15,8 +15,12 @@ struct SaveFiles {
impl SaveFiles {
fn new() -> Self {
// Tests run in parallel and the clock can read the same for two of them (macOS counts
// microseconds), so a counter keeps their folders apart.
static NEXT: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
let n = NEXT.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
let stamp = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos();
let dir = std::env::temp_dir().join(format!("figcraft-save-formats-{}-{stamp}", std::process::id()));
let dir = std::env::temp_dir().join(format!("figcraft-save-formats-{}-{stamp}-{n}", std::process::id()));
std::fs::create_dir(&dir).unwrap();
Self { dir, files: Vec::new() }
}