@@ -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/" ;
@@ -688,7 +689,6 @@ function cleanTestDirs() {
688689// used to pass data from jake command line directly to run.js
689690function 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 }
0 commit comments