From 96e539062157c96ef82209d7277079c43380557f Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Fri, 21 Aug 2026 12:03:11 -0600 Subject: [PATCH] test: use collision-proof temp dirs in macro_policy tests The with_macro_dirs fixture derived its temp-dir name from a wall-clock nanosecond timestamp, so parallel tests starting in the same clock tick shared a directory and saw each other's macro files (flaky on CI runners with coarse tick granularity). A process id + atomic counter makes the name unique by construction. --- src/config/macro_policy.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/config/macro_policy.rs b/src/config/macro_policy.rs index 6636778..4c08ed7 100644 --- a/src/config/macro_policy.rs +++ b/src/config/macro_policy.rs @@ -290,7 +290,8 @@ mod tests { use crate::utils::get_env_name; use serial_test::serial; use std::path::Path; - use std::{env, fs, time}; + use std::sync::atomic::{AtomicUsize, Ordering}; + use std::{env, fs, process}; fn valid_macro() -> Macro { Macro { @@ -748,10 +749,12 @@ mod tests { } fn with_macro_dirs(f: F) { - let unique = time::SystemTime::now() - .duration_since(time::UNIX_EPOCH) - .unwrap() - .as_nanos(); + static COUNTER: AtomicUsize = AtomicUsize::new(0); + let unique = format!( + "{}-{}", + process::id(), + COUNTER.fetch_add(1, Ordering::Relaxed) + ); let root = env::temp_dir().join(format!("coyote-macro-policy-test-{unique}")); let workspace = root.join("workspace-macros"); let global = root.join("global-macros");