Skip to main content

test_env_lock

Function test_env_lock 

Source
pub fn test_env_lock() -> TestEnvGuard
Expand description

Reentrant test env lock. Serializes env-mutating tests across threads (the point — std::env::set_var is not thread-safe) while letting the SAME thread re-acquire without deadlocking. A test and a setup() helper (or isolated_data_dir) can both take it; only the outermost acquisition holds the underlying mutex, nested ones just bump a per-thread depth. Other threads still block, so cross-test serialization is unchanged.