@@ -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/" ;
@@ -212,7 +213,10 @@ var es2016LibrarySourceMap = es2016LibrarySource.map(function (source) {
212213 return { target : "lib." + source , sources : [ "header.d.ts" , source ] } ;
213214} ) ;
214215
215- var es2017LibrarySource = [ "es2017.object.d.ts" ] ;
216+ var es2017LibrarySource = [
217+ "es2017.object.d.ts" ,
218+ "es2017.sharedmemory.d.ts"
219+ ] ;
216220
217221var es2017LibrarySourceMap = es2017LibrarySource . map ( function ( source ) {
218222 return { target : "lib." + source , sources : [ "header.d.ts" , source ] } ;
@@ -296,6 +300,7 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
296300 * @param {boolean } opts.noResolve: true if compiler should not include non-rooted files in compilation
297301 * @param {boolean } opts.stripInternal: true if compiler should remove declarations marked as @internal
298302 * @param {boolean } opts.noMapRoot: true if compiler omit mapRoot option
303+ * @param {boolean } opts.inlineSourceMap: true if compiler should inline sourceMap
299304 * @param callback: a function to execute after the compilation process ends
300305 */
301306function compileFile ( outFile , sources , prereqs , prefixes , useBuiltCompiler , opts , callback ) {
@@ -337,10 +342,16 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
337342 }
338343
339344 if ( useDebugMode ) {
340- options += " -sourcemap" ;
341- if ( ! opts . noMapRoot ) {
342- options += " -mapRoot file:///" + path . resolve ( path . dirname ( outFile ) ) ;
345+ if ( opts . inlineSourceMap ) {
346+ options += " --inlineSourceMap --inlineSources" ;
347+ } else {
348+ options += " -sourcemap" ;
349+ if ( ! opts . noMapRoot ) {
350+ options += " -mapRoot file:///" + path . resolve ( path . dirname ( outFile ) ) ;
351+ }
343352 }
353+ } else {
354+ options += " --newLine LF" ;
344355 }
345356
346357 if ( opts . stripInternal ) {
@@ -517,7 +528,13 @@ var nodeStandaloneDefinitionsFile = path.join(builtLocalDirectory, "typescript_s
517528compileFile ( servicesFile , servicesSources , [ builtLocalDirectory , copyright ] . concat ( servicesSources ) ,
518529 /*prefixes*/ [ copyright ] ,
519530 /*useBuiltCompiler*/ true ,
520- { noOutFile : false , generateDeclarations : true , preserveConstEnums : true , keepComments : true , noResolve : false , stripInternal : true } ,
531+ /*opts*/ { noOutFile : false ,
532+ generateDeclarations : true ,
533+ preserveConstEnums : true ,
534+ keepComments : true ,
535+ noResolve : false ,
536+ stripInternal : true
537+ } ,
521538 /*callback*/ function ( ) {
522539 jake . cpR ( servicesFile , nodePackageFile , { silent : true } ) ;
523540
@@ -540,16 +557,21 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca
540557 fs . writeFileSync ( nodeStandaloneDefinitionsFile , nodeStandaloneDefinitionsFileContents ) ;
541558 } ) ;
542559
543- compileFile ( servicesFileInBrowserTest , servicesSources , [ builtLocalDirectory , copyright ] . concat ( servicesSources ) ,
544- /*prefixes*/ [ copyright ] ,
545- /*useBuiltCompiler*/ true ,
546- { noOutFile : false , generateDeclarations : true , preserveConstEnums : true , keepComments : true , noResolve : false , stripInternal : true , noMapRoot : true } ,
547- /*callback*/ function ( ) {
548- var content = fs . readFileSync ( servicesFileInBrowserTest ) . toString ( ) ;
549- var i = content . lastIndexOf ( "\n" ) ;
550- fs . writeFileSync ( servicesFileInBrowserTest , content . substring ( 0 , i ) + "\r\n//# sourceURL=../built/local/typeScriptServices.js" + content . substring ( i ) ) ;
551- } ) ;
552-
560+ compileFile (
561+ servicesFileInBrowserTest ,
562+ servicesSources ,
563+ [ builtLocalDirectory , copyright ] . concat ( servicesSources ) ,
564+ /*prefixes*/ [ copyright ] ,
565+ /*useBuiltCompiler*/ true ,
566+ { noOutFile : false ,
567+ generateDeclarations : true ,
568+ preserveConstEnums : true ,
569+ keepComments : true ,
570+ noResolve : false ,
571+ stripInternal : true ,
572+ noMapRoot : true ,
573+ inlineSourceMap : true
574+ } ) ;
553575
554576var serverFile = path . join ( builtLocalDirectory , "tsserver.js" ) ;
555577compileFile ( serverFile , serverSources , [ builtLocalDirectory , copyright ] . concat ( serverSources ) , /*prefixes*/ [ copyright ] , /*useBuiltCompiler*/ true ) ;
@@ -650,7 +672,13 @@ directory(builtLocalDirectory);
650672
651673// Task to build the tests infrastructure using the built compiler
652674var run = path . join ( builtLocalDirectory , "run.js" ) ;
653- compileFile ( run , harnessSources , [ builtLocalDirectory , tscFile ] . concat ( libraryTargets ) . concat ( harnessSources ) , [ ] , /*useBuiltCompiler:*/ true ) ;
675+ compileFile (
676+ /*outFile*/ run ,
677+ /*source*/ harnessSources ,
678+ /*prereqs*/ [ builtLocalDirectory , tscFile ] . concat ( libraryTargets ) . concat ( harnessSources ) ,
679+ /*prefixes*/ [ ] ,
680+ /*useBuiltCompiler:*/ true ,
681+ /*opts*/ { inlineSourceMap : true } ) ;
654682
655683var internalTests = "internal/" ;
656684
@@ -774,51 +802,34 @@ function runConsoleTests(defaultReporter, runInParallel) {
774802 tests = tests ? ' -g "' + tests + '"' : '' ;
775803 var cmd = "mocha" + ( debug ? " --debug-brk" : "" ) + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run ;
776804 console . log ( cmd ) ;
805+
806+ var savedNodeEnv = process . env . NODE_ENV ;
807+ process . env . NODE_ENV = "development" ;
777808 exec ( cmd , function ( ) {
809+ process . env . NODE_ENV = savedNodeEnv ;
778810 runLinter ( ) ;
779811 finish ( ) ;
780812 } , function ( e , status ) {
813+ process . env . NODE_ENV = savedNodeEnv ;
781814 finish ( status ) ;
782815 } ) ;
783816
784817 }
785818 else {
786- // run task to load all tests and partition them between workers
787- var cmd = "mocha " + " -R min " + colors + run ;
788- console . log ( cmd ) ;
789- exec ( cmd , function ( ) {
790- // read all configuration files and spawn a worker for every config
791- var configFiles = fs . readdirSync ( taskConfigsFolder ) ;
792- var counter = configFiles . length ;
793- var firstErrorStatus ;
794- // schedule work for chunks
795- configFiles . forEach ( function ( f ) {
796- var configPath = path . join ( taskConfigsFolder , f ) ;
797- var workerCmd = "mocha" + " -t " + testTimeout + " -R " + reporter + " " + colors + " " + run + " --config='" + configPath + "'" ;
798- console . log ( workerCmd ) ;
799- exec ( workerCmd , finishWorker , finishWorker )
800- } ) ;
801-
802- function finishWorker ( e , errorStatus ) {
803- counter -- ;
804- if ( firstErrorStatus === undefined && errorStatus !== undefined ) {
805- firstErrorStatus = errorStatus ;
806- }
807- if ( counter !== 0 ) {
808- complete ( ) ;
809- }
810- else {
811- // last worker clean everything and runs linter in case if there were no errors
812- deleteTemporaryProjectOutput ( ) ;
813- jake . rmRf ( taskConfigsFolder ) ;
814- if ( firstErrorStatus === undefined ) {
815- runLinter ( ) ;
816- complete ( ) ;
817- }
818- else {
819- failWithStatus ( firstErrorStatus ) ;
820- }
821- }
819+ var savedNodeEnv = process . env . NODE_ENV ;
820+ process . env . NODE_ENV = "development" ;
821+ runTestsInParallel ( taskConfigsFolder , run , { testTimeout : testTimeout , noColors : colors === " --no-colors " } , function ( err ) {
822+ process . env . NODE_ENV = savedNodeEnv ;
823+
824+ // last worker clean everything and runs linter in case if there were no errors
825+ deleteTemporaryProjectOutput ( ) ;
826+ jake . rmRf ( taskConfigsFolder ) ;
827+ if ( err ) {
828+ fail ( err ) ;
829+ }
830+ else {
831+ runLinter ( ) ;
832+ complete ( ) ;
822833 }
823834 } ) ;
824835 }
@@ -873,7 +884,7 @@ compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile
873884
874885desc ( "Runs browserify on run.js to produce a file suitable for running tests in the browser" ) ;
875886task ( "browserify" , [ "tests" , builtLocalDirectory , nodeServerOutFile ] , function ( ) {
876- var cmd = 'browserify built/local/run.js -t ./scripts/browserify-optional -o built/local/bundle.js' ;
887+ var cmd = 'browserify built/local/run.js -t ./scripts/browserify-optional -d - o built/local/bundle.js' ;
877888 exec ( cmd ) ;
878889} , { async : true } ) ;
879890
@@ -894,7 +905,7 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFi
894905 }
895906
896907 tests = tests ? tests : '' ;
897- var cmd = host + " tests/webTestServer.js " + port + " " + browser + " " + tests ;
908+ var cmd = host + " tests/webTestServer.js " + port + " " + browser + " " + JSON . stringify ( tests ) ;
898909 console . log ( cmd ) ;
899910 exec ( cmd ) ;
900911} , { async : true } ) ;
0 commit comments