diff --git a/installer-rs/crates/phoebus-executor/src/ai.rs b/installer-rs/crates/phoebus-executor/src/ai.rs index 7731ee2..5caeabb 100644 --- a/installer-rs/crates/phoebus-executor/src/ai.rs +++ b/installer-rs/crates/phoebus-executor/src/ai.rs @@ -394,10 +394,12 @@ mod tests { ); } - /// Save, set, and restore PHOEBUS_AI_TIMEOUT around a check. Only this - /// module's tests touch the variable, and no other test asserts a - /// timeout value, so parallel execution stays deterministic. + static ENV_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(()); + + /// Save, set, and restore PHOEBUS_AI_TIMEOUT around a check. + /// Serialized via ENV_LOCK to keep parallel test execution deterministic. fn with_ai_timeout(var: Option<&str>, check: impl FnOnce()) { + let _guard = ENV_LOCK.lock().unwrap_or_else(|e| e.into_inner()); let prev = std::env::var("PHOEBUS_AI_TIMEOUT").ok(); match var { Some(v) => std::env::set_var("PHOEBUS_AI_TIMEOUT", v),