mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-29 09:43:49 +01:00
Contributes towards #279402 Make test/sanity NPM-install independent for faster initialization in the pipeline. Fixed pipeline and tests ro fully pass on Windows x64 and MacOS x64. Updated suite/test names to report nicely in ADO. Ensure temp dir name is expanded on Windows to avoid ~ expansion from CLI. Removed custom log file now that XML report is supported. Added option to turn headless browsing on/off.
157 lines
5.1 KiB
TypeScript
157 lines
5.1 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { spawn } from 'child_process';
|
|
import { test } from 'mocha';
|
|
import os from 'os';
|
|
import { TestContext } from './context';
|
|
import { UITest } from './uiTest';
|
|
|
|
export function setup(context: TestContext) {
|
|
if (context.skipRuntimeCheck || context.platform === 'linux-arm64') {
|
|
test('server-web-alpine-arm64', async () => {
|
|
const dir = await context.downloadAndUnpack('server-alpine-arm64-web');
|
|
const entryPoint = context.getServerEntryPoint(dir);
|
|
await testServer(entryPoint);
|
|
});
|
|
}
|
|
|
|
if (context.skipRuntimeCheck || context.platform === 'linux-x64') {
|
|
test('server-web-alpine-x64', async () => {
|
|
const dir = await context.downloadAndUnpack('server-linux-alpine-web');
|
|
const entryPoint = context.getServerEntryPoint(dir);
|
|
await testServer(entryPoint);
|
|
});
|
|
}
|
|
|
|
if (context.skipRuntimeCheck || context.platform === 'darwin-arm64') {
|
|
test('server-web-darwin-arm64', async () => {
|
|
const dir = await context.downloadAndUnpack('server-darwin-arm64-web');
|
|
context.validateAllCodesignSignatures(dir);
|
|
const entryPoint = context.getServerEntryPoint(dir);
|
|
await testServer(entryPoint);
|
|
});
|
|
}
|
|
|
|
if (context.skipRuntimeCheck || context.platform === 'darwin-x64') {
|
|
test('server-web-darwin-x64', async () => {
|
|
const dir = await context.downloadAndUnpack('server-darwin-web');
|
|
context.validateAllCodesignSignatures(dir);
|
|
const entryPoint = context.getServerEntryPoint(dir);
|
|
await testServer(entryPoint);
|
|
});
|
|
}
|
|
|
|
if (context.skipRuntimeCheck || context.platform === 'linux-arm64') {
|
|
test('server-web-linux-arm64', async () => {
|
|
const dir = await context.downloadAndUnpack('server-linux-arm64-web');
|
|
const entryPoint = context.getServerEntryPoint(dir);
|
|
await testServer(entryPoint);
|
|
});
|
|
}
|
|
|
|
if (context.skipRuntimeCheck || context.platform === 'linux-arm') {
|
|
test('server-web-linux-armhf', async () => {
|
|
const dir = await context.downloadAndUnpack('server-linux-armhf-web');
|
|
const entryPoint = context.getServerEntryPoint(dir);
|
|
await testServer(entryPoint);
|
|
});
|
|
}
|
|
|
|
if (context.skipRuntimeCheck || context.platform === 'linux-x64') {
|
|
test('server-web-linux-x64', async () => {
|
|
const dir = await context.downloadAndUnpack('server-linux-x64-web');
|
|
const entryPoint = context.getServerEntryPoint(dir);
|
|
await testServer(entryPoint);
|
|
});
|
|
}
|
|
|
|
if (context.skipRuntimeCheck || context.platform === 'win32-arm64') {
|
|
test('server-web-win32-arm64', async () => {
|
|
const dir = await context.downloadAndUnpack('server-win32-arm64-web');
|
|
context.validateAllAuthenticodeSignatures(dir);
|
|
const entryPoint = context.getServerEntryPoint(dir);
|
|
await testServer(entryPoint);
|
|
});
|
|
}
|
|
|
|
if (context.skipRuntimeCheck || context.platform === 'win32-x64') {
|
|
test('server-web-win32-x64', async () => {
|
|
const dir = await context.downloadAndUnpack('server-win32-x64-web');
|
|
context.validateAllAuthenticodeSignatures(dir);
|
|
const entryPoint = context.getServerEntryPoint(dir);
|
|
await testServer(entryPoint);
|
|
});
|
|
}
|
|
|
|
async function testServer(entryPoint: string) {
|
|
if (context.skipRuntimeCheck) {
|
|
return;
|
|
}
|
|
|
|
const token = context.getRandomToken();
|
|
const test = new UITest(context);
|
|
const args = [
|
|
'--accept-server-license-terms',
|
|
'--port', context.getRandomPort(),
|
|
'--connection-token', token,
|
|
'--server-data-dir', context.createTempDir(),
|
|
'--extensions-dir', test.extensionsDir,
|
|
'--user-data-dir', test.userDataDir
|
|
];
|
|
|
|
context.log(`Starting server ${entryPoint} with args ${args.join(' ')}`);
|
|
const server = spawn(entryPoint, args, { shell: true, detached: os.platform() !== 'win32' });
|
|
|
|
let testError: Error | undefined;
|
|
|
|
server.stderr.on('data', (data) => {
|
|
context.error(`[Server Error] ${data.toString().trim()}`);
|
|
});
|
|
|
|
server.stdout.on('data', (data) => {
|
|
const text = data.toString().trim();
|
|
text.split('\n').forEach((line: string) => {
|
|
context.log(`[Server Output] ${line}`);
|
|
});
|
|
|
|
const port = /Extension host agent listening on (\d+)/.exec(text)?.[1];
|
|
if (port) {
|
|
const url = context.getWebServerUrl(port, token, test.workspaceDir).toString();
|
|
runUITest(url, test)
|
|
.catch((error) => { testError = error; })
|
|
.finally(() => context.killProcessTree(server.pid!));
|
|
}
|
|
});
|
|
|
|
await new Promise<void>((resolve, reject) => {
|
|
server.on('error', reject);
|
|
server.on('exit', resolve);
|
|
});
|
|
|
|
if (testError) {
|
|
throw testError;
|
|
}
|
|
}
|
|
|
|
async function runUITest(url: string, test: UITest) {
|
|
const browser = await context.launchBrowser();
|
|
const page = await browser.newPage();
|
|
|
|
context.log(`Navigating to ${url}`);
|
|
await page.goto(url, { waitUntil: 'networkidle' });
|
|
|
|
context.log('Waiting for the workbench to load');
|
|
await page.waitForSelector('.monaco-workbench');
|
|
|
|
await test.run(page);
|
|
|
|
context.log('Closing browser');
|
|
await browser.close();
|
|
|
|
test.validate();
|
|
}
|
|
}
|