Repository navigation
fix(config): isolate permissions tests from real user config - #285
Merged
Merged
Conversation
The three `load_permissions` tests read `user_permissions_path()` (via `dirs::config_dir()`) and so merged the developer's real personal permissions file when the suite runs on a machine that has one, making `merged.allow`/`merged.deny` non-empty. Point `HOME`/`XDG_CONFIG_HOME` at an empty temp dir for those tests and restore on drop. - Hoist the crate's test `ENV_LOCK` to the crate root so the `permissions` module shares one lock with `lib.rs`'s env guards (rustc runs tests in parallel threads; both mutate `HOME`). - Add an `IsolatedUserConfig` guard and apply it to the three tests that depend on the user scope being absent. - Add a positive test proving a seeded user-scope file still loads and is merged under isolation, so the guard can't silently over-isolate.
mohitranka
added a commit
that referenced
this pull request
Aug 21, 2026
The three `load_permissions` tests read `user_permissions_path()` (via `dirs::config_dir()`) and so merged the developer's real personal permissions file when the suite runs on a machine that has one, making `merged.allow`/`merged.deny` non-empty. Point `HOME`/`XDG_CONFIG_HOME` at an empty temp dir for those tests and restore on drop. - Hoist the crate's test `ENV_LOCK` to the crate root so the `permissions` module shares one lock with `lib.rs`'s env guards (rustc runs tests in parallel threads; both mutate `HOME`). - Add an `IsolatedUserConfig` guard and apply it to the three tests that depend on the user scope being absent. - Add a positive test proving a seeded user-scope file still loads and is merged under isolation, so the guard can't silently over-isolate.
mohitranka
added a commit
that referenced
this pull request
Sep 11, 2026
The three `load_permissions` tests read `user_permissions_path()` (via `dirs::config_dir()`) and so merged the developer's real personal permissions file when the suite runs on a machine that has one, making `merged.allow`/`merged.deny` non-empty. Point `HOME`/`XDG_CONFIG_HOME` at an empty temp dir for those tests and restore on drop. - Hoist the crate's test `ENV_LOCK` to the crate root so the `permissions` module shares one lock with `lib.rs`'s env guards (rustc runs tests in parallel threads; both mutate `HOME`). - Add an `IsolatedUserConfig` guard and apply it to the three tests that depend on the user scope being absent. - Add a positive test proving a seeded user-scope file still loads and is merged under isolation, so the guard can't silently over-isolate.
mohitranka
added a commit
that referenced
this pull request
Sep 11, 2026
The three `load_permissions` tests read `user_permissions_path()` (via `dirs::config_dir()`) and so merged the developer's real personal permissions file when the suite runs on a machine that has one, making `merged.allow`/`merged.deny` non-empty. Point `HOME`/`XDG_CONFIG_HOME` at an empty temp dir for those tests and restore on drop. - Hoist the crate's test `ENV_LOCK` to the crate root so the `permissions` module shares one lock with `lib.rs`'s env guards (rustc runs tests in parallel threads; both mutate `HOME`). - Add an `IsolatedUserConfig` guard and apply it to the three tests that depend on the user scope being absent. - Add a positive test proving a seeded user-scope file still loads and is merged under isolation, so the guard can't silently over-isolate.
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
Three
forge-configpermissionstests (missing_files_merge_to_empty_without_diagnostics,malformed_repo_file_is_skipped_with_a_diagnostic,repo_allow_entries_are_ignored_but_deny_entries_are_honored) failed on any machine that has a real personalpermissions.toml:load_permissionsmergesuser_permissions_path()(resolved viadirs::config_dir()), somerged.allow/merged.denywere never empty.Fix
HOME/XDG_CONFIG_HOMEat an empty temp dir for those tests via a newIsolatedUserConfigguard that restores the environment on drop (including assertion failure).ENV_LOCKto the crate root so thepermissionsmodule shares one lock withlib.rs'sEnvGuard/XdgEnvGuard— both modules mutateHOMEin the same parallel test binary, so a single lock prevents a new race.user_scope_file_is_still_loaded_under_isolationproving a seeded user-scope file still loads and merges, so the guard can't silently over-isolate.Validation
cargo test --package forge-config --all-targets --locked: 59/59 pass (was 3 failures).cargo fmt --all -- --checkclean;cargo clippy --workspace --all-targets --locked -- -D warningsclean.forge-connect::anthropic::verify_falls_back_to_messages_endpoint_on_missing_models_route(macOS socket EINVAL race in itsmock_serverharness, ~3/8 with parallel ephemeral-port listeners) — reproduced onmain, unrelated to this PR.