From 4748a5a245cbe87897297b629555ca8f83b9f377 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Tue, 3 Mar 2026 00:28:04 +0100 Subject: [PATCH 1/5] chore(tests): prefer `--install-directory` over `PATH` manipulation --- tests/Disable.test.ts | 3 +-- tests/Enable.test.ts | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/Disable.test.ts b/tests/Disable.test.ts index fcea6a685..bde91bf17 100644 --- a/tests/Disable.test.ts +++ b/tests/Disable.test.ts @@ -80,8 +80,7 @@ describe(`DisableCommand`, () => { const dontRemoveBin = await makeBin(cwd, `dont-remove` as Filename); binNames.add(ppath.basename(dontRemoveBin)); - process.env.PATH = `${npath.fromPortablePath(cwd)}${delimiter}${process.env.PATH}`; - await expect(runCli(cwd, [`disable`, `yarn`])).resolves.toMatchObject({ + await expect(runCli(cwd, [`disable`, `--install-directory=${npath.fromPortablePath(cwd)}`, `yarn`])).resolves.toMatchObject({ exitCode: 0, }); diff --git a/tests/Enable.test.ts b/tests/Enable.test.ts index 8d559c6b9..c85f91f45 100644 --- a/tests/Enable.test.ts +++ b/tests/Enable.test.ts @@ -70,8 +70,7 @@ describe(`EnableCommand`, () => { await xfs.mktempPromise(async cwd => { const corepackBin = await makeBin(cwd, `corepack` as Filename); - process.env.PATH = `${npath.fromPortablePath(cwd)}${delimiter}${process.env.PATH}`; - await expect(runCli(cwd, [`enable`, `yarn`])).resolves.toMatchObject({ + await expect(runCli(cwd, [`enable`, `--install-directory=${npath.fromPortablePath(cwd)}`, `yarn`])).resolves.toMatchObject({ stdout: ``, stderr: ``, exitCode: 0, From 53e9c1d0de7f55c8dc6524c271b76d0c2f5b219f Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Tue, 3 Mar 2026 01:17:10 +0100 Subject: [PATCH 2/5] fixup! chore(tests): prefer `--install-directory` over `PATH` manipulation --- tests/Disable.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Disable.test.ts b/tests/Disable.test.ts index bde91bf17..4a7fe0f41 100644 --- a/tests/Disable.test.ts +++ b/tests/Disable.test.ts @@ -107,7 +107,7 @@ describe(`DisableCommand`, () => { ppath.join(cwd, `yarn`), ); - await expect(runCli(cwd, [`disable`])).resolves.toMatchObject({ + await expect(runCli(cwd, [`disable`, `--install-directory=${npath.fromPortablePath(cwd)}`])).resolves.toMatchObject({ exitCode: 0, }); From 5727f46e9d106a067d215116cecb2bf2e76b987d Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Tue, 3 Mar 2026 01:32:15 +0100 Subject: [PATCH 3/5] fixup! chore(tests): prefer `--install-directory` over `PATH` manipulation --- tests/Disable.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/Disable.test.ts b/tests/Disable.test.ts index 4a7fe0f41..3c497e736 100644 --- a/tests/Disable.test.ts +++ b/tests/Disable.test.ts @@ -102,12 +102,14 @@ describe(`DisableCommand`, () => { await xfs.mkdirPromise(ppath.join(cwd, `switch/bin`), {recursive: true}); await xfs.writeFilePromise(ppath.join(cwd, `switch/bin/yarn`), `hello`); - await xfs.linkPromise( + await xfs.symlinkPromise( ppath.join(cwd, `switch/bin/yarn`), ppath.join(cwd, `yarn`), ); await expect(runCli(cwd, [`disable`, `--install-directory=${npath.fromPortablePath(cwd)}`])).resolves.toMatchObject({ + stdout: ``, + stderr: expect.stringMatching(/^yarn is already installed in .+ and points to a Yarn Switch install - skipping\n$/), exitCode: 0, }); From df2c13e79761849af6a02990922244f840e9ca0e Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 15 May 2026 17:45:58 +0200 Subject: [PATCH 4/5] squash! fix test on Windows --- tests/Disable.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/Disable.test.ts b/tests/Disable.test.ts index 3c497e736..7f68f09a5 100644 --- a/tests/Disable.test.ts +++ b/tests/Disable.test.ts @@ -82,6 +82,8 @@ describe(`DisableCommand`, () => { await expect(runCli(cwd, [`disable`, `--install-directory=${npath.fromPortablePath(cwd)}`, `yarn`])).resolves.toMatchObject({ exitCode: 0, + stdout: ``, + stderr: ``, }); for (const variant of getBinaryNames(`yarn`)) @@ -109,7 +111,7 @@ describe(`DisableCommand`, () => { await expect(runCli(cwd, [`disable`, `--install-directory=${npath.fromPortablePath(cwd)}`])).resolves.toMatchObject({ stdout: ``, - stderr: expect.stringMatching(/^yarn is already installed in .+ and points to a Yarn Switch install - skipping\n$/), + stderr: process.platform === `win32` ? `` : expect.stringMatching(/^yarn is already installed in .+ and points to a Yarn Switch install - skipping\n$/), exitCode: 0, }); From fa10259b3eecaa433c03223d898c74719e1a2829 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 15 May 2026 18:20:09 +0200 Subject: [PATCH 5/5] fixup! squash! fix test on Windows --- tests/Disable.test.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/Disable.test.ts b/tests/Disable.test.ts index 7f68f09a5..d7b8648af 100644 --- a/tests/Disable.test.ts +++ b/tests/Disable.test.ts @@ -109,14 +109,18 @@ describe(`DisableCommand`, () => { ppath.join(cwd, `yarn`), ); + const isWindows = process.platform === `win32`; // Yarn Switch support is Posix-only await expect(runCli(cwd, [`disable`, `--install-directory=${npath.fromPortablePath(cwd)}`])).resolves.toMatchObject({ stdout: ``, - stderr: process.platform === `win32` ? `` : expect.stringMatching(/^yarn is already installed in .+ and points to a Yarn Switch install - skipping\n$/), + stderr: isWindows ? `` : expect.stringMatching(/^yarn is already installed in .+ and points to a Yarn Switch install - skipping\n$/), exitCode: 0, }); - const file = await xfs.readFilePromise(ppath.join(cwd, `yarn`), `utf8`); - expect(file).toBe(`hello`); + if (isWindows) { + expect(xfs.existsSync(ppath.join(cwd, `yarn`))).toBe(false); + } else { + await expect(xfs.readFilePromise(ppath.join(cwd, `yarn`), `utf8`)).resolves.toBe(`hello`); + } }); }); });