diff --git a/Jakefile.js b/Jakefile.js index 55113f986bcfd..59d9b69021085 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -726,24 +726,40 @@ function runConsoleTests(defaultReporter, defaultSubsets) { subsetRegexes = subsets.map(function (sub) { return "^" + sub + ".*$"; }); subsetRegexes.push("^(?!" + subsets.join("|") + ").*$"); } + var counter = subsetRegexes.length; + var errorStatus; subsetRegexes.forEach(function (subsetRegex, i) { tests = subsetRegex ? ' -g "' + subsetRegex + '"' : ''; var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run; console.log(cmd); - function finish() { + function finish(status) { + counter--; + // save first error status + if (status !== undefined && errorStatus === undefined) { + errorStatus = status; + } + deleteTemporaryProjectOutput(); - complete(); + if (counter !== 0 || errorStatus === undefined) { + // run linter when last worker is finished + if (lintFlag && counter === 0) { + var lint = jake.Task['lint']; + lint.addListener('complete', function () { + complete(); + }); + lint.invoke(); + } + complete(); + } + else { + fail("Process exited with code " + status); + } } exec(cmd, function () { - if (lintFlag && i === 0) { - var lint = jake.Task['lint']; - lint.addListener('complete', function () { - complete(); - }); - lint.invoke(); - } finish(); - }, finish); + }, function(e, status) { + finish(status); + }); }); }