From 8a8ed5045167fcd9b6b5fdba316675262e36e228 Mon Sep 17 00:00:00 2001 From: Mike Solar Date: Sun, 23 Aug 2026 19:05:19 +0800 Subject: [PATCH] oak-plugin: serialize the identity-registry tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every test_project() node packs the same NodeId::identity (a fresh graph's first node), so two tests running in parallel collide in the process-wide registry and one resolves the other's live entry — identity_project_dropped's dangling-upgrade assert then fails intermittently on CI. Both identity tests now share a mutex. --- crates/oak-plugin/src/node.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/oak-plugin/src/node.rs b/crates/oak-plugin/src/node.rs index 213be46f6..013e9d946 100644 --- a/crates/oak-plugin/src/node.rs +++ b/crates/oak-plugin/src/node.rs @@ -463,6 +463,15 @@ pub fn set_input_string_undoable( mod tests { use super::*; + /// Serializes the identity-registry tests: every `test_project()` node + /// gets the same packed `NodeId::identity` (a fresh graph's first + /// node), so two tests running in parallel collide in the process-wide + /// registry and one resolves the other's live entry. + fn identity_lock() -> &'static std::sync::Mutex<()> { + static LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(()); + &LOCK + } + /// 建一个含 Text/StrCombo/Float 输入的测试节点。 fn test_project() -> (Arc>, oak_node::id::NodeId) { let project = oak_node::project::Project::new(); @@ -496,6 +505,7 @@ mod tests { /// 注册表:register → node_from_identity → unregister 全链。 #[test] fn identity_register_roundtrip() { + let _guard = identity_lock().lock().unwrap_or_else(|e| e.into_inner()); let (project, id) = test_project(); let identity = register_node(project.clone(), id); let node = node_from_identity(identity as usize).expect("已登记身份应可解析"); @@ -513,6 +523,7 @@ mod tests { /// 覆盖死条目后重新解析到新 project。 #[test] fn identity_project_dropped() { + let _guard = identity_lock().lock().unwrap_or_else(|e| e.into_inner()); let (project, id) = test_project(); let identity = register_node(project.clone(), id); drop(project);