Skip to content

test: ensure all env-modifying tests use EnvGuard for isolation - #2925

Merged
oferchen merged 1 commit into
masterfrom
test/envguard-audit
Mar 22, 2026
Merged

oferchen merged 1 commit into
masterfrom
test/envguard-audit

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Replace raw env::set_var / env::remove_var calls in test code with scoped EnvGuard structs that automatically restore the previous value on drop
  • Prevents environment variable leaks between tests when a test panics before manual cleanup
  • Converted 3 files in the engine and cli crates that were using bare unsafe env mutations or closure-based patterns instead of EnvGuard

Files converted

  • crates/engine/src/local_copy/tests/partial_transfers.rs - 2 tests now use PartialEnvGuard
  • crates/engine/src/local_copy/executor/file/partial.rs - 3 tests now use EnvGuard
  • crates/cli/src/frontend/arguments/env.rs - replaced closure-based with_env_var pattern with EnvGuard

Also includes cargo fmt reformats in batch, core, fast_io, and protocol test files.

Closes #1344

Test plan

  • CI passes: fmt+clippy, nextest on all platforms (Linux, macOS, Windows, musl)
  • Verify env-modifying tests still pass and properly restore environment

@github-actions github-actions Bot added the test label Mar 21, 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
oferchen force-pushed the test/envguard-audit branch from 5e5ad87 to fa47111 Compare March 22, 2026 08:02
@oferchen
oferchen merged commit f30dcce into master Mar 22, 2026
8 of 9 checks passed
@oferchen
oferchen deleted the test/envguard-audit branch March 22, 2026 09:00
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant