From f08a564fa60ab1722181c59aa226ecedc7f975cb Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Tue, 27 Oct 2026 13:08:52 +0100 Subject: [PATCH] test: give each win_screen test its own temp dir The helper named its resource root after the pid, the poem flag and the end text's length, so two tests with the same arguments, running in parallel, shared it and one removed the other's files (os error 22 in the_screen_ends_once_everything_rolled_past). A counter makes each call's directory unique. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/win_screen.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/horizon-client/src/win_screen.rs b/crates/horizon-client/src/win_screen.rs index 8d2a1c145..9d100c744 100644 --- a/crates/horizon-client/src/win_screen.rs +++ b/crates/horizon-client/src/win_screen.rs @@ -309,11 +309,12 @@ mod tests { /// A resource root with only the credits texts: every glyph is the /// missing one, 6 pixels wide. fn screen(poem: bool, end: &str, credits: &str, post: &str) -> WinScreen { - let root = std::env::temp_dir().join(format!( - "horizon-win-screen-{}-{poem}-{}", - std::process::id(), - end.len() - )); + // One directory per call: tests run in parallel, and two of them with + // the same arguments used to remove each other's files. + static NEXT: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); + let n = NEXT.fetch_add(1, std::sync::atomic::Ordering::Relaxed); + let root = + std::env::temp_dir().join(format!("horizon-win-screen-{}-{n}", std::process::id())); let texts = root.join("assets/minecraft/texts"); std::fs::create_dir_all(&texts).unwrap(); std::fs::write(texts.join("end.txt"), end).unwrap();