mirror of
https://github.com/storytold/figcraft.git
synced 2026-10-24 10:27:00 -06:00
Merge #1032: M8: save-format tests keep their temp folders apart (@MortenHusted)
This commit is contained in:
@@ -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() }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user