diff --git a/Jakefile.js b/Jakefile.js index 151f1ab5db4..85ae5f60361 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -726,16 +726,25 @@ function runConsoleTests(defaultReporter, runInParallel) { tests = tests ? ' -g "' + tests + '"' : ''; var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run; console.log(cmd); + + var savedNodeEnv = process.env.NODE_ENV; + process.env.NODE_ENV = "development"; exec(cmd, function () { + process.env.NODE_ENV = savedNodeEnv; runLinter(); finish(); }, function(e, status) { + process.env.NODE_ENV = savedNodeEnv; finish(status); }); } else { + var savedNodeEnv = process.env.NODE_ENV; + process.env.NODE_ENV = "development"; runTestsInParallel(taskConfigsFolder, run, { testTimeout: testTimeout, noColors: colors === " --no-colors " }, function (err) { + process.env.NODE_ENV = savedNodeEnv; + // last worker clean everything and runs linter in case if there were no errors deleteTemporaryProjectOutput(); jake.rmRf(taskConfigsFolder); diff --git a/scripts/mocha-parallel.js b/scripts/mocha-parallel.js index 159dd630cc2..cc695729cbd 100644 --- a/scripts/mocha-parallel.js +++ b/scripts/mocha-parallel.js @@ -34,13 +34,7 @@ function discoverTests(run, options, cb) { console.log("Discovering tests..."); var cmd = "mocha -R " + require.resolve("./mocha-none-reporter.js") + " " + run; - var p = child_process.spawn( - process.platform === "win32" ? "cmd" : "/bin/sh", - process.platform === "win32" ? ["/c", cmd] : ["-c", cmd], { - windowsVerbatimArguments: true, - env: { NODE_ENV: "development" } - }); - + var p = spawnProcess(cmd); p.on("exit", function (status) { if (status) { cb(new Error("Process exited with code " + status)); @@ -87,18 +81,11 @@ function runTests(taskConfigsFolder, run, options, cb) { // Start the background process. var cmd = "mocha -t " + (options.testTimeout || 20000) + " -R tap --no-colors " + run + " --config='" + partition.file + "'"; - var p = child_process.spawn( - process.platform === "win32" ? "cmd" : "/bin/sh", - process.platform === "win32" ? ["/c", cmd] : ["-c", cmd], { - windowsVerbatimArguments: true, - env: { NODE_ENV: "development" } - }); - + var p = spawnProcess(cmd); var rl = readline.createInterface({ input: p.stdout, terminal: false }); - rl.on("line", onmessage); p.on("exit", onexit) @@ -259,6 +246,12 @@ function runTests(taskConfigsFolder, run, options, cb) { } } +function spawnProcess(cmd, options) { + var shell = process.platform === "win32" ? "cmd" : "/bin/sh"; + var prefix = process.platform === "win32" ? "/c" : "-c"; + return child_process.spawn(shell, [prefix, cmd], { windowsVerbatimArguments: true }); +} + function ProgressBars(options) { if (!options) options = {}; var open = options.open || '[';