@@ -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/" ;
@@ -312,10 +313,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
312
313
}
313
314
314
315
if ( useDebugMode ) {
315
- options += " -sourcemap" ;
316
- if ( ! opts . noMapRoot ) {
317
- options += " -mapRoot file:///" + path . resolve ( path . dirname ( outFile ) ) ;
318
- }
316
+ options += " --inlineSourceMap --inlineSources" ;
319
317
} else {
320
318
options += " --newLine LF" ;
321
319
}
@@ -485,7 +483,6 @@ var tscFile = path.join(builtLocalDirectory, compilerFilename);
485
483
compileFile ( tscFile , compilerSources , [ builtLocalDirectory , copyright ] . concat ( compilerSources ) , [ copyright ] , /*useBuiltCompiler:*/ false ) ;
486
484
487
485
var servicesFile = path . join ( builtLocalDirectory , "typescriptServices.js" ) ;
488
- var servicesFileInBrowserTest = path . join ( builtLocalDirectory , "typescriptServicesInBrowserTest.js" ) ;
489
486
var standaloneDefinitionsFile = path . join ( builtLocalDirectory , "typescriptServices.d.ts" ) ;
490
487
var nodePackageFile = path . join ( builtLocalDirectory , "typescript.js" ) ;
491
488
var nodeDefinitionsFile = path . join ( builtLocalDirectory , "typescript.d.ts" ) ;
@@ -517,16 +514,6 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca
517
514
fs . writeFileSync ( nodeStandaloneDefinitionsFile , nodeStandaloneDefinitionsFileContents ) ;
518
515
} ) ;
519
516
520
- compileFile ( servicesFileInBrowserTest , servicesSources , [ builtLocalDirectory , copyright ] . concat ( servicesSources ) ,
521
- /*prefixes*/ [ copyright ] ,
522
- /*useBuiltCompiler*/ true ,
523
- { noOutFile : false , generateDeclarations : true , preserveConstEnums : true , keepComments : true , noResolve : false , stripInternal : true , noMapRoot : true } ,
524
- /*callback*/ function ( ) {
525
- var content = fs . readFileSync ( servicesFileInBrowserTest ) . toString ( ) ;
526
- var i = content . lastIndexOf ( "\n" ) ;
527
- fs . writeFileSync ( servicesFileInBrowserTest , content . substring ( 0 , i ) + "\r\n//# sourceURL=../built/local/typeScriptServices.js" + content . substring ( i ) ) ;
528
- } ) ;
529
-
530
517
531
518
var serverFile = path . join ( builtLocalDirectory , "tsserver.js" ) ;
532
519
compileFile ( serverFile , serverSources , [ builtLocalDirectory , copyright ] . concat ( serverSources ) , /*prefixes*/ [ copyright ] , /*useBuiltCompiler*/ true ) ;
@@ -688,7 +675,6 @@ function cleanTestDirs() {
688
675
// used to pass data from jake command line directly to run.js
689
676
function writeTestConfigFile ( tests , light , taskConfigsFolder , workerCount ) {
690
677
var testConfigContents = JSON . stringify ( { test : tests ? [ tests ] : undefined , light : light , workerCount : workerCount , taskConfigsFolder : taskConfigsFolder } ) ;
691
- console . log ( 'Running tests with config: ' + testConfigContents ) ;
692
678
fs . writeFileSync ( 'test.config' , testConfigContents ) ;
693
679
}
694
680
@@ -749,42 +735,16 @@ function runConsoleTests(defaultReporter, runInParallel) {
749
735
750
736
}
751
737
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
- }
738
+ runTestsInParallel ( taskConfigsFolder , run , { testTimeout : testTimeout , noColors : colors === " --no-colors " } , function ( err ) {
739
+ // last worker clean everything and runs linter in case if there were no errors
740
+ deleteTemporaryProjectOutput ( ) ;
741
+ jake . rmRf ( taskConfigsFolder ) ;
742
+ if ( err ) {
743
+ fail ( err ) ;
744
+ }
745
+ else {
746
+ runLinter ( ) ;
747
+ complete ( ) ;
788
748
}
789
749
} ) ;
790
750
}
@@ -839,12 +799,12 @@ compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile
839
799
840
800
desc ( "Runs browserify on run.js to produce a file suitable for running tests in the browser" ) ;
841
801
task ( "browserify" , [ "tests" , builtLocalDirectory , nodeServerOutFile ] , function ( ) {
842
- var cmd = 'browserify built/local/run.js -o built/local/bundle.js' ;
802
+ var cmd = 'browserify built/local/run.js -d - o built/local/bundle.js' ;
843
803
exec ( cmd ) ;
844
804
} , { async : true } ) ;
845
805
846
806
desc ( "Runs the tests using the built run.js file like 'jake runtests'. Syntax is jake runtests-browser. Additional optional parameters tests=[regex], port=, browser=[chrome|IE]" ) ;
847
- task ( "runtests-browser" , [ "tests" , "browserify" , builtLocalDirectory , servicesFileInBrowserTest ] , function ( ) {
807
+ task ( "runtests-browser" , [ "tests" , "browserify" , builtLocalDirectory , servicesFile ] , function ( ) {
848
808
cleanTestDirs ( ) ;
849
809
host = "node" ;
850
810
port = process . env . port || process . env . p || '8888' ;
0 commit comments