From d7a2c7d64a54e8ded51554d54e1ce941f9ae90bc Mon Sep 17 00:00:00 2001 From: garrytan Date: Sat, 24 Oct 2026 20:17:28 +0000 Subject: [PATCH] test(pregate): the nested-package pnpm shim wins PATH beside a real pnpm 'a touched file in a nested pnpm+vitest package runs vitest there' ran the host's real pnpm wherever Bun and pnpm share a directory (/usr/local/bin on Capy's image): the lane puts Bun's directory first, so pnpm installed vitest from the network, dirtied the fixture tree and the check came back incomplete. Put the shim first again in the lane's bash through BASH_ENV, as the Rust fixture does. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- test/pregate-selection.test.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/pregate-selection.test.ts b/test/pregate-selection.test.ts index 3c29de015..3e4feffe5 100644 --- a/test/pregate-selection.test.ts +++ b/test/pregate-selection.test.ts @@ -524,12 +524,17 @@ describe('nested JS packages run their own runner from their own directory', () 'app/src/sum.ts': 'export const sum = (a: number, b: number) => a + b;\n', 'app/src/sum.test.ts': "import { expect, test } from 'vitest';\nimport { sum } from './sum';\ntest('sum', () => expect(sum(1, 2)).toBe(3));\n", }; - /** A `pnpm` (and `yarn`) on PATH that reports its cwd and argv and prints a vitest summary for the files it is given. */ - const pmShim = (repo: FixtureRepo): { PATH: string } => { + /** + * A `pnpm` (and `yarn`) on PATH that reports its cwd and argv and prints a vitest summary for the files it is given. + * The lane puts its Bun's directory first on PATH, and that directory can hold a real pnpm (/usr/local/bin), which + * would install from the network; the lane's bash puts the shim first again through BASH_ENV. + */ + const pmShim = (repo: FixtureRepo): { PATH: string; BASH_ENV: string } => { const dir = path.join(repo.root, 'shim'); fs.mkdirSync(dir, { recursive: true }); for (const tool of ['pnpm', 'yarn']) fs.writeFileSync(path.join(dir, tool), '#!/usr/bin/env bash\necho "ran in $(basename "$PWD"): $*"\necho " Test Files 1 passed (1)"\necho " Tests 3 passed (3)"\n', { mode: 0o755 }); - return { PATH: `${dir}:${process.env.PATH ?? ''}` }; + fs.writeFileSync(path.join(dir, 'path.sh'), `PATH='${dir}':"$PATH"\n`); + return { PATH: `${dir}:${process.env.PATH ?? ''}`, BASH_ENV: path.join(dir, 'path.sh') }; }; const ctxFor = (repo: FixtureRepo, env: Record) => ({ repoRoot: repo.work, config: DEFAULT_CONFIG, env }) as unknown as PregateContext;