spec: run nan tests to ensure v8 compat has not broken (#18489)

This commit is contained in:
Samuel Attard 2019-05-29 12:38:17 -07:00 committed by GitHub
parent 3d8db573d9
commit 96371b6d75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 117 additions and 5 deletions

View file

@ -1,3 +1,6 @@
// KEEP IN SYNC WITH DEPS FILE
const YARN_VERSION = '1.15.2'
const OUT_DIR = process.env.ELECTRON_OUT_DIR || 'Debug'
const { GitProcess } = require('dugite')
@ -42,5 +45,6 @@ module.exports = {
getCurrentBranch,
getElectronExec,
getAbsoluteElectronExec,
OUT_DIR
OUT_DIR,
YARN_VERSION
}

63
script/nan-spec-runner.js Normal file
View file

@ -0,0 +1,63 @@
const cp = require('child_process')
const fs = require('fs')
const path = require('path')
const BASE = path.resolve(__dirname, '../..')
const NAN_DIR = path.resolve(BASE, 'third_party', 'nan')
const NPX_CMD = process.platform === 'win32' ? 'npx.cmd' : 'npx'
const utils = require('./lib/utils')
if (!process.mainModule) {
throw new Error('Must call the nan spec runner directly')
}
async function main () {
const nodeDir = path.resolve(BASE, `out/${utils.OUT_DIR}/gen/node_headers`)
const env = Object.assign({}, process.env, {
npm_config_nodedir: nodeDir,
npm_config_msvs_version: '2017',
npm_config_arch: process.env.NPM_CONFIG_ARCH
})
const { status: buildStatus } = cp.spawnSync(NPX_CMD, ['node-gyp', 'rebuild', '--directory', 'test'], {
env,
cwd: NAN_DIR,
stdio: 'inherit'
})
if (buildStatus !== 0) {
console.error('Failed to build nan test modules')
return process.exit(buildStatus)
}
const { status: installStatus } = cp.spawnSync(NPX_CMD, [`yarn@${utils.YARN_VERSION}`, 'install'], {
env,
cwd: NAN_DIR,
stdio: 'inherit'
})
if (installStatus !== 0) {
console.error('Failed to install nan node_modules')
return process.exit(installStatus)
}
const DISABLED_TESTS = ['nannew-test.js']
const testsToRun = fs.readdirSync(path.resolve(NAN_DIR, 'test', 'js'))
.filter(test => !DISABLED_TESTS.includes(test))
.map(test => `test/js/${test}`)
const testChild = cp.spawn(utils.getAbsoluteElectronExec(), ['node_modules/.bin/tap', ...testsToRun], {
env: {
...process.env,
ELECTRON_RUN_AS_NODE: 'true'
},
cwd: NAN_DIR,
stdio: 'inherit'
})
testChild.on('exit', (testCode) => {
process.exit(testCode)
})
}
main().catch((err) => {
console.error('An unhandled error occurred in the nan spec runner', err)
process.exit(1)
})

View file

@ -26,8 +26,6 @@ const utils = require('./lib/utils')
const BASE = path.resolve(__dirname, '../..')
const NPM_CMD = process.platform === 'win32' ? 'npm.cmd' : 'npm'
const NPX_CMD = process.platform === 'win32' ? 'npx.cmd' : 'npx'
// KEEP IN SYNC WITH DEPS FILE
const YARN_VERSION = '1.15.2'
const specHashPath = path.resolve(__dirname, '../spec/.hash')
@ -146,7 +144,7 @@ async function installSpecModules () {
npm_config_nodedir: nodeDir,
npm_config_msvs_version: '2017'
})
const { status } = childProcess.spawnSync(NPX_CMD, [`yarn@${YARN_VERSION}`, 'install', '--frozen-lockfile'], {
const { status } = childProcess.spawnSync(NPX_CMD, [`yarn@${utils.YARN_VERSION}`, 'install', '--frozen-lockfile'], {
env,
cwd: path.resolve(__dirname, '../spec'),
stdio: 'inherit'