test(startup): pin the platform in the probe-env test

shellProbeEnv short-circuits on win32, so the POSIX-only assertion failed
for anyone running the suite on Windows. Matches the convention in
hydrate-shell-path.windows.test.ts.

Also narrows the win32 exemption comment: WindowsShellPathOwnership
snapshots its baseline after the seeds land, so it does not unwind them.
The exemption holds because Windows keys PATH as `Path` and no Windows
seed pins a node version.
This commit is contained in:
Neil
2026-08-24 18:38:15 -07:00
parent 8703969ca9
commit ac4690b248
2 changed files with 6 additions and 2 deletions
@@ -40,6 +40,7 @@ describe('hydrateShellPath', () => {
})
afterEach(() => {
vi.restoreAllMocks()
if (originalPath === undefined) {
delete process.env.PATH
} else {
@@ -180,6 +181,9 @@ describe('hydrateShellPath', () => {
})
it('probes with the recorded launch PATH so seeded fallbacks cannot pin nvm', async () => {
// Why: shellProbeEnv short-circuits on win32, so pin the platform or this
// POSIX-only assertion fails for anyone running the suite on Windows.
vi.spyOn(process, 'platform', 'get').mockReturnValue('darwin')
const proc = createMockShellProcess()
spawnMock.mockReturnValue(proc)
process.env.PATH = `/home/u/.nvm/versions/node/v26.7.0/bin${delimiter}/usr/bin`
+2 -2
View File
@@ -36,8 +36,8 @@ let probeQueue = Promise.resolve()
// ahead of PATH before we probe. nvm's startup `use` honors whatever node is
// already on PATH over the user's `default` alias, so a probe that inherits the
// seed comes back pinned to that version and every terminal loses the global
// CLIs installed under `default`. Probe with the launch PATH; Windows gets the
// same protection from WindowsShellPathOwnership.
// CLIs installed under `default`. Probe with the launch PATH instead. win32 is
// exempt: it keys PATH as `Path`, and no Windows seed pins a node version.
let launchPath: string | null = null
let configuredWindowsShell = 'powershell.exe'
let configuredWindowsGitBashPath: string | null = null