chore: allow custom node-spec-runner options (#22315)
This commit is contained in:
parent
a25d7fa440
commit
50009f6608
2 changed files with 44 additions and 5 deletions
|
@ -1193,7 +1193,7 @@ steps-test-node: &steps-test-node
|
||||||
name: Run Node Tests
|
name: Run Node Tests
|
||||||
command: |
|
command: |
|
||||||
cd src
|
cd src
|
||||||
node electron/script/node-spec-runner.js junit
|
node electron/script/node-spec-runner.js --default --jUnitDir=junit
|
||||||
- store_test_results:
|
- store_test_results:
|
||||||
path: src/junit
|
path: src/junit
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,16 @@ const cp = require('child_process')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
|
const args = require('minimist')(process.argv.slice(2), {
|
||||||
|
boolean: ['default'],
|
||||||
|
string: ['jUnitDir']
|
||||||
|
})
|
||||||
|
|
||||||
const BASE = path.resolve(__dirname, '../..')
|
const BASE = path.resolve(__dirname, '../..')
|
||||||
|
const DISABLED_TESTS = require('./node-disabled-tests.json')
|
||||||
const NODE_DIR = path.resolve(BASE, 'third_party', 'electron_node')
|
const NODE_DIR = path.resolve(BASE, 'third_party', 'electron_node')
|
||||||
const NPX_CMD = process.platform === 'win32' ? 'npx.cmd' : 'npx'
|
const NPX_CMD = process.platform === 'win32' ? 'npx.cmd' : 'npx'
|
||||||
const JUNIT_DIR = process.argv[2] ? path.resolve(process.argv[2]) : null
|
const JUNIT_DIR = args.jUnitDir ? path.resolve(args.jUnitDir) : null
|
||||||
const TAP_FILE_NAME = 'test.tap'
|
const TAP_FILE_NAME = 'test.tap'
|
||||||
|
|
||||||
const utils = require('./lib/utils')
|
const utils = require('./lib/utils')
|
||||||
|
@ -15,10 +21,43 @@ if (!process.mainModule) {
|
||||||
throw new Error('Must call the node spec runner directly')
|
throw new Error('Must call the node spec runner directly')
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main () {
|
const defaultOptions = [
|
||||||
const DISABLED_TESTS = require('./node-disabled-tests.json')
|
'tools/test.py',
|
||||||
|
'-p',
|
||||||
|
'tap',
|
||||||
|
'--logfile',
|
||||||
|
TAP_FILE_NAME,
|
||||||
|
'--mode=debug',
|
||||||
|
'default',
|
||||||
|
`--skip-tests=${DISABLED_TESTS.join(',')}`,
|
||||||
|
'--shell',
|
||||||
|
utils.getAbsoluteElectronExec(),
|
||||||
|
'-J'
|
||||||
|
]
|
||||||
|
|
||||||
const testChild = cp.spawn('python', ['tools/test.py', '--verbose', '-p', 'tap', '--logfile', TAP_FILE_NAME, '--mode=debug', 'default', `--skip-tests=${DISABLED_TESTS.join(',')}`, '--shell', utils.getAbsoluteElectronExec(), '-J'], {
|
const getCustomOptions = () => {
|
||||||
|
let customOptions = ['tools/test.py']
|
||||||
|
|
||||||
|
// Add all custom arguments.
|
||||||
|
const extra = process.argv.slice(2)
|
||||||
|
if (extra) {
|
||||||
|
customOptions = customOptions.concat(extra)
|
||||||
|
}
|
||||||
|
|
||||||
|
// We need this unilaterally or Node.js will try
|
||||||
|
// to run from out/Release/node.
|
||||||
|
customOptions = customOptions.concat([
|
||||||
|
'--shell',
|
||||||
|
utils.getAbsoluteElectronExec()
|
||||||
|
])
|
||||||
|
|
||||||
|
return customOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
async function main () {
|
||||||
|
const options = args.default ? defaultOptions : getCustomOptions()
|
||||||
|
|
||||||
|
const testChild = cp.spawn('python', options, {
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
ELECTRON_RUN_AS_NODE: 'true',
|
ELECTRON_RUN_AS_NODE: 'true',
|
||||||
|
|
Loading…
Reference in a new issue