diff --git a/crates/ui-egui/src/dialogs/proof_setup.rs b/crates/ui-egui/src/dialogs/proof_setup.rs index cb0e6981d2..9e0ce9adc7 100644 --- a/crates/ui-egui/src/dialogs/proof_setup.rs +++ b/crates/ui-egui/src/dialogs/proof_setup.rs @@ -654,6 +654,9 @@ mod tests { /// set, and redraw the documents. #[test] fn cancel_puts_back_a_view_whose_profile_was_removed() { + if !crate::testing::in_own_process("dialogs::proof_setup::tests::cancel_puts_back_a_view_whose_profile_was_removed") { + return; + } let _v = DefaultProofView::new(); let (mut app, ctx) = app(); let name = "Proof Setup Removed RGB"; @@ -760,6 +763,9 @@ mod tests { /// stays open with the proof view as it was. #[test] fn ok_with_an_unknown_device_keeps_the_dialog_open() { + if !crate::testing::in_own_process("dialogs::proof_setup::tests::ok_with_an_unknown_device_keeps_the_dialog_open") { + return; + } let _v = DefaultProofView::new(); let (mut app, ctx) = app(); let name = "Proof Setup Gone RGB"; diff --git a/crates/ui-egui/src/dialogs/save_pdf/tests.rs b/crates/ui-egui/src/dialogs/save_pdf/tests.rs index c76c79f1d0..091a2d5d97 100644 --- a/crates/ui-egui/src/dialogs/save_pdf/tests.rs +++ b/crates/ui-egui/src/dialogs/save_pdf/tests.rs @@ -285,6 +285,9 @@ fn save_summary_sees_a_deleted_flattener_preset() { /// dialog stays open: they are then refused, and nothing is written. #[test] fn save_summary_sees_a_removed_profile() { + if !crate::testing::in_own_process("dialogs::save_pdf::tests::save_summary_sees_a_removed_profile") { + return; + } use vectorcraft_color::cms; let name = "Summary Stamp CMYK"; // The built-in CMYK profile's file renamed `name`: padded with spaces, which names drop. diff --git a/crates/ui-egui/src/panels/tests_color_wheel_gamut.rs b/crates/ui-egui/src/panels/tests_color_wheel_gamut.rs index 0d8aae0ffd..59674de1af 100644 --- a/crates/ui-egui/src/panels/tests_color_wheel_gamut.rs +++ b/crates/ui-egui/src/panels/tests_color_wheel_gamut.rs @@ -42,6 +42,9 @@ fn uncalibrated_cmyk_marks_nothing() { /// color settings stay the same; the panel keeps drawing through the change. #[test] fn the_grid_is_computed_again_after_a_profile_is_loaded() { + if !crate::testing::in_own_process("panels::tests_color_wheel_gamut::the_grid_is_computed_again_after_a_profile_is_loaded") { + return; + } let mut p = Panel::new(app("#3366cc", "box", true)); /// Unregisters the profile when dropped, also after a failed assertion. struct Unregister(&'static str); diff --git a/crates/ui-egui/src/testing.rs b/crates/ui-egui/src/testing.rs index 476ab0b16f..1af93e507d 100644 --- a/crates/ui-egui/src/testing.rs +++ b/crates/ui-egui/src/testing.rs @@ -91,6 +91,27 @@ pub(crate) fn custom_dictionary() -> std::sync::MutexGuard<'static, ()> { HELD.lock().unwrap_or_else(std::sync::PoisonError::into_inner) } +/// Runs the test `name` (its path in the crate, such as `canvas::tests::a_test`) alone in a child test process, for a +/// test that loads or removes a color profile. The loaded profiles are the whole process's, and the canvas's frame key +/// holds their generation ([`vectorcraft_color::cms::profiles_generation`]), so a profile loaded in this process while +/// another test renders changes that test's keys. In the child it returns `true`, and the test goes on. Here it waits +/// for the child, fails when the child's test fails, and returns `false`. +pub(crate) fn in_own_process(name: &str) -> bool { + const CHILD: &str = "VECTORCRAFT_TEST_OWN_PROCESS"; + if std::env::var_os(CHILD).is_some_and(|v| v == name) { + return true; + } + let output = + std::process::Command::new(std::env::current_exe().unwrap()).args(["--exact", name, "--nocapture"]).env(CHILD, name).output().unwrap(); + let stdout = String::from_utf8_lossy(&output.stdout); + assert!( + output.status.success() && stdout.contains("test result: ok. 1 passed; 0 failed;"), + "{name} failed in its own process:\n{stdout}\n{}", + String::from_utf8_lossy(&output.stderr), + ); + false +} + /// The default proof view, held: View › Proof Colors, Overprint Preview and Separations Preview are the whole process's /// and the canvas draws through them, so a test that sets them, or that compares the canvas's renders, holds this. It /// leaves the default view when it is dropped.