From efe21cfca87613269e6db2b83bc8109222d94fdc Mon Sep 17 00:00:00 2001 From: DeeDeeG Date: Sat, 26 Oct 2024 20:15:36 -0400 Subject: [PATCH] CI: Simplify run-tests.js and use it in editor tests workflow Hopefully avoids an odd test failure we see in CI. --- .github/workflows/editor-tests.yml | 2 +- script/run-tests.js | 48 ++---------------------------- 2 files changed, 3 insertions(+), 47 deletions(-) diff --git a/.github/workflows/editor-tests.yml b/.github/workflows/editor-tests.yml index 53af44d66d..72f584cfac 100644 --- a/.github/workflows/editor-tests.yml +++ b/.github/workflows/editor-tests.yml @@ -42,7 +42,7 @@ jobs: - name: Run Tests if: runner.os != 'Linux' - run: yarn start --test spec + run: node script/run-tests.js spec - name: Run Tests with xvfb-run (Linux) if: runner.os == 'Linux' diff --git a/script/run-tests.js b/script/run-tests.js index f6fff0c3c8..37e80317ba 100644 --- a/script/run-tests.js +++ b/script/run-tests.js @@ -1,23 +1,14 @@ const cp = require('child_process') -function runAllSpecs(files) { - runSpecs(files, []) -} - -function runSpecs(files, retries) { +function runSpecs(files) { let env = process.env env.ATOM_JASMINE_REPORTER='list' - if(retries.length > 0) { - // Escape possible tests that can generate a regexp that will not match... - const escaped = retries.map(str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')); - env.SPEC_FILTER = escaped.join("|") - } + const res = cp.spawn('yarn', ['start', '--test', ...files], { cwd: process.cwd(), env: env }) - let out; res.stdout.on('data', data => { process.stdout.write(data.toString()); }); @@ -25,48 +16,13 @@ function runSpecs(files, retries) { res.stderr.on('data', data => { const strData = data.toString(); process.stderr.write(strData); - - if(strData.match(/ALL TESTS THAT FAILED:/)) { - out = ''; - } else if(out !== undefined) { - out += strData; - } }); res.on('close', code => { - if(code !== 0 && retries.length === 0) { - const failed = filterSpecs(out) - - console.log(`********************* -Tests failed. Retrying failed tests... -********************* - -`) - runSpecs(files, failed) - } else { process.exit(code) - } }); } -function filterSpecs(output) { - if(!output) return '' - let descriptions = [] - let start = true - for(let out of output.split("\n")) { - if(start) { - if(out !== '') { - start = false - descriptions.push(out) - } - } else if(out !== '') { - descriptions.push(out) - } else { - return descriptions - } - } -} - if(process.argv[0] === __filename) { runAllSpecs(process.argv.splice(1)) } else if(process.argv[1] === __filename) {