mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-28 09:21:55 +01:00
Merge pull request #9790 from dotCooCoo/fix/canvas-tests-profiles-generation
Tests: ui-egui tests that load a color profile run in their own process, so the profiles generation stays fixed
This commit is contained in:
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);
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user