ci: run apps/automated on CI (#9196)

This commit is contained in:
Igor Randjelovic
2021-02-05 20:21:16 +01:00
committed by GitHub
parent abc78800f2
commit 4945702620
13 changed files with 182 additions and 97 deletions

View File

@ -0,0 +1,36 @@
/**
* Script to run the automated tests & exit after the tests are finished.
* Mainly intended to be used on CI
*
* Usage: node run-automated.js <platform>
*/
const spawn = require('child_process').spawn
const kill = require('tree-kill');
const spawned_process = spawn('npm', ['start', `apps.automated.${process.argv[2]}`], {
stdio: ['inherit', 'pipe', 'pipe']
})
const {stdout, stderr} = spawned_process
stdout.pipe(process.stdout)
stderr.pipe(process.stderr)
let lineBuffer = []
stdout.on('data', data => {
const line = data.toString();
// start buffering lines when tests are complete
if(lineBuffer.length || line.includes('=== ALL TESTS COMPLETE ===')) {
lineBuffer.push(line)
}
if(line.includes('Tests EOF!')) {
let ok = lineBuffer.join('\n').includes('OK, 0 failed')
console.log(ok ? 'Tests PASSED' : 'Tests FAILED');
kill(spawned_process.pid)
process.exit(ok ? 0 : 1)
}
})