From 04bf2dcab9be5a5d47752e8fc884a2f9cc3b6b95 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 21 Oct 2026 04:25:50 -0700 Subject: [PATCH] Tests: the data set export test checks the whole file in a folder emptied first (#2969) variables_panel_data_sets_ask_off_the_ui_thread checked only that the exported file started with the header, so an export of the header alone passed. Its folder was named after the process ID and was used as it was found, so an out.csv left by an earlier run with the same ID passed the check even when the export wrote nothing. The test now empties its folder from vectorcraft_testkit::temp_dir before use, and checks that the file holds the header and the row for data set B and nothing else. --- crates/ui-egui/src/tests_picks.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/tests_picks.rs b/crates/ui-egui/src/tests_picks.rs index 90d73270e..898641d4c 100644 --- a/crates/ui-egui/src/tests_picks.rs +++ b/crates/ui-egui/src/tests_picks.rs @@ -222,13 +222,14 @@ fn load_profile_asks_off_the_ui_thread() { } /// The Variables panel menu's Import Data Sets… and Export Data Sets… ask off the UI thread: the -/// data sets in the file picked are loaded, and the data sets are written to the path the dialog -/// answers. +/// data sets in the file picked are loaded, and the header and data set `B` are written to the +/// path the dialog answers. #[test] fn variables_panel_data_sets_ask_off_the_ui_thread() { let (mut app, shown, _) = app(); app.run("file.new", json!({"width": 100, "height": 80})).unwrap(); - let dir = std::env::temp_dir().join(format!("vc-picks-data-sets-{}", std::process::id())); + let dir = vectorcraft_testkit::temp_dir("picks-data-sets"); + let _ = std::fs::remove_dir_all(&dir); std::fs::create_dir_all(&dir).unwrap(); let (csv, out) = (dir.join("sets.csv"), dir.join("out.csv")); std::fs::write(&csv, "name,Name\nB,y\n").unwrap(); @@ -244,7 +245,7 @@ fn variables_panel_data_sets_ask_off_the_ui_thread() { assert!(matches!(shown.requests().as_slice(), [PickRequest::Save(_)])); shown.answer(&[&out.to_string_lossy()]); poll(&mut app); - assert!(std::fs::read_to_string(&out).is_ok_and(|text| text.starts_with("name,Name\n")), "{}", app.ui.status); + assert_eq!(std::fs::read_to_string(&out).ok().as_deref(), Some("name,Name\nB,y\n"), "{}", app.ui.status); let _ = std::fs::remove_dir_all(dir); }