@@ -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" ) ) ;
@@ -551,7 +557,7 @@ compileFile(servicesFile, servicesSources, [builtLocalDirectory, copyright].conc
551557 // Stanalone/web definition file using global 'ts' namespace
552558 jake . cpR ( standaloneDefinitionsFile , nodeDefinitionsFile , { silent : true } ) ;
553559 var definitionFileContents = fs . readFileSync ( nodeDefinitionsFile ) . toString ( ) ;
554- 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 )
555561 fs . writeFileSync ( standaloneDefinitionsFile , definitionFileContents ) ;
556562
557563 // Official node package definition file, pointed to by 'typings' in package.json
@@ -611,6 +617,7 @@ compileFile(
611617 fs . readFileSync ( tsserverLibraryDefinitionFile ) . toString ( ) +
612618 "\r\nexport = ts;" +
613619 "\r\nexport as namespace ts;" ;
620+ tsserverLibraryDefinitionFileContents = removeConstModifierFromEnumDeclarations ( tsserverLibraryDefinitionFileContents ) ;
614621
615622 fs . writeFileSync ( tsserverLibraryDefinitionFile , tsserverLibraryDefinitionFileContents ) ;
616623 } ) ;
@@ -800,9 +807,10 @@ function runConsoleTests(defaultReporter, runInParallel) {
800807 cleanTestDirs ( ) ;
801808 }
802809
803- var debug = process . env . debug || process . env . d ;
804- var inspect = process . env . inspect ;
805- 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 ;
806814 var light = process . env . light || false ;
807815 var stackTraceLimit = process . env . stackTraceLimit ;
808816 var testConfigFile = 'test.config' ;
@@ -820,7 +828,7 @@ function runConsoleTests(defaultReporter, runInParallel) {
820828 } while ( fs . existsSync ( taskConfigsFolder ) ) ;
821829 fs . mkdirSync ( taskConfigsFolder ) ;
822830
823- workerCount = process . env . workerCount || os . cpus ( ) . length ;
831+ workerCount = process . env . workerCount || process . env . p || os . cpus ( ) . length ;
824832 }
825833
826834 if ( tests || light || taskConfigsFolder ) {
@@ -841,12 +849,6 @@ function runConsoleTests(defaultReporter, runInParallel) {
841849 if ( ! runInParallel ) {
842850 var startTime = mark ( ) ;
843851 var args = [ ] ;
844- if ( inspect ) {
845- args . push ( "--inspect" ) ;
846- }
847- if ( inspect || debug ) {
848- args . push ( "--debug-brk" ) ;
849- }
850852 args . push ( "-R" , reporter ) ;
851853 if ( tests ) {
852854 args . push ( "-g" , `"${ tests } "` ) ;
@@ -860,7 +862,15 @@ function runConsoleTests(defaultReporter, runInParallel) {
860862 if ( bail ) {
861863 args . push ( "--bail" ) ;
862864 }
863- 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+ }
864874 args . push ( run ) ;
865875
866876 var cmd = "mocha " + args . join ( " " ) ;
@@ -925,7 +935,6 @@ function runConsoleTests(defaultReporter, runInParallel) {
925935 }
926936}
927937
928- var testTimeout = 20000 ;
929938desc ( "Runs all the tests in parallel using the built run.js file. Optional arguments are: t[ests]=category1|category2|... d[ebug]=true." ) ;
930939task ( "runtests-parallel" , [ "build-rules" , "tests" , builtLocalDirectory ] , function ( ) {
931940 runConsoleTests ( 'min' , /*runInParallel*/ true ) ;
@@ -938,6 +947,7 @@ task("runtests", ["build-rules", "tests", builtLocalDirectory], function() {
938947
939948desc ( "Generates code coverage data via instanbul" ) ;
940949task ( "generate-code-coverage" , [ "tests" , builtLocalDirectory ] , function ( ) {
950+ var testTimeout = process . env . timeout || defaultTestTimeout ;
941951 var cmd = 'istanbul cover node_modules/mocha/bin/_mocha -- -R min -t ' + testTimeout + ' ' + run ;
942952 console . log ( cmd ) ;
943953 exec ( cmd ) ;
@@ -949,7 +959,7 @@ var nodeServerInFile = "tests/webTestServer.ts";
949959compileFile ( nodeServerOutFile , [ nodeServerInFile ] , [ builtLocalDirectory , tscFile ] , [ ] , /*useBuiltCompiler:*/ true , { noOutFile : true , lib : "es6" } ) ;
950960
951961desc ( "Runs browserify on run.js to produce a file suitable for running tests in the browser" ) ;
952- task ( "browserify" , [ "tests" , builtLocalDirectory , nodeServerOutFile ] , function ( ) {
962+ task ( "browserify" , [ "tests" , run , builtLocalDirectory , nodeServerOutFile ] , function ( ) {
953963 var cmd = 'browserify built/local/run.js -t ./scripts/browserify-optional -d -o built/local/bundle.js' ;
954964 exec ( cmd ) ;
955965} , { async : true } ) ;
0 commit comments