test: prewarm Node headers cache if specifying Electron version (#38287)

This commit is contained in:
David Sanders 2023-05-15 02:10:22 -07:00 committed by GitHub
parent d1c5e623fa
commit c591ecf518
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View file

@ -5,6 +5,7 @@ const childProcess = require('child_process');
const crypto = require('crypto'); const crypto = require('crypto');
const fs = require('fs-extra'); const fs = require('fs-extra');
const { hashElement } = require('folder-hash'); const { hashElement } = require('folder-hash');
const os = require('os');
const path = require('path'); const path = require('path');
const unknownFlags = []; const unknownFlags = [];
@ -260,7 +261,18 @@ async function installSpecModules (dir) {
env.npm_config_target = args.electronVersion; env.npm_config_target = args.electronVersion;
env.npm_config_disturl = 'https://electronjs.org/headers'; env.npm_config_disturl = 'https://electronjs.org/headers';
env.npm_config_runtime = 'electron'; env.npm_config_runtime = 'electron';
env.npm_config_devdir = path.join(os.homedir(), '.electron-gyp');
env.npm_config_build_from_source = 'true'; env.npm_config_build_from_source = 'true';
const { status } = childProcess.spawnSync('npm', ['run', 'node-gyp-install', '--ensure'], {
env,
cwd: dir,
stdio: 'inherit',
shell: true
});
if (status !== 0) {
console.log(`${fail} Failed to "npm run node-gyp-install" install in '${dir}'`);
process.exit(1);
}
} else { } else {
env.npm_config_nodedir = path.resolve(BASE, `out/${utils.getOutDir({ shouldLog: true })}/gen/node_headers`); env.npm_config_nodedir = path.resolve(BASE, `out/${utils.getOutDir({ shouldLog: true })}/gen/node_headers`);
} }

View file

@ -3,6 +3,9 @@
"productName": "Electron Test Main", "productName": "Electron Test Main",
"main": "index.js", "main": "index.js",
"version": "0.1.0", "version": "0.1.0",
"scripts": {
"node-gyp-install": "node-gyp install"
},
"devDependencies": { "devDependencies": {
"@electron-ci/echo": "file:./fixtures/native-addon/echo", "@electron-ci/echo": "file:./fixtures/native-addon/echo",
"@electron-ci/uv-dlopen": "file:./fixtures/native-addon/uv-dlopen/", "@electron-ci/uv-dlopen": "file:./fixtures/native-addon/uv-dlopen/",