@@ -25,6 +25,8 @@ var LKGDirectory = "lib/";
2525var copyright = "CopyrightNotice.txt" ;
2626var thirdParty = "ThirdPartyNoticeText.txt" ;
2727
28+ var defaultTestTimeout = 40000 ;
29+
2830// add node_modules to path so we don't need global modules, prefer the modules by adding them first
2931var nodeModulesPathPrefix = path . resolve ( "./node_modules/.bin/" ) + path . delimiter ;
3032if ( process . env . path !== undefined ) {
@@ -74,6 +76,10 @@ function measure(marker) {
7476 console . log ( "travis_time:end:" + marker . id + ":start=" + toNs ( marker . stamp ) + ",finish=" + toNs ( total ) + ",duration=" + toNs ( diff ) + "\r" ) ;
7577}
7678
79+ function removeConstModifierFromEnumDeclarations ( text ) {
80+ return text . replace ( / ^ ( \s * ) ( e x p o r t ) ? c o n s t e n u m ( \S + ) { ( \s * ) $ / gm, '$1$2enum $3 {$4' ) ;
81+ }
82+
7783var compilerSources = filesFromConfig ( "./src/compiler/tsconfig.json" ) ;
7884var servicesSources = filesFromConfig ( "./src/services/tsconfig.json" ) ;
7985var cancellationTokenSources = filesFromConfig ( path . join ( serverDirectory , "cancellationToken/tsconfig.json" ) ) ;
@@ -268,7 +274,6 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
268274 * @param {boolean } opts.preserveConstEnums: true if compiler should keep const enums in code
269275 * @param {boolean } opts.noResolve: true if compiler should not include non-rooted files in compilation
270276 * @param {boolean } opts.stripInternal: true if compiler should remove declarations marked as @internal
271- * @param {boolean } opts.noMapRoot: true if compiler omit mapRoot option
272277 * @param {boolean } opts.inlineSourceMap: true if compiler should inline sourceMap
273278 * @param {Array } opts.types: array of types to include in compilation
274279 * @param callback: a function to execute after the compilation process ends
@@ -321,9 +326,6 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
321326 }
322327 else {
323328 options += " -sourcemap" ;
324- if ( ! opts . noMapRoot ) {
325- options += " -mapRoot file:///" + path . resolve ( path . dirname ( outFile ) ) ;
326- }
327329 }
328330 }
329331 else {
@@ -527,7 +529,7 @@ task("importDefinitelyTypedTests", [importDefinitelyTypedTestsJs], function () {
527529
528530// Local target to build the compiler and services
529531var tscFile = path . join ( builtLocalDirectory , compilerFilename ) ;
530- compileFile ( tscFile , compilerSources , [ builtLocalDirectory , copyright ] . concat ( compilerSources ) , [ copyright ] , /*useBuiltCompiler:*/ false , { noMapRoot : true } ) ;
532+ compileFile ( tscFile , compilerSources , [ builtLocalDirectory , copyright ] . concat ( compilerSources ) , [ copyright ] , /*useBuiltCompiler:*/ false ) ;
531533
532534var servicesFile = path . join ( builtLocalDirectory , "typescriptServices.js" ) ;
533535var servicesFileInBrowserTest = path . join ( builtLocalDirectory , "typescriptServicesInBrowserTest.js" ) ;
@@ -555,7 +557,7 @@ compileFile(servicesFile, servicesSources, [builtLocalDirectory, copyright].conc
555557 // Stanalone/web definition file using global 'ts' namespace
556558 jake . cpR ( standaloneDefinitionsFile , nodeDefinitionsFile , { silent : true } ) ;
557559 var definitionFileContents = fs . readFileSync ( nodeDefinitionsFile ) . toString ( ) ;
558- definitionFileContents = definitionFileContents . replace ( / ^ ( \s * ) ( e x p o r t ) ? c o n s t e n u m ( \S + ) { ( \s * ) $ / gm , '$1$2enum $3 {$4' ) ;
560+ definitionFileContents = removeConstModifierFromEnumDeclarations ( definitionFileContents )
559561 fs . writeFileSync ( standaloneDefinitionsFile , definitionFileContents ) ;
560562
561563 // Official node package definition file, pointed to by 'typings' in package.json
@@ -582,7 +584,6 @@ compileFile(
582584 keepComments : true ,
583585 noResolve : false ,
584586 stripInternal : true ,
585- noMapRoot : true ,
586587 inlineSourceMap : true
587588 } ) ;
588589
@@ -616,6 +617,7 @@ compileFile(
616617 fs . readFileSync ( tsserverLibraryDefinitionFile ) . toString ( ) +
617618 "\r\nexport = ts;" +
618619 "\r\nexport as namespace ts;" ;
620+ tsserverLibraryDefinitionFileContents = removeConstModifierFromEnumDeclarations ( tsserverLibraryDefinitionFileContents ) ;
619621
620622 fs . writeFileSync ( tsserverLibraryDefinitionFile , tsserverLibraryDefinitionFileContents ) ;
621623 } ) ;
@@ -805,9 +807,10 @@ function runConsoleTests(defaultReporter, runInParallel) {
805807 cleanTestDirs ( ) ;
806808 }
807809
808- var debug = process . env . debug || process . env . d ;
809- var inspect = process . env . inspect ;
810- tests = process . env . test || process . env . tests || process . env . t ;
810+ var debug = process . env . debug || process . env [ "debug-brk" ] || process . env . d ;
811+ var inspect = process . env . inspect || process . env [ "inspect-brk" ] || process . env . i ;
812+ var testTimeout = process . env . timeout || defaultTestTimeout ;
813+ var tests = process . env . test || process . env . tests || process . env . t ;
811814 var light = process . env . light || false ;
812815 var stackTraceLimit = process . env . stackTraceLimit ;
813816 var testConfigFile = 'test.config' ;
@@ -825,7 +828,7 @@ function runConsoleTests(defaultReporter, runInParallel) {
825828 } while ( fs . existsSync ( taskConfigsFolder ) ) ;
826829 fs . mkdirSync ( taskConfigsFolder ) ;
827830
828- workerCount = process . env . workerCount || os . cpus ( ) . length ;
831+ workerCount = process . env . workerCount || process . env . p || os . cpus ( ) . length ;
829832 }
830833
831834 if ( tests || light || taskConfigsFolder ) {
@@ -846,12 +849,6 @@ function runConsoleTests(defaultReporter, runInParallel) {
846849 if ( ! runInParallel ) {
847850 var startTime = mark ( ) ;
848851 var args = [ ] ;
849- if ( inspect ) {
850- args . push ( "--inspect" ) ;
851- }
852- if ( inspect || debug ) {
853- args . push ( "--debug-brk" ) ;
854- }
855852 args . push ( "-R" , reporter ) ;
856853 if ( tests ) {
857854 args . push ( "-g" , `"${ tests } "` ) ;
@@ -865,7 +862,15 @@ function runConsoleTests(defaultReporter, runInParallel) {
865862 if ( bail ) {
866863 args . push ( "--bail" ) ;
867864 }
868- args . push ( "-t" , testTimeout ) ;
865+ if ( inspect ) {
866+ args . unshift ( "--inspect-brk" ) ;
867+ }
868+ else if ( debug ) {
869+ args . unshift ( "--debug-brk" ) ;
870+ }
871+ else {
872+ args . push ( "-t" , testTimeout ) ;
873+ }
869874 args . push ( run ) ;
870875
871876 var cmd = "mocha " + args . join ( " " ) ;
@@ -930,7 +935,6 @@ function runConsoleTests(defaultReporter, runInParallel) {
930935 }
931936}
932937
933- var testTimeout = 20000 ;
934938desc ( "Runs all the tests in parallel using the built run.js file. Optional arguments are: t[ests]=category1|category2|... d[ebug]=true." ) ;
935939task ( "runtests-parallel" , [ "build-rules" , "tests" , builtLocalDirectory ] , function ( ) {
936940 runConsoleTests ( 'min' , /*runInParallel*/ true ) ;
@@ -943,6 +947,7 @@ task("runtests", ["build-rules", "tests", builtLocalDirectory], function() {
943947
944948desc ( "Generates code coverage data via instanbul" ) ;
945949task ( "generate-code-coverage" , [ "tests" , builtLocalDirectory ] , function ( ) {
950+ var testTimeout = process . env . timeout || defaultTestTimeout ;
946951 var cmd = 'istanbul cover node_modules/mocha/bin/_mocha -- -R min -t ' + testTimeout + ' ' + run ;
947952 console . log ( cmd ) ;
948953 exec ( cmd ) ;
0 commit comments