From f66b169158d51baa6b1bfec97b3e6bfda415b983 Mon Sep 17 00:00:00 2001 From: atlas Date: Tue, 27 Oct 2026 17:30:53 +0100 Subject: [PATCH] give each appservice test its own scratch directory --- swarm-matrix-ctl/src/appservice.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/swarm-matrix-ctl/src/appservice.rs b/swarm-matrix-ctl/src/appservice.rs index 20b8520b..4f1d6e81 100644 --- a/swarm-matrix-ctl/src/appservice.rs +++ b/swarm-matrix-ctl/src/appservice.rs @@ -447,15 +447,16 @@ mod tests { const REGEX: &str = "^@[a-z0-9._=/-]+:t\\.local$"; + /// A directory of its own per call. A counter, not the clock, keeps two + /// tests that start in the same clock tick out of one directory. fn scratch() -> PathBuf { + static NEXT: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0); let dir = std::env::temp_dir().join(format!( "swarm-appservice-{}-{}", std::process::id(), - std::time::SystemTime::now() - .duration_since(std::time::UNIX_EPOCH) - .expect("after the epoch") - .as_nanos() + NEXT.fetch_add(1, std::sync::atomic::Ordering::Relaxed) )); + std::fs::remove_dir_all(&dir).ok(); std::fs::create_dir_all(&dir).expect("temp dir"); dir }