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 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-27 13:08:52 +01:00
parent 7262304a6d
commit f08a564fa6
+6 -5
View File
@@ -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();