rust-subprocess
rust-subprocess copied to clipboard
Fix test that calls setenv() without synchronization
This test is flaky under the following interleaving:
- exec_to_string() grabs MUTATE_ENV.
- env_inherit_set() calls temp_env_var() which calls env::set_var().
- exec_to_string() executes some asserts, one of which fails because the other test messed with the environment in a way exec_to_string() did not expect.
- exec_to_string() panics and poisons MUTATE_ENV.
- env_inherit_set() grabs the lock and panics because it's poisoned.
Taking the lock before setenv fixes this.