Repository navigation
test: isolate HOME per package so tests cannot write real user settings - #20
Merged
Merged
Conversation
Once init began binding tools into the local registry, any test invoking it without an isolated HOME wrote into the developer's real settings.yaml. That happened: temporary-directory paths were saved as plugin_path and tools.sops under a genuine provider entry, and because LoadSettings is on the path of every command, an older binary reading those unknown fields failed on every invocation, including the shell hook. Isolating inside a shared helper only protects tests that remember to call it. TestMain isolates HOME and XDG_CONFIG_HOME for every package that reads or writes settings, so no future test can reach the real path regardless of which helpers it uses.
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.
What happened
Once
initbegan binding tools into the local registry (#19), any test that invoked it without an isolatedHOMEwrote into the developer's realsettings.yaml. That is not hypothetical — it occurred during development of #19, in the window afterinitgained the write and beforefakeSOPSgainedHOMEisolation:The blast radius is larger than a corrupted field.
LoadSettingsis on the path of every command, so an older binary encountering the unknown fields fails on every invocation — including the prompt hook. The symptom wasdotenvsec: validate YAML fields: field plugin_path not found in type config.ProviderEntryon plaingit log, in a directory with no scope at all.Fix
Isolating inside
fakeSOPSonly protects tests that remember to call it, which is exactly the assumption that failed.TestMainisolatesHOMEandXDG_CONFIG_HOMEfor every package that reads or writes settings (cli,app,config,identity), so no future test can reach the real path regardless of which helpers it uses.Verification
Checksummed the real
settings.yaml, ran the full suite, re-checksummed — byte-identical. Without this change the same procedure mutates it.just lintclean, all packages pass.