mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-01 06:24:41 +01:00
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>
This commit is contained in:
1 parent
ebd0f6a928
commit
d7a2c7d64a
1 file changed
+8
-3
@@ -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<string, string>) => ({ repoRoot: repo.work, config: DEFAULT_CONFIG, env }) as unknown as PregateContext;
|
||||
|
||||
|
||||
Reference in new issue
Block a user