Fix env var state leakage in tests via Drop-based EnvGuard#80
Merged
vsilent merged 2 commits intocopilot/analyze-test-coveragefrom Mar 25, 2026
Merged
Fix env var state leakage in tests via Drop-based EnvGuard#80vsilent merged 2 commits intocopilot/analyze-test-coveragefrom
vsilent merged 2 commits intocopilot/analyze-test-coveragefrom
Conversation
9 tasks
Co-authored-by: vsilent <42473+vsilent@users.noreply.github.com> Agent-Logs-Url: https://github.com/trydirect/status/sessions/8a87702e-2218-4345-a395-0c5ee430b4c9
Copilot
AI
changed the title
[WIP] Add unit tests to increase confidence and coverage
Fix env var state leakage in tests via Drop-based EnvGuard
Mar 25, 2026
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.
Tests mutating env vars (
AGENT_SCOPES,UPDATE_SERVER_URL,UPDATE_STORAGE_PATH) used unconditionalremove_varcleanup, leaking state into other tests on panic and clobbering any pre-existing env values.load_manifest_nonexistent_returns_defaultalso used a hard-coded/tmppath that could become flaky if that path existed from a prior run.Changes
src/test_utils.rs(new) — sharedEnvGuarddrop-based restore helper; saves the original value before mutation and restores it onDropregardless of panic:src/lib.rs— registerstest_utilsas#[cfg(test)] pub(crate) mod test_utilssrc/security/scopes.rs,src/commands/version_check.rs,src/commands/deploy.rs— replace all manualset_var/remove_varpairs withEnvGuard::set()/EnvGuard::remove()imported from the shared modulesrc/commands/deploy.rs—load_manifest_nonexistent_returns_defaultnow usestempfile::tempdir()instead of/tmp/status-test-nonexistent-pathfor guaranteed isolation✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.