Skip to content

fix: add EnvGuard mutex serialization to all tests modifying environment variables - #2942

Merged
oferchen merged 1 commit into
masterfrom
fix/envguard-flaky-tests
Mar 22, 2026
Merged

oferchen merged 1 commit into
masterfrom
fix/envguard-flaky-tests

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Add static ENV_MUTEX: Mutex<()> to four test modules that were modifying process-global environment variables without serialization, causing flaky parallel test failures
  • Each test that creates an EnvGuard now acquires the mutex first, matching the established pattern in compress_env.rs, cli_binaries.rs, and the daemon test_env module

Files fixed

File Env var Tests affected
crates/cli/src/frontend/arguments/env.rs RSYNC_PROTECT_ARGS 11 tests
crates/engine/src/local_copy/executor/file/partial.rs RSYNC_PARTIAL_DIR 3 tests
crates/engine/src/local_copy/tests/partial_transfers.rs RSYNC_PARTIAL_DIR 2 tests
crates/embedding/src/lib.rs OC_RSYNC_EMBEDDING_TEST_ENVGUARD 1 test

Closes #1344

Test plan

  • CI nextest passes on all platforms (Linux, macOS, Windows)
  • No new clippy warnings from the added Mutex imports
  • Repeated parallel runs of affected test modules show no flakiness

…ent variables

Tests that mutate process-global environment variables without a
serialization mutex can race when nextest runs them in parallel,
causing flaky failures. Four test modules were missing the mutex.

Add a static ENV_MUTEX to each module and acquire it before every
EnvGuard-protected test, matching the pattern already established in
compress_env.rs, cli_binaries.rs, and the daemon test_env module.
@oferchen
oferchen merged commit f523a6c into master Mar 22, 2026
5 of 10 checks passed
@oferchen
oferchen deleted the fix/envguard-flaky-tests branch March 22, 2026 09:38
@github-actions github-actions Bot added the bug Something isn't working label Mar 22, 2026
oferchen added a commit that referenced this pull request May 1, 2026
…ent variables (#2942)

Tests that mutate process-global environment variables without a
serialization mutex can race when nextest runs them in parallel,
causing flaky failures. Four test modules were missing the mutex.

Add a static ENV_MUTEX to each module and acquire it before every
EnvGuard-protected test, matching the pattern already established in
compress_env.rs, cli_binaries.rs, and the daemon test_env module.
oferchen added a commit that referenced this pull request May 5, 2026
…ent variables (#2942)

Tests that mutate process-global environment variables without a
serialization mutex can race when nextest runs them in parallel,
causing flaky failures. Four test modules were missing the mutex.

Add a static ENV_MUTEX to each module and acquire it before every
EnvGuard-protected test, matching the pattern already established in
compress_env.rs, cli_binaries.rs, and the daemon test_env module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant