@@ -5,6 +5,7 @@ var os = require("os");
55var path = require ( "path" ) ;
66var child_process = require ( "child_process" ) ;
77var Linter = require ( "tslint" ) ;
8+ var runTestsInParallel = require ( "./scripts/mocha-parallel" ) . runTestsInParallel ;
89
910// Variables
1011var compilerDirectory = "src/compiler/" ;
@@ -683,7 +684,6 @@ function cleanTestDirs() {
683684// used to pass data from jake command line directly to run.js
684685function 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 }
0 commit comments