From 5f2649aa63ed2df53f97dcfdf40bbf6136e89a41 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 22 Nov 2026 05:49:11 -0800 Subject: [PATCH] Tests: the filter shortcut test no longer sees plug-ins another test installs Installed plug-ins are process-wide, and the shortcut test each_filter_plugin_takes_a_shortcut_of_its_own and the palette test filter_plugins_with_one_name_show_their_ids both install two filter plug-ins named Same Name. When the two ran at the same time, the shortcut test counted 4 Same Name lines in the exported shortcuts instead of its own 2, and its own row took an id suffix. The tests that install filter plug-ins under a shared name, or that check how plug-ins sharing a name are told apart, now hold one test lock (SHARED_PLUGIN_NAMES in the ui-egui test module) while their plug-ins are installed: the shortcut test and both palette tests (each_filter_plugin_is_a_result_of_its_own checks the exact labels of two filters named Group). Running the two tests together with --test-threads=8, 50 times on Linux: 0 of 50 passed before, 50 of 50 after. --- crates/ui-egui/src/palette.rs | 2 ++ crates/ui-egui/src/shortcuts/tests.rs | 1 + crates/ui-egui/src/tests.rs | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/crates/ui-egui/src/palette.rs b/crates/ui-egui/src/palette.rs index a3c5fed207..29cc18bf69 100644 --- a/crates/ui-egui/src/palette.rs +++ b/crates/ui-egui/src/palette.rs @@ -3230,6 +3230,7 @@ mod tests { #[test] fn each_filter_plugin_is_a_result_of_its_own() { use vectorcraft_plugins::wat as tpl; + let _names = crate::tests::SHARED_PLUGIN_NAMES.lock().unwrap_or_else(|e| e.into_inner()); let (one, two) = ("test.UI.palette_filter-one", "test.UI.palette_filter-two"); let (key_one, key_two) = (format!("plugin:{one}"), format!("plugin:{two}")); let install = |id: &str, params: &str| { @@ -3509,6 +3510,7 @@ mod tests { #[test] fn filter_plugins_with_one_name_show_their_ids() { use vectorcraft_plugins::wat as tpl; + let _names = crate::tests::SHARED_PLUGIN_NAMES.lock().unwrap_or_else(|e| e.into_inner()); let (one, two) = ("test.UI.palette_same-one", "test.UI.palette_same-two"); for id in [one, two] { let manifest = format!(r#"{{"id":"{id}","name":"Same Name","version":"1","kind":"filter","params":{{"wiggle":{{"type":"bool"}}}}}}"#); diff --git a/crates/ui-egui/src/shortcuts/tests.rs b/crates/ui-egui/src/shortcuts/tests.rs index 063d63bb14..45314702b8 100644 --- a/crates/ui-egui/src/shortcuts/tests.rs +++ b/crates/ui-egui/src/shortcuts/tests.rs @@ -3391,6 +3391,7 @@ fn a_live_effect_plugin_installed_later_takes_a_shortcut_of_its_own() { fn each_filter_plugin_takes_a_shortcut_of_its_own() { use serde_json::Value; use vectorcraft_plugins::wat as tpl; + let _names = crate::tests::SHARED_PLUGIN_NAMES.lock().unwrap_or_else(|e| e.into_inner()); let (one, two) = ("test.UI.key_filter-one", "test.UI.key_filter-two"); let (key_one, key_two) = (format!("plugin:{one}"), format!("plugin:{two}")); let install = |id: &str, name: &str, params: &str| { diff --git a/crates/ui-egui/src/tests.rs b/crates/ui-egui/src/tests.rs index e0619ddaf7..36a9cdc17b 100644 --- a/crates/ui-egui/src/tests.rs +++ b/crates/ui-egui/src/tests.rs @@ -62,3 +62,8 @@ mod toolescape; mod trace_runs; mod transparencygrid; mod widthtool; + +/// Installed plug-ins are process-wide. Tests that install filter plug-ins under a name another +/// test also installs, or that check how plug-ins sharing a name are told apart, hold this lock +/// while their plug-ins are installed, so each sees only its own plug-ins under that name. +pub(super) static SHARED_PLUGIN_NAMES: std::sync::Mutex<()> = std::sync::Mutex::new(());