Skip to content

Commit a1e4135

Browse files
authored
Merge pull request #9066 from Microsoft/fixRuntestsParallel
Fixes issue with runtests-parallel
2 parents 2b46656 + 5af8ba8 commit a1e4135

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

Jakefile.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,16 +726,25 @@ function runConsoleTests(defaultReporter, runInParallel) {
726726
tests = tests ? ' -g "' + tests + '"' : '';
727727
var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
728728
console.log(cmd);
729+
730+
var savedNodeEnv = process.env.NODE_ENV;
731+
process.env.NODE_ENV = "development";
729732
exec(cmd, function () {
733+
process.env.NODE_ENV = savedNodeEnv;
730734
runLinter();
731735
finish();
732736
}, function(e, status) {
737+
process.env.NODE_ENV = savedNodeEnv;
733738
finish(status);
734739
});
735740

736741
}
737742
else {
743+
var savedNodeEnv = process.env.NODE_ENV;
744+
process.env.NODE_ENV = "development";
738745
runTestsInParallel(taskConfigsFolder, run, { testTimeout: testTimeout, noColors: colors === " --no-colors " }, function (err) {
746+
process.env.NODE_ENV = savedNodeEnv;
747+
739748
// last worker clean everything and runs linter in case if there were no errors
740749
deleteTemporaryProjectOutput();
741750
jake.rmRf(taskConfigsFolder);

scripts/mocha-parallel.js

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,7 @@ function discoverTests(run, options, cb) {
3434
console.log("Discovering tests...");
3535

3636
var cmd = "mocha -R " + require.resolve("./mocha-none-reporter.js") + " " + run;
37-
var p = child_process.spawn(
38-
process.platform === "win32" ? "cmd" : "/bin/sh",
39-
process.platform === "win32" ? ["/c", cmd] : ["-c", cmd], {
40-
windowsVerbatimArguments: true,
41-
env: { NODE_ENV: "development" }
42-
});
43-
37+
var p = spawnProcess(cmd);
4438
p.on("exit", function (status) {
4539
if (status) {
4640
cb(new Error("Process exited with code " + status));
@@ -87,18 +81,11 @@ function runTests(taskConfigsFolder, run, options, cb) {
8781

8882
// Start the background process.
8983
var cmd = "mocha -t " + (options.testTimeout || 20000) + " -R tap --no-colors " + run + " --config='" + partition.file + "'";
90-
var p = child_process.spawn(
91-
process.platform === "win32" ? "cmd" : "/bin/sh",
92-
process.platform === "win32" ? ["/c", cmd] : ["-c", cmd], {
93-
windowsVerbatimArguments: true,
94-
env: { NODE_ENV: "development" }
95-
});
96-
84+
var p = spawnProcess(cmd);
9785
var rl = readline.createInterface({
9886
input: p.stdout,
9987
terminal: false
10088
});
101-
10289
rl.on("line", onmessage);
10390
p.on("exit", onexit)
10491

@@ -259,6 +246,12 @@ function runTests(taskConfigsFolder, run, options, cb) {
259246
}
260247
}
261248

249+
function spawnProcess(cmd, options) {
250+
var shell = process.platform === "win32" ? "cmd" : "/bin/sh";
251+
var prefix = process.platform === "win32" ? "/c" : "-c";
252+
return child_process.spawn(shell, [prefix, cmd], { windowsVerbatimArguments: true });
253+
}
254+
262255
function ProgressBars(options) {
263256
if (!options) options = {};
264257
var open = options.open || '[';

0 commit comments

Comments
 (0)