test: move module tests to main process (#20419)

This commit is contained in:
Jeremy Apthorp 2019-10-09 16:33:15 -07:00 committed by GitHub
parent df1d3156a0
commit 8de925c4c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 58 additions and 76 deletions

View file

@ -60,7 +60,8 @@ async function main () {
(lastSpecInstallHash !== currentSpecInstallHash)
if (somethingChanged) {
await installSpecModules()
await installSpecModules(path.resolve(__dirname, '..', 'spec'))
await installSpecModules(path.resolve(__dirname, '..', 'spec-main'))
await getSpecHash().then(saveSpecHash)
}
@ -214,7 +215,7 @@ async function runMainProcessElectronTests () {
console.log(`${pass} Electron main process tests passed.`)
}
async function installSpecModules () {
async function installSpecModules (dir) {
const nodeDir = path.resolve(BASE, `out/${utils.getOutDir(true)}/gen/node_headers`)
const env = Object.assign({}, process.env, {
npm_config_nodedir: nodeDir,
@ -222,11 +223,11 @@ async function installSpecModules () {
})
const { status } = childProcess.spawnSync(NPX_CMD, [`yarn@${YARN_VERSION}`, 'install', '--frozen-lockfile'], {
env,
cwd: path.resolve(__dirname, '../spec'),
cwd: dir,
stdio: 'inherit'
})
if (status !== 0 && !process.env.IGNORE_YARN_INSTALL_ERROR) {
console.log(`${fail} Failed to yarn install in the spec folder`)
console.log(`${fail} Failed to yarn install in '${dir}'`)
process.exit(1)
}
}
@ -236,7 +237,9 @@ function getSpecHash () {
(async () => {
const hasher = crypto.createHash('SHA256')
hasher.update(fs.readFileSync(path.resolve(__dirname, '../spec/package.json')))
hasher.update(fs.readFileSync(path.resolve(__dirname, '../spec-main/package.json')))
hasher.update(fs.readFileSync(path.resolve(__dirname, '../spec/yarn.lock')))
hasher.update(fs.readFileSync(path.resolve(__dirname, '../spec-main/yarn.lock')))
return hasher.digest('hex')
})(),
(async () => {