diff --git a/src/rag/mod.rs b/src/rag/mod.rs index 758d0ee..a88af63 100644 --- a/src/rag/mod.rs +++ b/src/rag/mod.rs @@ -2289,10 +2289,17 @@ mod tests { impl TempDir { fn new(tag: &str) -> Self { - let unique = SystemTime::now() + // Wall-clock nanos alone are not unique across parallel tests + // (coarse clocks hand the same tick to concurrent callers, so two + // tests would share a directory and overwrite each other's files); + // a process-wide counter makes every name distinct. + static SEQ: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0); + let nanos = SystemTime::now() .duration_since(UNIX_EPOCH) .unwrap() .as_nanos(); + let seq = SEQ.fetch_add(1, std::sync::atomic::Ordering::Relaxed); + let unique = format!("{nanos}-{seq}"); let path = env::temp_dir().join(format!("coyote-rag-{tag}-{unique}")); fs::create_dir_all(&path).unwrap(); Self { path }