[FIX] test isolation: suite no longer touches the real ~/.claude#20
Merged
Conversation
`Tool.defaultConfigDir` built paths from `homeDirectoryForCurrentUser` (getpwuid — ignores env), so it always resolved to the developer's real ~/.claude/.codex/ .gemini even when `withIsolatedHome` had redirected ORRERY_HOME. Origin-takeover code symlinks at `tool.defaultConfigDir`, so running the suite repointed the real ~/.claude projects/sessions/session-env into per-test temp dirs (data loss risk when /var/folders is purged). It also made the "active account is marked" ListCommand test flaky (it reads the real ~/.claude/metadata.json). - Add `userHomeURL()` in OrreryHome — homeDirectoryForCurrentUser, overridable via `ORRERY_USER_HOME`. Route `Tool.defaultConfigDir` (and orreryHomeURL's fallback) through it. Unset in production, so behavior is unchanged there. - `withIsolatedHome` sets `ORRERY_USER_HOME` to the temp dir. A dedicated var, NOT $HOME: setting $HOME breaks macOS Keychain resolution (login keychain is located via $HOME), which would fail the credential round-trip tests. - Add TestIsolationTests asserting defaultConfigDir stays inside the temp home. Verified: full suite green (366/366), and the real ~/.claude symlinks are byte-identical before and after a full `swift test` run (no hijack).
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
Running
swift testcorrupted the developer's real~/.claude:Tool.defaultConfigDirbuilt~/.claude/~/.codex/~/.geminifromFileManager.homeDirectoryForCurrentUser(which readsgetpwuidand ignores env overrides), so it resolved to the real home even whenwithIsolatedHomehad redirectedORRERY_HOME. Origin-takeover code symlinks attool.defaultConfigDir, so a full test run repointed the real~/.claudeprojects/sessions/session-envinto per-test temp dirs under/var/folders— silent data-loss risk when the OS purges them. The same read (ListCommandline 42) made the "active account is marked" test flaky.userHomeURL()(OrreryHome) —homeDirectoryForCurrentUser, overridable viaORRERY_USER_HOME.Tool.defaultConfigDirandorreryHomeURL()'s fallback route through it. The override is unset in production, so behavior there is unchanged.withIsolatedHomesetsORRERY_USER_HOMEto the temp dir. A dedicated var, not$HOME— setting$HOMEbreaks macOS Keychain resolution (the login keychain is located via$HOME), which fails the credential round-trip tests.TestIsolationTestsassertingdefaultConfigDirstays inside the temp home underwithIsolatedHome.Test Plan
defaultConfigDirresolves under the temp home, not real~/.claude$HOMEuntouched)ListCommandtest now deterministic~/.claudesymlinks byte-identical before/after a fullswift testrun (no hijack)Note
Independent of #19 (origin bare-launch fix). Recommend merging this first — it makes the suite safe to run on any dev machine that has orrery installed.
🤖 Generated with Claude Code