mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 02:54:11 +08:00
ci: run apps/automated on CI (#9196)
This commit is contained in:
36
tools/scripts/run-automated.js
Normal file
36
tools/scripts/run-automated.js
Normal 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)
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user