diff --git a/lib/configparser/Cargo.toml b/lib/configparser/Cargo.toml index 0245c40556..a2edac7b04 100644 --- a/lib/configparser/Cargo.toml +++ b/lib/configparser/Cargo.toml @@ -14,6 +14,7 @@ pest_derive = "2.1.0" shellexpand = "1.0.0" [dev-dependencies] +lazy_static = "1.3.0" minibench = { path = "../minibench" } tempdir = "0.3.7" diff --git a/lib/configparser/src/hg.rs b/lib/configparser/src/hg.rs index 4928b1bf62..e7d2e0068e 100644 --- a/lib/configparser/src/hg.rs +++ b/lib/configparser/src/hg.rs @@ -514,8 +514,18 @@ mod tests { use crate::config::tests::write_file; + use lazy_static::lazy_static; + use std::sync::Mutex; + + lazy_static! { + /// Lock for the environment. This should be acquired by tests that rely on particular + /// environment variable values that might be overwritten by other tests. + static ref ENV_LOCK: Mutex<()> = Mutex::new(()); + } + #[test] fn test_basic_hgplain() { + let _guard = ENV_LOCK.lock().unwrap(); env::set_var(HGPLAIN, "1"); env::remove_var(HGPLAINEXCEPT); @@ -540,6 +550,7 @@ mod tests { #[test] fn test_hgplainexcept() { + let _guard = ENV_LOCK.lock().unwrap(); env::remove_var(HGPLAIN); env::set_var(HGPLAINEXCEPT, "alias,revsetalias");