Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/vscode/e2e/lint/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -135,6 +136,8 @@ async function runIsolatedSuite(
path.join(profileRoot, 'node_modules'),
process.platform === 'win32' ? 'junction' : 'dir',
);
} else {
writeRepoPackageManager(profileRoot, extensionDevelopmentPath);
}

await runTests({
Expand Down
24 changes: 24 additions & 0 deletions packages/vscode/e2e/pnpmInstall.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions packages/vscode/e2e/rstest/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
Loading