From 67e6687fd75db67193acec87e926414822a51deb Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 1 Jun 2016 13:02:28 -0700 Subject: [PATCH 1/3] Add option to bail out of `jake runtests` when a test fails --- Jakefile.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index 2f0ce4aa399cd..feaae86c1c976 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -726,13 +726,14 @@ function runConsoleTests(defaultReporter, runInParallel) { colors = process.env.colors || process.env.color; colors = colors ? ' --no-colors ' : ' --colors '; reporter = process.env.reporter || process.env.r || defaultReporter; + var bail = (process.env.bail || process.env.b) ? "--bail" : ""; var lintFlag = process.env.lint !== 'false'; // timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally // default timeout is 2sec which really should be enough, but maybe we just need a small amount longer if(!runInParallel) { tests = tests ? ' -g "' + tests + '"' : ''; - var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run; + var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + bail + ' -t ' + testTimeout + ' ' + run; console.log(cmd); exec(cmd, function () { runLinter(); @@ -814,7 +815,7 @@ task("runtests-parallel", ["build-rules", "tests", builtLocalDirectory], functio runConsoleTests('min', /*runInParallel*/ true); }, {async: true}); -desc("Runs the tests using the built run.js file. Optional arguments are: t[ests]=regex r[eporter]=[list|spec|json|] d[ebug]=true color[s]=false lint=true."); +desc("Runs the tests using the built run.js file. Optional arguments are: t[ests]=regex r[eporter]=[list|spec|json|] d[ebug]=true color[s]=false lint=true bail=false."); task("runtests", ["build-rules", "tests", builtLocalDirectory], function() { runConsoleTests('mocha-fivemat-progress-reporter', /*runInParallel*/ false); }, {async: true}); From 4450bfb05ce3897137c7a47c7a3add1bfd34a63d Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 3 Jun 2016 10:15:57 -0700 Subject: [PATCH 2/3] Add bail option to runtests-parallel too --- Jakefile.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index feaae86c1c976..2769d761d4c6d 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -755,13 +755,18 @@ function runConsoleTests(defaultReporter, runInParallel) { // schedule work for chunks configFiles.forEach(function (f) { var configPath = path.join(taskConfigsFolder, f); - var workerCmd = "mocha" + " -t " + testTimeout + " -R " + reporter + " " + colors + " " + run + " --config='" + configPath + "'"; + var workerCmd = "mocha" + " -t " + testTimeout + " -R " + reporter + " " + colors + bail + " " + run + " --config='" + configPath + "'"; console.log(workerCmd); exec(workerCmd, finishWorker, finishWorker) }); function finishWorker(e, errorStatus) { counter--; + + if (bail && errorStatus !== undefined) { + failWithStatus(firstErrorStatus); + } + if (firstErrorStatus === undefined && errorStatus !== undefined) { firstErrorStatus = errorStatus; } @@ -810,7 +815,7 @@ function runConsoleTests(defaultReporter, runInParallel) { } var testTimeout = 20000; -desc("Runs all the tests in parallel using the built run.js file. Optional arguments are: t[ests]=category1|category2|... d[ebug]=true."); +desc("Runs all the tests in parallel using the built run.js file. Optional arguments are: t[ests]=category1|category2|... d[ebug]=true bail=false."); task("runtests-parallel", ["build-rules", "tests", builtLocalDirectory], function() { runConsoleTests('min', /*runInParallel*/ true); }, {async: true}); From c04075db46000a39783f66f0d96376cc8051e476 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 6 Jun 2016 11:37:06 -0700 Subject: [PATCH 3/3] Fix error --- Jakefile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jakefile.js b/Jakefile.js index 2769d761d4c6d..9c4e72a1e3dd6 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -764,7 +764,7 @@ function runConsoleTests(defaultReporter, runInParallel) { counter--; if (bail && errorStatus !== undefined) { - failWithStatus(firstErrorStatus); + failWithStatus(errorStatus); } if (firstErrorStatus === undefined && errorStatus !== undefined) {