@@ -25,6 +25,8 @@ var LKGDirectory = "lib/";
25
25
var copyright = "CopyrightNotice.txt" ;
26
26
var thirdParty = "ThirdPartyNoticeText.txt" ;
27
27
28
+ var defaultTestTimeout = 40000 ;
29
+
28
30
// add node_modules to path so we don't need global modules, prefer the modules by adding them first
29
31
var nodeModulesPathPrefix = path . resolve ( "./node_modules/.bin/" ) + path . delimiter ;
30
32
if ( process . env . path !== undefined ) {
@@ -74,6 +76,10 @@ function measure(marker) {
74
76
console . log ( "travis_time:end:" + marker . id + ":start=" + toNs ( marker . stamp ) + ",finish=" + toNs ( total ) + ",duration=" + toNs ( diff ) + "\r" ) ;
75
77
}
76
78
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
+
77
83
var compilerSources = filesFromConfig ( "./src/compiler/tsconfig.json" ) ;
78
84
var servicesSources = filesFromConfig ( "./src/services/tsconfig.json" ) ;
79
85
var cancellationTokenSources = filesFromConfig ( path . join ( serverDirectory , "cancellationToken/tsconfig.json" ) ) ;
@@ -268,7 +274,6 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
268
274
* @param {boolean } opts.preserveConstEnums: true if compiler should keep const enums in code
269
275
* @param {boolean } opts.noResolve: true if compiler should not include non-rooted files in compilation
270
276
* @param {boolean } opts.stripInternal: true if compiler should remove declarations marked as @internal
271
- * @param {boolean } opts.noMapRoot: true if compiler omit mapRoot option
272
277
* @param {boolean } opts.inlineSourceMap: true if compiler should inline sourceMap
273
278
* @param {Array } opts.types: array of types to include in compilation
274
279
* @param callback: a function to execute after the compilation process ends
@@ -321,9 +326,6 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
321
326
}
322
327
else {
323
328
options += " -sourcemap" ;
324
- if ( ! opts . noMapRoot ) {
325
- options += " -mapRoot file:///" + path . resolve ( path . dirname ( outFile ) ) ;
326
- }
327
329
}
328
330
}
329
331
else {
@@ -527,7 +529,7 @@ task("importDefinitelyTypedTests", [importDefinitelyTypedTestsJs], function () {
527
529
528
530
// Local target to build the compiler and services
529
531
var 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 ) ;
531
533
532
534
var servicesFile = path . join ( builtLocalDirectory , "typescriptServices.js" ) ;
533
535
var servicesFileInBrowserTest = path . join ( builtLocalDirectory , "typescriptServicesInBrowserTest.js" ) ;
@@ -555,7 +557,7 @@ compileFile(servicesFile, servicesSources, [builtLocalDirectory, copyright].conc
555
557
// Stanalone/web definition file using global 'ts' namespace
556
558
jake . cpR ( standaloneDefinitionsFile , nodeDefinitionsFile , { silent : true } ) ;
557
559
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 )
559
561
fs . writeFileSync ( standaloneDefinitionsFile , definitionFileContents ) ;
560
562
561
563
// Official node package definition file, pointed to by 'typings' in package.json
@@ -582,7 +584,6 @@ compileFile(
582
584
keepComments : true ,
583
585
noResolve : false ,
584
586
stripInternal : true ,
585
- noMapRoot : true ,
586
587
inlineSourceMap : true
587
588
} ) ;
588
589
@@ -616,6 +617,7 @@ compileFile(
616
617
fs . readFileSync ( tsserverLibraryDefinitionFile ) . toString ( ) +
617
618
"\r\nexport = ts;" +
618
619
"\r\nexport as namespace ts;" ;
620
+ tsserverLibraryDefinitionFileContents = removeConstModifierFromEnumDeclarations ( tsserverLibraryDefinitionFileContents ) ;
619
621
620
622
fs . writeFileSync ( tsserverLibraryDefinitionFile , tsserverLibraryDefinitionFileContents ) ;
621
623
} ) ;
@@ -805,9 +807,10 @@ function runConsoleTests(defaultReporter, runInParallel) {
805
807
cleanTestDirs ( ) ;
806
808
}
807
809
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 ;
811
814
var light = process . env . light || false ;
812
815
var stackTraceLimit = process . env . stackTraceLimit ;
813
816
var testConfigFile = 'test.config' ;
@@ -825,7 +828,7 @@ function runConsoleTests(defaultReporter, runInParallel) {
825
828
} while ( fs . existsSync ( taskConfigsFolder ) ) ;
826
829
fs . mkdirSync ( taskConfigsFolder ) ;
827
830
828
- workerCount = process . env . workerCount || os . cpus ( ) . length ;
831
+ workerCount = process . env . workerCount || process . env . p || os . cpus ( ) . length ;
829
832
}
830
833
831
834
if ( tests || light || taskConfigsFolder ) {
@@ -846,12 +849,6 @@ function runConsoleTests(defaultReporter, runInParallel) {
846
849
if ( ! runInParallel ) {
847
850
var startTime = mark ( ) ;
848
851
var args = [ ] ;
849
- if ( inspect ) {
850
- args . push ( "--inspect" ) ;
851
- }
852
- if ( inspect || debug ) {
853
- args . push ( "--debug-brk" ) ;
854
- }
855
852
args . push ( "-R" , reporter ) ;
856
853
if ( tests ) {
857
854
args . push ( "-g" , `"${ tests } "` ) ;
@@ -865,7 +862,15 @@ function runConsoleTests(defaultReporter, runInParallel) {
865
862
if ( bail ) {
866
863
args . push ( "--bail" ) ;
867
864
}
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
+ }
869
874
args . push ( run ) ;
870
875
871
876
var cmd = "mocha " + args . join ( " " ) ;
@@ -930,7 +935,6 @@ function runConsoleTests(defaultReporter, runInParallel) {
930
935
}
931
936
}
932
937
933
- var testTimeout = 20000 ;
934
938
desc ( "Runs all the tests in parallel using the built run.js file. Optional arguments are: t[ests]=category1|category2|... d[ebug]=true." ) ;
935
939
task ( "runtests-parallel" , [ "build-rules" , "tests" , builtLocalDirectory ] , function ( ) {
936
940
runConsoleTests ( 'min' , /*runInParallel*/ true ) ;
@@ -943,6 +947,7 @@ task("runtests", ["build-rules", "tests", builtLocalDirectory], function() {
943
947
944
948
desc ( "Generates code coverage data via instanbul" ) ;
945
949
task ( "generate-code-coverage" , [ "tests" , builtLocalDirectory ] , function ( ) {
950
+ var testTimeout = process . env . timeout || defaultTestTimeout ;
946
951
var cmd = 'istanbul cover node_modules/mocha/bin/_mocha -- -R min -t ' + testTimeout + ' ' + run ;
947
952
console . log ( cmd ) ;
948
953
exec ( cmd ) ;
0 commit comments