From 47f51c8a7d73caf4fd7229634b59321e172d8b9e Mon Sep 17 00:00:00 2001 From: Alexandra Borovova Date: Fri, 13 Jan 2023 10:51:59 +0100 Subject: [PATCH] chore: forward mocha arguments through the custom runner (#9502) **What kind of change does this PR introduce?** This is a change to a custom mocha runner to forward arguments to mocha. **Summary** In order to start using puppeteer custom mocha runner, the Firefox team needs to forward some arguments to mocha through the runner to make it compatible with our log parser. **Does this PR introduce a breaking change?** no --- tools/mochaRunner/src/main.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tools/mochaRunner/src/main.ts b/tools/mochaRunner/src/main.ts index 38f0d3b6..ef62fc5b 100644 --- a/tools/mochaRunner/src/main.ts +++ b/tools/mochaRunner/src/main.ts @@ -129,14 +129,31 @@ async function main() { ? statsFilename : path.join(tmpDir, 'output.json'); console.log('Running', JSON.stringify(parameters), tmpFilename); + const reporterArgumentIndex = process.argv.indexOf('--reporter'); const args = [ '-u', path.join(__dirname, 'interface.js'), '-R', - path.join(__dirname, 'reporter.js'), + reporterArgumentIndex === -1 + ? path.join(__dirname, 'reporter.js') + : process.argv[reporterArgumentIndex + 1] || '', '-O', 'output=' + tmpFilename, ]; + const retriesArgumentIndex = process.argv.indexOf('--retries'); + const timeoutArgumentIndex = process.argv.indexOf('--timeout'); + if (retriesArgumentIndex > -1) { + args.push('--retries', process.argv[retriesArgumentIndex + 1] || ''); + } + if (timeoutArgumentIndex > -1) { + args.push('--timeout', process.argv[timeoutArgumentIndex + 1] || ''); + } + if (process.argv.indexOf('--no-parallel')) { + args.push('--no-parallel'); + } + if (process.argv.indexOf('--fullTrace')) { + args.push('--fullTrace'); + } const spawnArgs: SpawnOptions = { shell: true, cwd: process.cwd(),