Tests: ui-egui tests that load a color profile run in their own process

The canvas's frame key holds the loaded profiles' generation
(cms::profiles_generation), which every profile load or removal in the
process raises. Four ui-egui tests loaded and removed a profile in the
shared test process, so a canvas test running beside them saw its color
key change between two frames:
a_worker_frame_of_other_color_settings_is_not_shown saw the generation go
from 0 to 2, and a_pan_after_the_settling_frame_copies did not copy the
pan because its key no longer matched the kept frame. Both fail in the
same way when a profile is loaded and removed on another thread in the
middle of the test.

- testing::in_own_process runs one test alone in a child test process,
  as the crate's other tests that change process-wide color state
  already do.
- The color wheel gamut reload test, the two Proof Setup tests with a
  removed profile and the Save PDF summary test with a removed profile
  call it first.
This commit is contained in:
dotCooCoo committed 2026-11-27 12:30:23 -08:00
1 parent 98b56f3d97
commit 2d20f54607
4 files changed
+33

No files matched your search

@@ -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";
@@ -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.
@@ -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);
+21
View File
@@ -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.