diff --git a/build/azure-pipelines/darwin/steps/product-build-darwin-test.yml b/build/azure-pipelines/darwin/steps/product-build-darwin-test.yml index 2028b862f8f..d01ee78dcd8 100644 --- a/build/azure-pipelines/darwin/steps/product-build-darwin-test.yml +++ b/build/azure-pipelines/darwin/steps/product-build-darwin-test.yml @@ -15,6 +15,8 @@ steps: - ${{ if eq(parameters.VSCODE_RUN_ELECTRON_TESTS, true) }}: - script: ./scripts/test.sh --build --tfs "Unit Tests" + env: + VSCODE_SKIP_PRELAUNCH: '1' displayName: 🧪 Run unit tests (Electron) timeoutInMinutes: 15 - script: npm run test-node -- --build @@ -64,6 +66,7 @@ steps: ./scripts/test-integration.sh --build --tfs "Integration Tests" env: VSCODE_REMOTE_SERVER_PATH: $(agent.builddirectory)/vscode-server-darwin-$(VSCODE_ARCH) + VSCODE_SKIP_PRELAUNCH: '1' displayName: 🧪 Run integration tests (Electron) timeoutInMinutes: 20 @@ -85,6 +88,7 @@ steps: ./scripts/test-remote-integration.sh env: VSCODE_REMOTE_SERVER_PATH: $(agent.builddirectory)/vscode-server-darwin-$(VSCODE_ARCH) + VSCODE_SKIP_PRELAUNCH: '1' displayName: 🧪 Run integration tests (Remote) timeoutInMinutes: 20 diff --git a/build/azure-pipelines/linux/steps/product-build-linux-test.yml b/build/azure-pipelines/linux/steps/product-build-linux-test.yml index c91f3e8ec0e..79b9a96b618 100644 --- a/build/azure-pipelines/linux/steps/product-build-linux-test.yml +++ b/build/azure-pipelines/linux/steps/product-build-linux-test.yml @@ -27,6 +27,8 @@ steps: - ${{ if eq(parameters.VSCODE_RUN_ELECTRON_TESTS, true) }}: - script: ./scripts/test.sh --build --tfs "Unit Tests" + env: + VSCODE_SKIP_PRELAUNCH: '1' displayName: 🧪 Run unit tests (Electron) timeoutInMinutes: 15 - script: npm run test-node -- --build @@ -75,6 +77,7 @@ steps: ./scripts/test-integration.sh --build --tfs "Integration Tests" env: VSCODE_REMOTE_SERVER_PATH: $(agent.builddirectory)/vscode-server-linux-$(VSCODE_ARCH) + VSCODE_SKIP_PRELAUNCH: '1' displayName: 🧪 Run integration tests (Electron) timeoutInMinutes: 20 @@ -95,6 +98,7 @@ steps: ./scripts/test-remote-integration.sh env: VSCODE_REMOTE_SERVER_PATH: $(agent.builddirectory)/vscode-server-linux-$(VSCODE_ARCH) + VSCODE_SKIP_PRELAUNCH: '1' displayName: 🧪 Run integration tests (Remote) timeoutInMinutes: 20 diff --git a/build/azure-pipelines/win32/steps/product-build-win32-test.yml b/build/azure-pipelines/win32/steps/product-build-win32-test.yml index f8b4eb57440..d8d7851a89c 100644 --- a/build/azure-pipelines/win32/steps/product-build-win32-test.yml +++ b/build/azure-pipelines/win32/steps/product-build-win32-test.yml @@ -17,6 +17,8 @@ steps: - ${{ if eq(parameters.VSCODE_RUN_ELECTRON_TESTS, true) }}: - powershell: .\scripts\test.bat --build --tfs "Unit Tests" + env: + VSCODE_SKIP_PRELAUNCH: '1' displayName: 🧪 Run unit tests (Electron) timeoutInMinutes: 15 - powershell: npm run test-node -- --build @@ -82,6 +84,8 @@ steps: $env:INTEGRATION_TEST_ELECTRON_PATH = "$AppRoot\$AppNameShort.exe" $env:VSCODE_REMOTE_SERVER_PATH = "$(agent.builddirectory)\test\vscode-server-win32-$(VSCODE_ARCH)" exec { .\scripts\test-integration.bat --build --tfs "Integration Tests" } + env: + VSCODE_SKIP_PRELAUNCH: '1' displayName: 🧪 Run integration tests (Electron) timeoutInMinutes: 20 @@ -105,6 +109,8 @@ steps: $env:INTEGRATION_TEST_ELECTRON_PATH = "$AppRoot\$AppNameShort.exe" $env:VSCODE_REMOTE_SERVER_PATH = "$(agent.builddirectory)\test\vscode-server-win32-$(VSCODE_ARCH)" exec { .\scripts\test-remote-integration.bat } + env: + VSCODE_SKIP_PRELAUNCH: '1' displayName: 🧪 Run integration tests (Remote) timeoutInMinutes: 20 diff --git a/build/lib/electron.ts b/build/lib/electron.ts index 64786cb2de7..8d4eb0f8844 100644 --- a/build/lib/electron.ts +++ b/build/lib/electron.ts @@ -229,15 +229,9 @@ function getElectron(arch: string): () => NodeJS.ReadWriteStream { } async function main(arch: string = process.arch): Promise { - const version = electronVersion; const electronPath = path.join(root, '.build', 'electron'); - const versionFile = path.join(electronPath, versionedResourcesFolder, 'version'); - const isUpToDate = fs.existsSync(versionFile) && fs.readFileSync(versionFile, 'utf8') === `${version}`; - - if (!isUpToDate) { - await util.rimraf(electronPath)(); - await util.streamToPromise(getElectron(arch)()); - } + await util.rimraf(electronPath)(); + await util.streamToPromise(getElectron(arch)()); } if (import.meta.main) { diff --git a/extensions/vscode-test-resolver/src/extension.ts b/extensions/vscode-test-resolver/src/extension.ts index 74d25c65ae0..3e6c9f0ad49 100644 --- a/extensions/vscode-test-resolver/src/extension.ts +++ b/extensions/vscode-test-resolver/src/extension.ts @@ -165,6 +165,8 @@ export function activate(context: vscode.ExtensionContext) { outputChannel.appendLine(`Launching server: "${serverCommandPath}" ${commandArgs.join(' ')}`); const shell = (process.platform === 'win32'); + // Skip prelaunch to avoid redownloading electron while it may be in use + env['VSCODE_SKIP_PRELAUNCH'] = '1'; extHostProcess = cp.spawn(serverCommandPath, commandArgs, { env, cwd: vscodePath, shell }); } else { const extensionToInstall = process.env['TESTRESOLVER_INSTALL_BUILTIN_EXTENSION']; diff --git a/scripts/node-electron.sh b/scripts/node-electron.sh index 187bfe314bb..d95c302944f 100755 --- a/scripts/node-electron.sh +++ b/scripts/node-electron.sh @@ -19,7 +19,9 @@ else fi # Get electron -npm run electron +if [[ -z "${VSCODE_SKIP_PRELAUNCH}" ]]; then + npm run electron +fi popd diff --git a/scripts/test.bat b/scripts/test.bat index 79d939a589c..4e0f89fb501 100644 --- a/scripts/test.bat +++ b/scripts/test.bat @@ -12,8 +12,10 @@ set NAMESHORT=%NAMESHORT:"=%.exe set CODE=".build\electron\%NAMESHORT%" :: Download Electron if needed -call node build\lib\electron.ts -if %errorlevel% neq 0 node .\node_modules\gulp\bin\gulp.js electron +if "%VSCODE_SKIP_PRELAUNCH%"=="" ( + call node build\lib\electron.ts + if %errorlevel% neq 0 node .\node_modules\gulp\bin\gulp.js electron +) :: Run tests set ELECTRON_ENABLE_LOGGING=1 diff --git a/scripts/test.sh b/scripts/test.sh index bc4661ecb7f..423bfec1ecf 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -25,7 +25,9 @@ VSCODECRASHDIR=$ROOT/.build/crashes test -d node_modules || npm i # Get electron -npm run electron +if [[ -z "${VSCODE_SKIP_PRELAUNCH}" ]]; then + npm run electron +fi # Unit Tests if [[ "$OSTYPE" == "darwin"* ]]; then diff --git a/src/vs/workbench/contrib/policyExport/test/node/policyExport.integrationTest.ts b/src/vs/workbench/contrib/policyExport/test/node/policyExport.integrationTest.ts index ddfa6885e01..a405426a595 100644 --- a/src/vs/workbench/contrib/policyExport/test/node/policyExport.integrationTest.ts +++ b/src/vs/workbench/contrib/policyExport/test/node/policyExport.integrationTest.ts @@ -38,8 +38,10 @@ suite('PolicyExport Integration Tests', () => { ? join(rootPath, 'scripts', 'code.bat') : join(rootPath, 'scripts', 'code.sh'); + // Skip prelaunch to avoid redownloading electron while the parent VS Code is using it await exec(`"${scriptPath}" --export-policy-data="${tempFile}"`, { - cwd: rootPath + cwd: rootPath, + env: { ...process.env, VSCODE_SKIP_PRELAUNCH: '1' } }); // Read both files