17 lines
1.0 KiB
JavaScript
17 lines
1.0 KiB
JavaScript
// Runs every tools/*-test.js (or only the names given), one after another, and lists the ones that fail.
|
|
// A new test file is picked up automatically; `smoke` and `frontend` run first because they fail fastest.
|
|
const { spawnSync } = require('child_process');
|
|
const fs = require('fs'), path = require('path');
|
|
const FIRST = ['smoke', 'frontend'];
|
|
const all = fs.readdirSync(__dirname).filter(f => f.endsWith('-test.js')).map(f => f.slice(0, -'-test.js'.length));
|
|
const want = process.argv.slice(2);
|
|
const names = (want.length ? want : all).sort((a, b) => (FIRST.indexOf(a) + 1 || 99) - (FIRST.indexOf(b) + 1 || 99) || a.localeCompare(b));
|
|
const failed = [];
|
|
for (const n of names) {
|
|
if (!all.includes(n)) { console.error('No test named ' + n); process.exit(2); }
|
|
console.log('\n== ' + n);
|
|
if (spawnSync(process.execPath, [path.join(__dirname, n + '-test.js')], { stdio: 'inherit' }).status !== 0) failed.push(n);
|
|
}
|
|
console.log(failed.length ? '\nFAILED: ' + failed.join(', ') : '\nAll ' + names.length + ' test files passed');
|
|
process.exit(failed.length ? 1 : 0);
|