diff --git a/packages/vscode/e2e/lint/runTest.ts b/packages/vscode/e2e/lint/runTest.ts index 70583bf..9bc3cd8 100644 --- a/packages/vscode/e2e/lint/runTest.ts +++ b/packages/vscode/e2e/lint/runTest.ts @@ -32,6 +32,7 @@ import os from 'node:os'; import path from 'node:path'; import { downloadAndUnzipVSCode, runTests } from '@vscode/test-electron'; +import { writeRepoPackageManager } from '../pnpmInstall'; import { vscodeTestCachePath } from '../vscodeTestCache'; interface TestSuite { @@ -135,6 +136,8 @@ async function runIsolatedSuite( path.join(profileRoot, 'node_modules'), process.platform === 'win32' ? 'junction' : 'dir', ); + } else { + writeRepoPackageManager(profileRoot, extensionDevelopmentPath); } await runTests({ diff --git a/packages/vscode/e2e/pnpmInstall.ts b/packages/vscode/e2e/pnpmInstall.ts index 23757a6..7535dfa 100644 --- a/packages/vscode/e2e/pnpmInstall.ts +++ b/packages/vscode/e2e/pnpmInstall.ts @@ -1,8 +1,32 @@ import { execFile as execFileCallback } from 'node:child_process'; +import fs from 'node:fs'; +import path from 'node:path'; import { promisify } from 'node:util'; const execFile = promisify(execFileCallback); +/** + * Writes the repo's `packageManager` pin into a tmpdir sandbox parent so + * Corepack reuses the cached pnpm instead of fetching `pnpm/latest` from npm. + */ +export function writeRepoPackageManager( + sandboxRoot: string, + extensionDevelopmentPath: string, +): void { + const { packageManager } = JSON.parse( + fs.readFileSync( + path.resolve(extensionDevelopmentPath, '../../package.json'), + 'utf8', + ), + ) as { packageManager?: string }; + if (packageManager) { + fs.writeFileSync( + path.join(sandboxRoot, 'package.json'), + `${JSON.stringify({ packageManager })}\n`, + ); + } +} + /** * Runs `pnpm install --frozen-lockfile --ignore-scripts` in `cwd`. pnpm 11 * prints install errors (e.g. ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION) to diff --git a/packages/vscode/e2e/rstest/runTest.ts b/packages/vscode/e2e/rstest/runTest.ts index d8c7f9a..b717511 100644 --- a/packages/vscode/e2e/rstest/runTest.ts +++ b/packages/vscode/e2e/rstest/runTest.ts @@ -28,6 +28,7 @@ import { import { tmpdir } from 'node:os'; import path from 'node:path'; import { runTests } from '@vscode/test-electron'; +import { writeRepoPackageManager } from '../pnpmInstall'; import { vscodeTestCachePath } from '../vscodeTestCache'; // Repo-relative fixture dirs whose installs this slice needs. workspace-2 has @@ -134,6 +135,7 @@ async function main() { recursive: true, filter: (source) => path.basename(source) !== 'node_modules', }); + writeRepoPackageManager(recoveryRoot, extensionDevelopmentPath); await runTests({ ...launchOptions, extensionTestsPath: path.resolve(