Repository navigation
test: ensure all env-modifying tests use EnvGuard for isolation - #2925
Merged
Merged
Conversation
Replace raw env::set_var / env::remove_var calls in test code with scoped EnvGuard structs that automatically restore the previous value on drop. This prevents environment variable leaks between tests when a test panics before manual cleanup. Files converted: - engine partial_transfers.rs: 2 tests (PartialEnvGuard) - engine partial.rs: 3 tests (EnvGuard) - cli arguments/env.rs: replaced closure-based with_env_var with EnvGuard Also includes cargo fmt reformats in batch, core, fast_io, and protocol test files. Closes #1344
oferchen
force-pushed
the
test/envguard-audit
branch
from
March 22, 2026 08:02
5e5ad87 to
fa47111
Compare
oferchen
added a commit
that referenced
this pull request
May 1, 2026
Replace raw env::set_var / env::remove_var calls in test code with scoped EnvGuard structs that automatically restore the previous value on drop. This prevents environment variable leaks between tests when a test panics before manual cleanup. Files converted: - engine partial_transfers.rs: 2 tests (PartialEnvGuard) - engine partial.rs: 3 tests (EnvGuard) - cli arguments/env.rs: replaced closure-based with_env_var with EnvGuard Also includes cargo fmt reformats in batch, core, fast_io, and protocol test files. Closes #1344
oferchen
added a commit
that referenced
this pull request
May 5, 2026
Replace raw env::set_var / env::remove_var calls in test code with scoped EnvGuard structs that automatically restore the previous value on drop. This prevents environment variable leaks between tests when a test panics before manual cleanup. Files converted: - engine partial_transfers.rs: 2 tests (PartialEnvGuard) - engine partial.rs: 3 tests (EnvGuard) - cli arguments/env.rs: replaced closure-based with_env_var with EnvGuard Also includes cargo fmt reformats in batch, core, fast_io, and protocol test files. Closes #1344
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
env::set_var/env::remove_varcalls in test code with scopedEnvGuardstructs that automatically restore the previous value on dropFiles converted
crates/engine/src/local_copy/tests/partial_transfers.rs- 2 tests now usePartialEnvGuardcrates/engine/src/local_copy/executor/file/partial.rs- 3 tests now useEnvGuardcrates/cli/src/frontend/arguments/env.rs- replaced closure-basedwith_env_varpattern withEnvGuardAlso includes
cargo fmtreformats in batch, core, fast_io, and protocol test files.Closes #1344
Test plan