@@ -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/" ;
@@ -188,7 +189,10 @@ var es2016LibrarySourceMap = es2016LibrarySource.map(function (source) {
188
189
return { target : "lib." + source , sources : [ "header.d.ts" , source ] } ;
189
190
} ) ;
190
191
191
- var es2017LibrarySource = [ "es2017.object.d.ts" ] ;
192
+ var es2017LibrarySource = [
193
+ "es2017.object.d.ts" ,
194
+ "es2017.sharedmemory.d.ts"
195
+ ] ;
192
196
193
197
var es2017LibrarySourceMap = es2017LibrarySource . map ( function ( source ) {
194
198
return { target : "lib." + source , sources : [ "header.d.ts" , source ] } ;
@@ -309,10 +313,9 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
309
313
}
310
314
311
315
if ( useDebugMode ) {
312
- options += " -sourcemap" ;
313
- if ( ! opts . noMapRoot ) {
314
- options += " -mapRoot file:///" + path . resolve ( path . dirname ( outFile ) ) ;
315
- }
316
+ options += " --inlineSourceMap --inlineSources" ;
317
+ } else {
318
+ options += " --newLine LF" ;
316
319
}
317
320
318
321
if ( opts . stripInternal ) {
@@ -480,7 +483,6 @@ var tscFile = path.join(builtLocalDirectory, compilerFilename);
480
483
compileFile ( tscFile , compilerSources , [ builtLocalDirectory , copyright ] . concat ( compilerSources ) , [ copyright ] , /*useBuiltCompiler:*/ false ) ;
481
484
482
485
var servicesFile = path . join ( builtLocalDirectory , "typescriptServices.js" ) ;
483
- var servicesFileInBrowserTest = path . join ( builtLocalDirectory , "typescriptServicesInBrowserTest.js" ) ;
484
486
var standaloneDefinitionsFile = path . join ( builtLocalDirectory , "typescriptServices.d.ts" ) ;
485
487
var nodePackageFile = path . join ( builtLocalDirectory , "typescript.js" ) ;
486
488
var nodeDefinitionsFile = path . join ( builtLocalDirectory , "typescript.d.ts" ) ;
@@ -512,16 +514,6 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca
512
514
fs . writeFileSync ( nodeStandaloneDefinitionsFile , nodeStandaloneDefinitionsFileContents ) ;
513
515
} ) ;
514
516
515
- compileFile ( servicesFileInBrowserTest , servicesSources , [ builtLocalDirectory , copyright ] . concat ( servicesSources ) ,
516
- /*prefixes*/ [ copyright ] ,
517
- /*useBuiltCompiler*/ true ,
518
- { noOutFile : false , generateDeclarations : true , preserveConstEnums : true , keepComments : true , noResolve : false , stripInternal : true , noMapRoot : true } ,
519
- /*callback*/ function ( ) {
520
- var content = fs . readFileSync ( servicesFileInBrowserTest ) . toString ( ) ;
521
- var i = content . lastIndexOf ( "\n" ) ;
522
- fs . writeFileSync ( servicesFileInBrowserTest , content . substring ( 0 , i ) + "\r\n//# sourceURL=../built/local/typeScriptServices.js" + content . substring ( i ) ) ;
523
- } ) ;
524
-
525
517
526
518
var serverFile = path . join ( builtLocalDirectory , "tsserver.js" ) ;
527
519
compileFile ( serverFile , serverSources , [ builtLocalDirectory , copyright ] . concat ( serverSources ) , /*prefixes*/ [ copyright ] , /*useBuiltCompiler*/ true ) ;
@@ -683,7 +675,6 @@ function cleanTestDirs() {
683
675
// used to pass data from jake command line directly to run.js
684
676
function writeTestConfigFile ( tests , light , taskConfigsFolder , workerCount ) {
685
677
var testConfigContents = JSON . stringify ( { test : tests ? [ tests ] : undefined , light : light , workerCount : workerCount , taskConfigsFolder : taskConfigsFolder } ) ;
686
- console . log ( 'Running tests with config: ' + testConfigContents ) ;
687
678
fs . writeFileSync ( 'test.config' , testConfigContents ) ;
688
679
}
689
680
@@ -735,51 +726,34 @@ function runConsoleTests(defaultReporter, runInParallel) {
735
726
tests = tests ? ' -g "' + tests + '"' : '' ;
736
727
var cmd = "mocha" + ( debug ? " --debug-brk" : "" ) + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run ;
737
728
console . log ( cmd ) ;
729
+
730
+ var savedNodeEnv = process . env . NODE_ENV ;
731
+ process . env . NODE_ENV = "development" ;
738
732
exec ( cmd , function ( ) {
733
+ process . env . NODE_ENV = savedNodeEnv ;
739
734
runLinter ( ) ;
740
735
finish ( ) ;
741
736
} , function ( e , status ) {
737
+ process . env . NODE_ENV = savedNodeEnv ;
742
738
finish ( status ) ;
743
739
} ) ;
744
740
745
741
}
746
742
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
- }
743
+ var savedNodeEnv = process . env . NODE_ENV ;
744
+ process . env . NODE_ENV = "development" ;
745
+ runTestsInParallel ( taskConfigsFolder , run , { testTimeout : testTimeout , noColors : colors === " --no-colors " } , function ( err ) {
746
+ process . env . NODE_ENV = savedNodeEnv ;
747
+
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 ( ) ;
783
757
}
784
758
} ) ;
785
759
}
@@ -834,12 +808,12 @@ compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile
834
808
835
809
desc ( "Runs browserify on run.js to produce a file suitable for running tests in the browser" ) ;
836
810
task ( "browserify" , [ "tests" , builtLocalDirectory , nodeServerOutFile ] , function ( ) {
837
- var cmd = 'browserify built/local/run.js -o built/local/bundle.js' ;
811
+ var cmd = 'browserify built/local/run.js -d - o built/local/bundle.js' ;
838
812
exec ( cmd ) ;
839
813
} , { async : true } ) ;
840
814
841
815
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]" ) ;
842
- task ( "runtests-browser" , [ "tests" , "browserify" , builtLocalDirectory , servicesFileInBrowserTest ] , function ( ) {
816
+ task ( "runtests-browser" , [ "tests" , "browserify" , builtLocalDirectory , servicesFile ] , function ( ) {
843
817
cleanTestDirs ( ) ;
844
818
host = "node" ;
845
819
port = process . env . port || process . env . p || '8888' ;
0 commit comments