tests - add --sequential option and use in CI runs

This commit is contained in:
Benjamin Pasero 2022-01-11 10:48:16 +01:00
parent 2387375634
commit af5de88a44
No known key found for this signature in database
GPG key ID: E6380CC4C8219E65
4 changed files with 20 additions and 12 deletions

View file

@ -181,7 +181,7 @@ steps:
- script: |
set -e
DEBUG=*browser* yarn test-browser --build --browser chromium --browser webkit --browser firefox --tfs "Browser Unit Tests"
DEBUG=*browser* yarn test-browser --sequential --build --browser chromium --browser webkit --browser firefox --tfs "Browser Unit Tests"
displayName: Run unit tests (Browser, Chromium & Firefox & Webkit)
timeoutInMinutes: 7
condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false'))

View file

@ -177,7 +177,7 @@ steps:
- script: |
set -e
yarn test-browser --build --browser chromium --tfs "Browser Unit Tests"
DEBUG=*browser* yarn test-browser --build --browser chromium --tfs "Browser Unit Tests"
displayName: Run unit tests (Browser, Chromium)
timeoutInMinutes: 7
condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false'))

View file

@ -161,7 +161,7 @@ steps:
- powershell: |
. build/azure-pipelines/win32/exec.ps1
$ErrorActionPreference = "Stop"
exec { yarn test-browser --build --browser chromium --browser firefox --tfs "Browser Unit Tests" }
exec { yarn test-browser --sequential --build --browser chromium --browser firefox --tfs "Browser Unit Tests" }
displayName: Run unit tests (Browser, Chromium & Firefox)
timeoutInMinutes: 7
condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false'), ne(variables['VSCODE_ARCH'], 'arm64'))

View file

@ -24,6 +24,7 @@ const optimist = require('optimist')
.describe('run', 'only run tests matching <relative_file_path>').string('run')
.describe('grep', 'only run tests matching <pattern>').alias('grep', 'g').alias('grep', 'f').string('grep')
.describe('debug', 'do not run browsers headless').alias('debug', ['debug-browser']).boolean('debug')
.describe('sequential', 'only run suites for a single browser at a time').boolean('sequential')
.describe('browser', 'browsers in which tests should run').string('browser').default('browser', ['chromium', 'firefox', 'webkit'])
.describe('reporter', 'the mocha reporter').string('reporter').default('reporter', defaultReporterName)
.describe('reporter-options', 'the mocha reporter options').string('reporter-options').default('reporter-options', '')
@ -234,18 +235,25 @@ testModules.then(async modules => {
const browserTypes = Array.isArray(argv.browser)
? argv.browser : [argv.browser];
const promises = browserTypes.map(async browserType => {
try {
return await runTestsInBrowser(modules, browserType);
} catch (err) {
console.error(err);
process.exit(1);
let messages = [];
let didFail = false;
try {
if (argv.sequential) {
for (const browserType of browserTypes) {
messages.push(await runTestsInBrowser(modules, browserType));
}
} else {
messages = await Promise.all(browserTypes.map(async browserType => {
return await runTestsInBrowser(modules, browserType);
}));
}
});
} catch (err) {
console.error(err);
process.exit(1);
}
// aftermath
let didFail = false;
const messages = await Promise.all(promises);
for (let msg of messages) {
if (msg) {
didFail = true;