From 015e1348e0175766bce6cfdb1a5685fcdc700452 Mon Sep 17 00:00:00 2001 From: Alexey Kuzmin Date: Tue, 9 Jul 2019 23:56:46 +0300 Subject: [PATCH] ci: do not use the MOCHA_FILE env variable (#19171) It is not used in a expected way anyway. --- .circleci/config.yml | 14 ++++++-------- script/spec-runner.js | 26 +++++++++++++------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e44f5b9e660..886f4c304fc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -875,7 +875,7 @@ steps-tests: &steps-tests name: Run Electron tests environment: MOCHA_REPORTER: mocha-multi-reporters - MOCHA_FILE: junit/test-results.xml + ELECTRON_TEST_RESULTS_DIR: junit MOCHA_MULTI_REPORTERS: mocha-junit-reporter, tap ELECTRON_DISABLE_SECURITY_WARNINGS: 1 command: | @@ -885,15 +885,13 @@ steps-tests: &steps-tests - run: name: Check test results existence command: | - MOCHA_FILE='src/junit/test-results-remote.xml' - # Check if it exists and not empty. - if [ ! -s "$MOCHA_FILE" ]; then + cd src + + # Check if test results exist and are not empty. + if [ ! -s "junit/test-results-remote.xml" ]; then exit 1 fi - - MOCHA_FILE='src/junit/test-results-main.xml' - # Check if it exists and not empty. - if [ ! -s "$MOCHA_FILE" ]; then + if [ ! -s "junit/test-results-main.xml" ]; then exit 1 fi - store_test_results: diff --git a/script/spec-runner.js b/script/spec-runner.js index 7d1789bf4c4..6e33b532f7a 100755 --- a/script/spec-runner.js +++ b/script/spec-runner.js @@ -79,25 +79,25 @@ function saveSpecHash ([newSpecHash, newSpecInstallHash]) { async function runElectronTests () { const errors = [] - const runners = [ - ['Main process specs', 'main', runMainProcessElectronTests], - ['Remote based specs', 'remote', runRemoteBasedElectronTests] - ] + const runners = new Map([ + ['main', { description: 'Main process specs', run: runMainProcessElectronTests }], + ['remote', { description: 'Remote based specs', run: runRemoteBasedElectronTests }] + ]) - const mochaFile = process.env.MOCHA_FILE - for (const runner of runners) { - if (runnersToRun && !runnersToRun.includes(runner[1])) { - console.info('\nSkipping:', runner[0]) + const testResultsDir = process.env.ELECTRON_TEST_RESULTS_DIR + for (const [runnerId, { description, run }] of runners) { + if (runnersToRun && !runnersToRun.includes(runnerId)) { + console.info('\nSkipping:', description) continue } try { - console.info('\nRunning:', runner[0]) - if (mochaFile) { - process.env.MOCHA_FILE = mochaFile.replace('.xml', `-${runner[1]}.xml`) + console.info('\nRunning:', description) + if (testResultsDir) { + process.env.MOCHA_FILE = path.join(testResultsDir, `test-results-${runnerId}.xml`) } - await runner[2]() + await run() } catch (err) { - errors.push([runner[0], err]) + errors.push([runnerId, err]) } }