From 4ec02a9af9f85c2dba526687ba6a33d715b8fd29 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sun, 2 May 2021 16:32:06 -0400 Subject: [PATCH] remote_runner: Simplify finished test check --- src/tests/frontend/travis/remote_runner.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/tests/frontend/travis/remote_runner.js b/src/tests/frontend/travis/remote_runner.js index 143034977..236a0aaa5 100644 --- a/src/tests/frontend/travis/remote_runner.js +++ b/src/tests/frontend/travis/remote_runner.js @@ -28,6 +28,8 @@ const log = (msg, pfx = '') => { console.log(`${pfx}${msg.replace(colorRegex, (m, p1) => colorSubst[p1])}`); }; +const finishedRegex = /FINISHED.*[0-9]+ tests passed, ([0-9]+) tests failed/; + const sauceTestWorker = async.queue((testSettings, callback) => { const name = `${testSettings.browserName} ${testSettings.version}, ${testSettings.platform}`; const pfx = `[${name}] `; @@ -80,18 +82,8 @@ const sauceTestWorker = async.queue((testSettings, callback) => { } consoleText.substring(logIndex).split('\\n').forEach((line) => log(line, pfx)); logIndex = consoleText.length; - if (consoleText.indexOf('FINISHED') > 0) { - const match = consoleText.match( - /FINISHED.*([0-9]+) tests passed, ([0-9]+) tests failed/); - // finished without failures - if (match[2] && match[2] === '0') { - stopSauce(true); - - // finished but some tests did not return or some tests failed - } else { - stopSauce(false); - } - } + const [finished, nFailedStr] = consoleText.match(finishedRegex) || []; + if (finished) stopSauce(nFailedStr === '0'); }); }, 5000); });