@@ -5,6 +5,7 @@ var os = require("os");
5
5
var path = require ( "path" ) ;
6
6
var child_process = require ( "child_process" ) ;
7
7
var Linter = require ( "tslint" ) ;
8
+ var runTestsInParallel = require ( "./scripts/mocha-parallel" ) . runTestsInParallel ;
8
9
9
10
// Variables
10
11
var compilerDirectory = "src/compiler/" ;
@@ -688,7 +689,6 @@ function cleanTestDirs() {
688
689
// used to pass data from jake command line directly to run.js
689
690
function writeTestConfigFile ( tests , light , taskConfigsFolder , workerCount ) {
690
691
var testConfigContents = JSON . stringify ( { test : tests ? [ tests ] : undefined , light : light , workerCount : workerCount , taskConfigsFolder : taskConfigsFolder } ) ;
691
- console . log ( 'Running tests with config: ' + testConfigContents ) ;
692
692
fs . writeFileSync ( 'test.config' , testConfigContents ) ;
693
693
}
694
694
@@ -749,42 +749,16 @@ function runConsoleTests(defaultReporter, runInParallel) {
749
749
750
750
}
751
751
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 ( ) ;
788
762
}
789
763
} ) ;
790
764
}
0 commit comments