Skip to content

Commit 19baf1f

Browse files
committed
Adds progress indicators to the runtests-parallel build task.
1 parent cdf4cde commit 19baf1f

File tree

3 files changed

+404
-37
lines changed

3 files changed

+404
-37
lines changed

Jakefile.js

Lines changed: 11 additions & 37 deletions
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/";
@@ -683,7 +684,6 @@ function cleanTestDirs() {
683684
// used to pass data from jake command line directly to run.js
684685
function writeTestConfigFile(tests, light, taskConfigsFolder, workerCount) {
685686
var testConfigContents = JSON.stringify({ test: tests ? [tests] : undefined, light: light, workerCount: workerCount, taskConfigsFolder: taskConfigsFolder });
686-
console.log('Running tests with config: ' + testConfigContents);
687687
fs.writeFileSync('test.config', testConfigContents);
688688
}
689689

@@ -744,42 +744,16 @@ function runConsoleTests(defaultReporter, runInParallel) {
744744

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

scripts/mocha-none-reporter.js

Lines changed: 26 additions & 0 deletions
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)