test(executor): synchronize PHOEBUS_AI_TIMEOUT test modifications with a mutex
Some checks are pending
ci / test (push) Waiting to run
Some checks are pending
ci / test (push) Waiting to run
This commit is contained in:
parent
bed56cd52a
commit
29d2cfd37a
1 changed files with 5 additions and 3 deletions
|
|
@ -394,10 +394,12 @@ mod tests {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Save, set, and restore PHOEBUS_AI_TIMEOUT around a check. Only this
|
static ENV_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());
|
||||||
/// module's tests touch the variable, and no other test asserts a
|
|
||||||
/// timeout value, so parallel execution stays deterministic.
|
/// 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()) {
|
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();
|
let prev = std::env::var("PHOEBUS_AI_TIMEOUT").ok();
|
||||||
match var {
|
match var {
|
||||||
Some(v) => std::env::set_var("PHOEBUS_AI_TIMEOUT", v),
|
Some(v) => std::env::set_var("PHOEBUS_AI_TIMEOUT", v),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue