Skip to content

Commit c14d711

Browse files
committed
Merge pull request #9043 from Microsoft/parallelTestProgress
Adds progress indicators to the runtests-parallel build task.
2 parents 82505ea + 8fc3422 commit c14d711

File tree

3 files changed

+404
-37
lines changed

3 files changed

+404
-37
lines changed

Jakefile.js

+11-37
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var os = require("os");
55
var path = require("path");
66
var child_process = require("child_process");
77
var Linter = require("tslint");
8+
var runTestsInParallel = require("./scripts/mocha-parallel").runTestsInParallel;
89

910
// Variables
1011
var compilerDirectory = "src/compiler/";
@@ -688,7 +689,6 @@ function cleanTestDirs() {
688689
// used to pass data from jake command line directly to run.js
689690
function writeTestConfigFile(tests, light, taskConfigsFolder, workerCount) {
690691
var testConfigContents = JSON.stringify({ test: tests ? [tests] : undefined, light: light, workerCount: workerCount, taskConfigsFolder: taskConfigsFolder });
691-
console.log('Running tests with config: ' + testConfigContents);
692692
fs.writeFileSync('test.config', testConfigContents);
693693
}
694694

@@ -749,42 +749,16 @@ function runConsoleTests(defaultReporter, runInParallel) {
749749

750750
}
751751
else {
752-
// run task to load all tests and partition them between workers
753-
var cmd = "mocha " + " -R min " + colors + run;
754-
console.log(cmd);
755-
exec(cmd, function() {
756-
// read all configuration files and spawn a worker for every config
757-
var configFiles = fs.readdirSync(taskConfigsFolder);
758-
var counter = configFiles.length;
759-
var firstErrorStatus;
760-
// schedule work for chunks
761-
configFiles.forEach(function (f) {
762-
var configPath = path.join(taskConfigsFolder, f);
763-
var workerCmd = "mocha" + " -t " + testTimeout + " -R " + reporter + " " + colors + " " + run + " --config='" + configPath + "'";
764-
console.log(workerCmd);
765-
exec(workerCmd, finishWorker, finishWorker)
766-
});
767-
768-
function finishWorker(e, errorStatus) {
769-
counter--;
770-
if (firstErrorStatus === undefined && errorStatus !== undefined) {
771-
firstErrorStatus = errorStatus;
772-
}
773-
if (counter !== 0) {
774-
complete();
775-
}
776-
else {
777-
// last worker clean everything and runs linter in case if there were no errors
778-
deleteTemporaryProjectOutput();
779-
jake.rmRf(taskConfigsFolder);
780-
if (firstErrorStatus === undefined) {
781-
runLinter();
782-
complete();
783-
}
784-
else {
785-
failWithStatus(firstErrorStatus);
786-
}
787-
}
752+
runTestsInParallel(taskConfigsFolder, run, { testTimeout: testTimeout, noColors: colors === " --no-colors " }, function (err) {
753+
// last worker clean everything and runs linter in case if there were no errors
754+
deleteTemporaryProjectOutput();
755+
jake.rmRf(taskConfigsFolder);
756+
if (err) {
757+
fail(err);
758+
}
759+
else {
760+
runLinter();
761+
complete();
788762
}
789763
});
790764
}

scripts/mocha-none-reporter.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Module dependencies.
3+
*/
4+
5+
var Base = require('mocha').reporters.Base;
6+
7+
/**
8+
* Expose `None`.
9+
*/
10+
11+
exports = module.exports = None;
12+
13+
/**
14+
* Initialize a new `None` test reporter.
15+
*
16+
* @api public
17+
* @param {Runner} runner
18+
*/
19+
function None(runner) {
20+
Base.call(this);
21+
}
22+
23+
/**
24+
* Inherit from `Base.prototype`.
25+
*/
26+
None.prototype.__proto__ = Base.prototype;

0 commit comments

Comments
 (0)