test: support running tests against Electron releases (#36944)
Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
parent
b69236d177
commit
9630e26e6d
3 changed files with 269 additions and 5 deletions
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const { ElectronVersions, Installer } = require('@electron/fiddle-core');
|
||||
const childProcess = require('child_process');
|
||||
const crypto = require('crypto');
|
||||
const fs = require('fs-extra');
|
||||
|
@ -12,7 +13,7 @@ const pass = '✓'.green;
|
|||
const fail = '✗'.red;
|
||||
|
||||
const args = require('minimist')(process.argv, {
|
||||
string: ['runners', 'target'],
|
||||
string: ['runners', 'target', 'electronVersion'],
|
||||
boolean: ['buildNativeTests'],
|
||||
unknown: arg => unknownFlags.push(arg)
|
||||
});
|
||||
|
@ -39,6 +40,15 @@ const runners = new Map([
|
|||
|
||||
const specHashPath = path.resolve(__dirname, '../spec/.hash');
|
||||
|
||||
if (args.electronVersion) {
|
||||
if (args.runners && args.runners !== 'main') {
|
||||
console.log(`${fail} only 'main' runner can be used with --electronVersion`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
args.runners = 'main';
|
||||
}
|
||||
|
||||
let runnersToRun = null;
|
||||
if (args.runners !== undefined) {
|
||||
runnersToRun = args.runners.split(',').filter(value => value);
|
||||
|
@ -52,6 +62,14 @@ if (args.runners !== undefined) {
|
|||
}
|
||||
|
||||
async function main () {
|
||||
if (args.electronVersion) {
|
||||
const versions = await ElectronVersions.create();
|
||||
if (!versions.isVersion(args.electronVersion)) {
|
||||
console.log(`${fail} '${args.electronVersion}' is not a recognized Electron version`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
const [lastSpecHash, lastSpecInstallHash] = loadLastSpecHash();
|
||||
const [currentSpecHash, currentSpecInstallHash] = await getSpecHash();
|
||||
const somethingChanged = (currentSpecHash !== lastSpecHash) ||
|
||||
|
@ -122,7 +140,13 @@ async function runElectronTests () {
|
|||
}
|
||||
|
||||
async function runTestUsingElectron (specDir, testName) {
|
||||
let exe = path.resolve(BASE, utils.getElectronExec());
|
||||
let exe;
|
||||
if (args.electronVersion) {
|
||||
const installer = new Installer();
|
||||
exe = await installer.install(args.electronVersion);
|
||||
} else {
|
||||
exe = path.resolve(BASE, utils.getElectronExec());
|
||||
}
|
||||
const runnerArgs = [`electron/${specDir}`, ...unknownArgs.slice(2)];
|
||||
if (process.platform === 'linux') {
|
||||
runnerArgs.unshift(path.resolve(__dirname, 'dbus_mock.py'), exe);
|
||||
|
@ -212,14 +236,20 @@ async function installSpecModules (dir) {
|
|||
// but don't clobber any other CXXFLAGS that were passed into spec-runner.js
|
||||
const CXXFLAGS = ['-std=c++17', process.env.CXXFLAGS].filter(x => !!x).join(' ');
|
||||
|
||||
const nodeDir = path.resolve(BASE, `out/${utils.getOutDir({ shouldLog: true })}/gen/node_headers`);
|
||||
const env = {
|
||||
...process.env,
|
||||
CXXFLAGS,
|
||||
npm_config_nodedir: nodeDir,
|
||||
npm_config_msvs_version: '2019',
|
||||
npm_config_yes: 'true'
|
||||
};
|
||||
if (args.electronVersion) {
|
||||
env.npm_config_target = args.electronVersion;
|
||||
env.npm_config_disturl = 'https://electronjs.org/headers';
|
||||
env.npm_config_runtime = 'electron';
|
||||
env.npm_config_build_from_source = 'true';
|
||||
} else {
|
||||
env.npm_config_nodedir = path.resolve(BASE, `out/${utils.getOutDir({ shouldLog: true })}/gen/node_headers`);
|
||||
}
|
||||
if (fs.existsSync(path.resolve(dir, 'node_modules'))) {
|
||||
await fs.remove(path.resolve(dir, 'node_modules'));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue