From a7ac4a2147c10e48f2a162034e1bf3f4f762d0ce Mon Sep 17 00:00:00 2001 From: Rafael Oleza Date: Fri, 12 Apr 2019 12:52:55 +0200 Subject: [PATCH 1/2] Change the way exitCodes are passed from the test steps --- script/test | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/script/test b/script/test index 263858139..e55db3e1e 100755 --- a/script/test +++ b/script/test @@ -87,7 +87,7 @@ function runCoreMainProcessTests (callback) { console.log('Executing core main process tests'.bold.green) const cp = childProcess.spawn(executablePath, testArguments, {stdio: 'inherit', env: testEnv}) cp.on('error', error => { callback(error) }) - cp.on('close', exitCode => { callback(null, exitCode) }) + cp.on('close', exitCode => { callback(null, {exitCode}) }) } function runCoreRenderProcessTests (callback) { @@ -101,7 +101,7 @@ function runCoreRenderProcessTests (callback) { console.log('Executing core render process tests'.bold.green) const cp = childProcess.spawn(executablePath, testArguments, {stdio: 'inherit', env: testEnv}) cp.on('error', error => { callback(error) }) - cp.on('close', exitCode => { callback(null, exitCode) }) + cp.on('close', exitCode => { callback(null, {exitCode}) }) } // Build an array of functions, each running tests for a different bundled package @@ -118,7 +118,7 @@ for (let packageName in CONFIG.appMetadata.packageDependencies) { if (!testSubdir) { packageTestSuites.push(function (callback) { console.log(`Skipping tests for ${packageName} because no test folder was found`.bold.yellow) - callback(null, 0) + callback(null, {exitCode: 0}) }) continue } @@ -162,7 +162,7 @@ for (let packageName in CONFIG.appMetadata.packageDependencies) { console.log(stderrOutput) } finalize() - callback(null, exitCode) + callback(null, {exitCode}) }) }) } @@ -175,7 +175,7 @@ function runBenchmarkTests (callback) { console.log('Executing benchmark tests'.bold.green) const cp = childProcess.spawn(executablePath, testArguments, {stdio: 'inherit', env: testEnv}) cp.on('error', error => { callback(error) }) - cp.on('close', exitCode => { callback(null, exitCode) }) + cp.on('close', exitCode => { callback(null, {exitCode}) }) } let testSuitesToRun = requestedTestSuites() || testSuitesForPlatform(process.platform) @@ -220,12 +220,12 @@ function testSuitesForPlatform (platform) { return suites } -async.series(testSuitesToRun, function (err, exitCodes) { +async.series(testSuitesToRun, function (err, results) { if (err) { console.error(err) process.exit(1) } else { - const testsPassed = exitCodes.every(exitCode => exitCode === 0) + const testsPassed = results.every(({exitCode}) => exitCode === 0) process.exit(testsPassed ? 0 : 1) } }) From 91558332de7c8252bdf67e477f575e120bdfa1bc Mon Sep 17 00:00:00 2001 From: Rafael Oleza Date: Fri, 12 Apr 2019 12:53:20 +0200 Subject: [PATCH 2/2] Add debugging message specifying which step failed --- script/test | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/script/test b/script/test index e55db3e1e..adb8a5123 100755 --- a/script/test +++ b/script/test @@ -87,7 +87,7 @@ function runCoreMainProcessTests (callback) { console.log('Executing core main process tests'.bold.green) const cp = childProcess.spawn(executablePath, testArguments, {stdio: 'inherit', env: testEnv}) cp.on('error', error => { callback(error) }) - cp.on('close', exitCode => { callback(null, {exitCode}) }) + cp.on('close', exitCode => { callback(null, {exitCode, step: 'core-main-process'}) }) } function runCoreRenderProcessTests (callback) { @@ -101,7 +101,7 @@ function runCoreRenderProcessTests (callback) { console.log('Executing core render process tests'.bold.green) const cp = childProcess.spawn(executablePath, testArguments, {stdio: 'inherit', env: testEnv}) cp.on('error', error => { callback(error) }) - cp.on('close', exitCode => { callback(null, {exitCode}) }) + cp.on('close', exitCode => { callback(null, {exitCode, step: 'core-render-process'}) }) } // Build an array of functions, each running tests for a different bundled package @@ -118,7 +118,7 @@ for (let packageName in CONFIG.appMetadata.packageDependencies) { if (!testSubdir) { packageTestSuites.push(function (callback) { console.log(`Skipping tests for ${packageName} because no test folder was found`.bold.yellow) - callback(null, {exitCode: 0}) + callback(null, {exitCode: 0, step: `package-${packageName}`}) }) continue } @@ -162,7 +162,7 @@ for (let packageName in CONFIG.appMetadata.packageDependencies) { console.log(stderrOutput) } finalize() - callback(null, {exitCode}) + callback(null, {exitCode, step: `package-${packageName}`}) }) }) } @@ -175,7 +175,7 @@ function runBenchmarkTests (callback) { console.log('Executing benchmark tests'.bold.green) const cp = childProcess.spawn(executablePath, testArguments, {stdio: 'inherit', env: testEnv}) cp.on('error', error => { callback(error) }) - cp.on('close', exitCode => { callback(null, {exitCode}) }) + cp.on('close', exitCode => { callback(null, {exitCode, step: 'core-benchmarks'}) }) } let testSuitesToRun = requestedTestSuites() || testSuitesForPlatform(process.platform) @@ -225,7 +225,12 @@ async.series(testSuitesToRun, function (err, results) { console.error(err) process.exit(1) } else { - const testsPassed = results.every(({exitCode}) => exitCode === 0) - process.exit(testsPassed ? 0 : 1) + const failedSteps = results.filter(({exitCode}) => exitCode !== 0) + + for (const {step} of failedSteps) { + console.error(`Error! The '${step}' test step finished with a non-zero exit code`) + } + + process.exit(failedSteps.length === 0 ? 0 : 1) } })