From 0449edf64582a065220b8028670ca41c5c069e2b Mon Sep 17 00:00:00 2001 From: MortenHusted Date: Thu, 22 Oct 2026 09:37:35 +0200 Subject: [PATCH] M8: save-format tests keep their temp folders apart SaveFiles named each test's folder after the process id and the clock in nanoseconds. The tests run in parallel and the macOS clock counts microseconds, so two of them often got the same folder and one failed with AlreadyExists (14 of 30 runs here). A counter now keeps the names apart. --- crates/engine/src/save_format_tests.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/save_format_tests.rs b/crates/engine/src/save_format_tests.rs index d635808e..fc4ca775 100644 --- a/crates/engine/src/save_format_tests.rs +++ b/crates/engine/src/save_format_tests.rs @@ -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() } }