From 7668a2c378cb2a65abfa49c13fe839a3504e2a95 Mon Sep 17 00:00:00 2001 From: Guillem Hermida Date: Fri, 23 Oct 2026 19:18:36 +0200 Subject: [PATCH] tests: each forms test saves into a folder of its own tabbing_back_to_the_same_field_then_saving_keeps_the_committed_value (its same-frame case) and typing_and_saving_in_the_same_frame_saves_the_last_keystrokes both asked scratch() for "same-frame". The tests of the it binary share one process id and run in parallel, so they got the same folder, and one could clear it while the other was saving into it: the save then failed to read back with NotFound. scratch() now adds a number taken per call. --- crates/ui-egui/tests/it/forms.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/tests/it/forms.rs b/crates/ui-egui/tests/it/forms.rs index 230addd65..8e1a3b760 100644 --- a/crates/ui-egui/tests/it/forms.rs +++ b/crates/ui-egui/tests/it/forms.rs @@ -500,8 +500,13 @@ fn wait_for_file(h: &mut Harness<'static, PdfCraftApp>, path: &std::path::Path) h.run_steps(1); } +/// A fresh folder of its own for one test. The tests of this binary share one process id and run +/// in parallel, and two of them name their folder "same-frame": a number taken per call keeps one +/// test from clearing the folder another is saving into. fn scratch(name: &str) -> std::path::PathBuf { - let dir = std::env::temp_dir().join(format!("pdfcraft-forms-{name}-{}", std::process::id())); + static NEXT: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); + let n = NEXT.fetch_add(1, std::sync::atomic::Ordering::Relaxed); + let dir = std::env::temp_dir().join(format!("pdfcraft-forms-{name}-{}-{n}", std::process::id())); let _ = std::fs::remove_dir_all(&dir); std::fs::create_dir_all(&dir).unwrap(); dir