2022-02-04 13:22:48 +01:00
|
|
|
const fs = require('fs')
|
2022-11-15 10:29:13 -06:00
|
|
|
const path = require('path')
|
2022-02-04 13:22:48 +01:00
|
|
|
const spawn = require('child_process').spawn
|
|
|
|
|
2022-11-15 10:29:13 -06:00
|
|
|
const projectRoot = path.normalize(path.join(__dirname, '..'))
|
|
|
|
const outputLog = path.join(projectRoot, '.test-failures.log')
|
|
|
|
const collectorScript = path.join(projectRoot, 'scripts', 'test-failure-collector.js')
|
2022-02-04 13:22:48 +01:00
|
|
|
|
|
|
|
// Start with a fresh output log on each run.
|
|
|
|
if (fs.existsSync(outputLog)) {
|
2022-11-15 10:29:13 -06:00
|
|
|
fs.unlinkSync(outputLog)
|
2022-02-04 13:22:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Run all tests, specifying the collector script.
|
2022-11-15 10:29:13 -06:00
|
|
|
spawn(
|
|
|
|
'lerna',
|
|
|
|
[
|
|
|
|
'run',
|
|
|
|
'--no-bail',
|
2022-11-15 12:02:46 -06:00
|
|
|
'testci',
|
2022-11-15 10:29:13 -06:00
|
|
|
'--stream',
|
|
|
|
'--parallel',
|
2022-11-15 10:47:57 -06:00
|
|
|
'--loglevel',
|
|
|
|
'error',
|
2022-11-15 10:29:13 -06:00
|
|
|
'--',
|
|
|
|
'--file',
|
|
|
|
`${collectorScript}`,
|
2022-11-15 11:32:48 -06:00
|
|
|
'--no-warnings',
|
2022-11-15 12:10:38 -06:00
|
|
|
'--timeout=15000',
|
2022-11-15 10:29:13 -06:00
|
|
|
],
|
|
|
|
{ stdio: 'inherit' }
|
|
|
|
).on('exit', function (code) {
|
|
|
|
// If a failure occurred, the log file will have been created. Print it.
|
|
|
|
if (fs.existsSync(outputLog)) {
|
|
|
|
console.error(fs.readFileSync(outputLog, 'utf8').trim())
|
|
|
|
}
|
2022-02-04 13:22:48 +01:00
|
|
|
|
2022-11-15 10:29:13 -06:00
|
|
|
// Propagate the exit code.
|
|
|
|
process.exit(code)
|
|
|
|
})
|