[CI > Test] Retry on no output
This commit is contained in:
parent
6f0b17cb6d
commit
ce45959a64
|
@ -1,14 +1,17 @@
|
||||||
const { execFile } = require('child_process');
|
const { execFile } = require('child_process');
|
||||||
|
|
||||||
const test = () => {
|
const test = () => {
|
||||||
|
console.log('running...');
|
||||||
const proc = execFile('xvfb-run', [process.argv[2], '--enable-logging']);
|
const proc = execFile('xvfb-run', [process.argv[2], '--enable-logging']);
|
||||||
|
|
||||||
let success = false;
|
let success = false;
|
||||||
|
let anyOutput = false;
|
||||||
proc.stderr.on('data', (data) => {
|
proc.stderr.on('data', (data) => {
|
||||||
console.error('stderr', data.toString());
|
console.error('stderr', data.toString());
|
||||||
});
|
});
|
||||||
|
|
||||||
proc.stdout.on('data', (data) => {
|
proc.stdout.on('data', (data) => {
|
||||||
|
anyOutput = true;
|
||||||
console.log('stdout', data.toString());
|
console.log('stdout', data.toString());
|
||||||
if (data.toString().includes('Installing discord_rpc')) {
|
if (data.toString().includes('Installing discord_rpc')) {
|
||||||
success = true;
|
success = true;
|
||||||
|
@ -17,8 +20,15 @@ const test = () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
proc.on('close', async () => {
|
proc.on('close', async () => {
|
||||||
|
if (!anyOutput) return;
|
||||||
process.exit(success ? 0 : 1);
|
process.exit(success ? 0 : 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
if (anyOutput) return;
|
||||||
|
console.log('detected no output in 5s, retrying...');
|
||||||
|
proc.kill();
|
||||||
|
}, 5000);
|
||||||
};
|
};
|
||||||
|
|
||||||
test();
|
while (true) test();
|
Loading…
Reference in New Issue