Skip to content

Commit

Permalink
infra: add parallel flag to the test-runner (#2423)
Browse files Browse the repository at this point in the history
  • Loading branch information
tzachbon authored Mar 29, 2022
1 parent 41c5f88 commit ede0449
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"watch": "npm run build -- -w",
"lint": "eslint .",
"pretest": "npm run build",
"test": "node scripts/test-runner.js",
"test": "node scripts/test-runner.js --parallel",
"test:integrations": "npm run test -- --i",
"test:core-packages": "npm run test -- --cp",
"prettify": "npx prettier . --write"
Expand Down
22 changes: 14 additions & 8 deletions scripts/test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ async function run() {
packages,
glob,
timeout: timeoutOverride,
parallel,
} = await yargs
.usage('$0 [options]')
.option('all', {
Expand Down Expand Up @@ -61,25 +62,31 @@ async function run() {
type: 'number',
describe: 'timeout for each test',
})
.option('parallel', {
type: 'boolean',
describe: 'run tests in parallel',
})
.alias('h', 'help')
.help()
.strict()
.wrap(yargs.terminalWidth())
.parse();

let {
glob: globPath,
parallel = true,
timeout = 10000,
} = createRunParameters({ all, corePackages, glob, integrations, packages });
let { glob: globPath, timeout = 10000 } = createRunParameters({
all,
corePackages,
glob,
integrations,
packages,
});

timeout = timeoutOverride !== null && timeoutOverride !== undefined ? timeoutOverride : timeout;

const childProcess = fork(
getMochaRunner(),
[
globPath,
...(parallel !== undefined ? ['--parallel'] : []),
...(parallel ? ['--parallel'] : []),
...(timeout !== undefined ? ['--timeout', String(timeout)] : []),
],
{ stdio: 'inherit' }
Expand All @@ -90,7 +97,7 @@ async function run() {

function createRunParameters({ integrations, packages, corePackages, all, glob }) {
/**
* @type {{ glob: string; timeout?: number; parallel?: boolean}}
* @type {{ glob: string; timeout?: number }}
*/
let runParameters;

Expand All @@ -107,7 +114,6 @@ function createRunParameters({ integrations, packages, corePackages, all, glob }
runParameters = {
glob: createTestFilesGlob(packagesList),
timeout: 20000,
parallel: false,
};
} else if (corePackages) {
runParameters = {
Expand Down

0 comments on commit ede0449

Please sign in to comment.