test(versioncheck): isolate the install-probe env and tag the unix-only tests - #2309
Merged
Merged
Conversation
isolateWindowsInstallEnv cleared MISE_INSTALLS_DIR and MISE_DATA_DIR, but it
is windows-tagged, so TestUpdateCommandForCurrentBinary_Unix kept reading the
host's:
MISE_INSTALLS_DIR=/usr/local go test ./cmd/entire/cli/versioncheck/ \
-run TestUpdateCommandForCurrentBinary_Unix
--- FAIL: .../unknown_path_stable_falls_back_to_stable_curl_command
UpdateCommandForCurrentBinary() = "mise upgrade entire",
want "curl -fsSL https://entire.io/install.sh | bash"
MISE_INSTALLS_DIR is the only probe variable whose value becomes a root
verbatim: miseRoots returns it as-is, while MISE_DATA_DIR gets "installs"
appended and scoopRoots appends "apps" to all four of its inputs. That
mandatory extra segment is what stops the others prefixing an arbitrary path,
which is also why no value of SCOOP could reproduce the Windows half of the
finding this fell out of. So the exposed rows are the two asserting that NO
probe matched, and one variable reaches them.
Move the two Setenv calls into an untagged isolateMiseInstallEnv so both
platforms share one helper — the Windows one wraps it and adds Scoop's — rather
than letting the pair drift again. Nothing here affects CI, where none of these
variables are set; it is the developer-box run that lies.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 01M1XX0CE04KSHZ22BJWPJ8S9B
Three tests in the untagged versioncheck_test.go only hold where
installerAutoRuns is true, because they assert what happens *after*
maybeAutoUpdate reaches the prompt:
- BrewSkipUntilNextVersionCachesLatest and MiseSkipUntilNextVersionCachesLatest
expect chooseUpdate's answer to land in the cache as SkippedVersion
- InstallerFailureKeepsCacheFresh expects the "Try again later running:" hint
On Windows maybeAutoUpdate returns autoUpdateActionSkip before any of that, so
lastCmdStr stays empty, SkippedVersion is never written, and the hint never
prints. All three fail on a Windows host. Confirmed by building the package
with installerAutoRuns flipped to false.
CI cannot see it: the test-windows job selects by name (-run '(Windows|MSYS)'),
and none of these match. Until now the escape hatch was the goos variable seam
and its pinNonWindowsGOOS helper, which the per-OS split removed — correctly,
but these three were the callers it left behind, so a build tag is now the only
way to express what they need.
Move them to versioncheck_unix_test.go, alongside the existing unix-only
CheckAndNotify coverage, and take brewUpgradeCmd with them since brew is a
unix-only probe here. brewCaskPath stays untagged: SkipsVersionMarkedSkipped
still uses it and is genuinely platform-agnostic, since CheckAndNotify returns
on the skipped version before any installer is consulted.
Verified with go list that the Windows test build now contains only
autoupdate_windows_test.go, fixture_test.go, versioncheck_test.go and
versioncheck_windows_test.go, and that GOOS=windows go vet is clean.
The gap this leaves is worth naming: nothing asserts the Windows side of the
same contract — that CheckAndNotify does NOT cache a skip there, which is the
deliberate "the nudge returns every 24h" behaviour maybeAutoUpdate documents.
That wants a windows-tagged test, not a moved one, so it is out of scope here.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 01M1XX536ZZQX16VHF8AM0NA2Q
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Changes are test-only, scoped, and align build tags/env isolation with the intended platform-specific behaviors.
Pull request overview
This PR improves versioncheck test hygiene by (1) isolating mise-related environment variables across platforms so host mise roots don’t affect update-command detection tests, and (2) correctly scoping unix-only auto-update tests behind the unix build tag to avoid Windows-only behavior differences.
Changes:
- Adds a shared
isolateMiseInstallEnvtest helper to clearMISE_INSTALLS_DIR/MISE_DATA_DIR, and uses it from both unix and Windows tests. - Updates the unix
UpdateCommandForCurrentBinarytable test to callisolateMiseInstallEnvper subtest, preventing host environment leakage. - Moves three
CheckAndNotifytests that rely on unix auto-update behavior intoversioncheck_unix_test.go(//go:build unix) and removes them from the untagged test file.
File summaries
| File | Description |
|---|---|
| cmd/entire/cli/versioncheck/versioncheck_windows_test.go | Reuses shared mise env isolation from Windows-specific install env helper. |
| cmd/entire/cli/versioncheck/versioncheck_unix_test.go | Adds per-subtest mise env isolation and relocates unix-only CheckAndNotify test coverage under the unix build tag. |
| cmd/entire/cli/versioncheck/versioncheck_test.go | Removes unix-only tests/constants from the untagged cross-platform test file. |
| cmd/entire/cli/versioncheck/fixture_test.go | Introduces shared isolateMiseInstallEnv helper for cross-platform test env isolation. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
gtrrz-victor
approved these changes
Sep 7, 2026
MuskanPaliwal
pushed a commit
to MuskanPaliwal/cli
that referenced
this pull request
Sep 7, 2026
A finding on entireio#2309 claimed the three CheckAndNotify tests moved there fail when a developer has MISE_INSTALLS_DIR set wide enough to cover brewCaskPath (it suggested /opt). The premise is right and the conclusion is not: both probes match, but UpdateCommandForCurrentBinary returns the FIRST match and installProbes orders brewProbe ahead of miseProbe, so brew wins. miseProbe.matches("/opt/homebrew/Caskroom/entire/1.0.0/entire") = true brewProbe.matches("/opt/homebrew/Caskroom/entire/1.0.0/entire") = true UpdateCommandForCurrentBinary() = "brew upgrade --yes entire" Confirmed against every MISE_INSTALLS_DIR worth trying, /opt and / included, plus MISE_DATA_DIR. The comparison to 73a3d39 does not hold either: that fixed the two table rows whose expectation is the *fallback*, where by definition no probe matched, so precedence could not rescue them. Here it does. What the finding did surface is that precedence is load-bearing and unpinned. It is a product invariant, not just test scaffolding: someone can have entire installed by brew and mise relocated under a broad root, and that user has to be told to run brew. Reordering installProbes would silently change the advice, and would break those tests only on the developer boxes that set the variable. So pin it, asserting the precondition as well as the outcome — without a contending probe the test would keep passing while testing nothing. Verified by mutation: flipping installProbes fails on the outcome, and stopping mise matching fails on the precondition. Also fold isolateMiseInstallEnv into newAutoUpdateFixture, which is already where a test's environment is made hermetic (HOME, kill switch, TTY), and into the one test that wires the same seams inline instead of using the fixture. That is decoupling rather than a fix — nothing was failing — so that the tests no longer depend on precedence at all, and the invariant is asserted in one place that says why. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 01M1Y02AWEH7JCQ00J806YVMNC
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.
https://entire.io/gh/entireio/cli/trails/1257
Two test-hygiene items found reviewing #2217, which merged while this was being written — so this targets
mainrather than stacking. Test-only: no production code changes.1. The unix table test read the host's mise roots
isolateWindowsInstallEnvclearsMISE_INSTALLS_DIRandMISE_DATA_DIR, but it lives inversioncheck_windows_test.go, so the unix table test never got the fix:MISE_INSTALLS_DIRis the only probe variable whose value becomes a root verbatim —miseRootsreturns it as-is, whileMISE_DATA_DIRgetsinstallsappended andscoopRootsappendsappsto all four of its inputs. That mandatory extra segment is what stops the others prefixing an arbitrary path, and it is also why no value ofSCOOPcould reproduce the Windows half of the finding this fell out of:SCOOP=C:\toolsyields the rootc:/tools/apps/, which does not prefixc:/tools/cli/entire.exe.So the exposed rows are exactly the two whose expectation is the fallback — the ones asserting that no probe matched — and one variable reaches them. The brew rows are immune by probe order, and the
executable errorrow returns before the probe loop.Fix: the two
Setenvcalls move into an untaggedisolateMiseInstallEnvthat both platforms share, withisolateWindowsInstallEnvwrapping it and adding Scoop's, so the pair cannot drift again.MISE_INSTALLS_DIR=/usr/localMISE_DATA_DIR=/usrinstalls/segment)MISE_INSTALLS_DIR=usr/localnormalizeInstallRootrejects relative)CI is unaffected either way — no runner sets these. It is the developer-box run that lies, with a message pointing at the code under test and no hint that the environment caused it.
2. Three
CheckAndNotifytests were untagged but unix-onlyTestCheckAndNotify_BrewSkipUntilNextVersionCachesLatest,..._MiseSkipUntilNextVersionCachesLatestand..._InstallerFailureKeepsCacheFreshall assert what happens aftermaybeAutoUpdatereaches the prompt — thatchooseUpdate's answer lands in the cache asSkippedVersion, or that theTry again later running:hint prints. On WindowsmaybeAutoUpdatereturnsautoUpdateActionSkipbefore any of that, so all three fail on a Windows host. Confirmed by building the package withinstallerAutoRunsflipped tofalse.CI cannot see it:
test-windowsselects by name (-run '(Windows|MSYS)') and none of these match. The previous escape hatch was thegoosvariable seam and itspinNonWindowsGOOShelper, which #2217 removed — correctly — leaving these three as the callers it did not follow up. A build tag is now the only way to express what they need.They move to
versioncheck_unix_test.goalongside the existing unix-onlyCheckAndNotifycoverage, andbrewUpgradeCmdgoes with them since brew is a unix-only probe here.brewCaskPathstays untagged:TestCheckAndNotify_SkipsVersionMarkedSkippedstill uses it and is genuinely platform-agnostic, becauseCheckAndNotifyreturns on the skipped version before any installer is consulted.Verified with
go listthat the Windows test build now contains onlyautoupdate_windows_test.go,fixture_test.go,versioncheck_test.goandversioncheck_windows_test.go.Known gap, deliberately not closed here
Nothing asserts the Windows side of the same contract — that
CheckAndNotifydoes not cache a skip there, which is the deliberate "the nudge returns every 24h until they update" behaviourmaybeAutoUpdatedocuments. That wants a new windows-tagged test rather than a moved one, so it is out of scope.Verification
mise run lint0 issues,mise run test:cifully green,GOOS=windows go vet ./...clean.🤖 Generated with Claude Code
Note
Low Risk
Only test layout and environment isolation; no runtime version-check or auto-update logic changes.
Overview
Test-only hardening for
versioncheck: no production behavior changes.Adds shared
isolateMiseInstallEnv(clearsMISE_INSTALLS_DIR/MISE_DATA_DIR) so host mise roots cannot make “unknown path → curl install” cases look likemise upgrade. The UnixUpdateCommandForCurrentBinarytable calls it in each subtest;isolateWindowsInstallEnvnow delegates to the same helper instead of duplicating thoseSetenvcalls.Moves three
CheckAndNotifytests that depend on interactive auto-update (skip-until-next-version caching and installer-failure retry hint) intoversioncheck_unix_test.gounder theunixbuild tag, because on WindowsinstallerAutoRunsis false andmaybeAutoUpdatebails out before those paths run.brewUpgradeCmdmoves with them; sharedversioncheck_test.godrops the duplicated tests and unused imports.Reviewed by Cursor Bugbot for commit dfef5ab. Configure here.