test(completion): isolate ZshInstaller tests from a real Oh My Zsh install#1400
Open
clay-good wants to merge 2 commits into
Open
test(completion): isolate ZshInstaller tests from a real Oh My Zsh install#1400clay-good wants to merge 2 commits into
clay-good wants to merge 2 commits into
Conversation
…stall process.env.ZSH (exported by Oh My Zsh) short-circuits isOhMyZshInstalled() before the fallback check against the injected test home directory, so 17 of the 50 tests failed on any machine with Oh My Zsh installed. Clear $ZSH in beforeEach and restore it in afterEach, matching the save/restore idiom already used for OPENSPEC_NO_AUTO_CONFIG in this file and for SHELL/COMSPEC in shell-detection.test.ts. Fixes #1321 Co-Authored-By: Stanley Kao <stanleykao72@gmail.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
📝 WalkthroughWalkthroughThe Zsh installer tests now clear and restore ChangesZsh installer test isolation
Estimated code review effort: 1 (Trivial) | ~2 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Clearing $ZSH in setup left isOhMyZshInstalled()'s env-var branch with no coverage anywhere (before, it was only exercised accidentally on machines with Oh My Zsh). Assert detection succeeds from $ZSH alone, with no .oh-my-zsh directory present. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
alfred-openspec
approved these changes
Jul 20, 2026
alfred-openspec
left a comment
Collaborator
There was a problem hiding this comment.
Confirmed the host-environment failure: the base has 17 of 50 focused tests fail with ZSH set, while this exact head passes all 51 and restores the original environment after each test. Clean test-only fix.
This was referenced Jul 20, 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.
Fixes #1321.
Status: LGTM — test-only change, no runtime code touched, full suite green.
What was wrong:
test/core/completions/installers/zsh-installer.test.tsfailed 17 of 50 tests on any machine with a real Oh My Zsh install. The tests inject an isolated temp home directory, butisOhMyZshInstalled()checksprocess.env.ZSHbefore falling back to that directory (zsh-installer.ts:31-46). Oh My Zsh exports$ZSH, the test runner inherits it, and every standard-Zsh test silently ran down the Oh My Zsh code path. CI containers don't have Oh My Zsh, so CI stayed green while local contributors saw a permanently red suite that could mask real regressions in this file.How it was fixed:
$ZSHinbeforeEachand restore it inafterEach— the same save/clear/restore idiom this file already uses forOPENSPEC_NO_AUTO_CONFIGandshell-detection.test.tsuses forSHELL/COMSPEC.$ZSHand asserts detection succeeds with no.oh-my-zshdirectory present. Clearing the variable would otherwise leave that source branch with no coverage anywhere (before this PR it was only ever exercised accidentally, on the machines where the suite failed).21 lines total, all inside the test file.
Replication / proof: On macOS with Oh My Zsh (
$ZSHset):Notes: The fix approach was proposed by @stanleykao72 in #1321 (credited as co-author). No behavior change for users; nothing in
src/or the published package is touched.🤖 Generated with Claude Code
Summary by CodeRabbit
ZSHenvironment value, clearing it for each test, and restoring (or removing) it afterward.isOhMyZshInstalled()returnstruewhen theZSHenvironment variable is set, independent of an.oh-my-zshdirectory.