@@ -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 fold = require ( "travis-fold" ) ;
8
9
var runTestsInParallel = require ( "./scripts/mocha-parallel" ) . runTestsInParallel ;
9
10
10
11
// Variables
@@ -32,6 +33,28 @@ if (process.env.path !== undefined) {
32
33
process . env . PATH = nodeModulesPathPrefix + process . env . PATH ;
33
34
}
34
35
36
+ function toNs ( diff ) {
37
+ return diff [ 0 ] * 1e9 + diff [ 1 ] ;
38
+ }
39
+
40
+ function mark ( ) {
41
+ if ( ! fold . isTravis ( ) ) return ;
42
+ var stamp = process . hrtime ( ) ;
43
+ var id = Math . floor ( Math . random ( ) * 0xFFFFFFFF ) . toString ( 16 ) ;
44
+ console . log ( "travis_time:start:" + id + "\r" ) ;
45
+ return {
46
+ stamp : stamp ,
47
+ id : id
48
+ } ;
49
+ }
50
+
51
+ function measure ( marker ) {
52
+ if ( ! fold . isTravis ( ) ) return ;
53
+ var diff = process . hrtime ( marker . stamp ) ;
54
+ var total = [ marker . stamp [ 0 ] + diff [ 0 ] , marker . stamp [ 1 ] + diff [ 1 ] ] ;
55
+ console . log ( "travis_time:end:" + marker . id + ":start=" + toNs ( marker . stamp ) + ",finish=" + toNs ( total ) + ",duration=" + toNs ( diff ) + "\r" ) ;
56
+ }
57
+
35
58
var compilerSources = [
36
59
"core.ts" ,
37
60
"performance.ts" ,
@@ -285,6 +308,7 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
285
308
*/
286
309
function compileFile ( outFile , sources , prereqs , prefixes , useBuiltCompiler , opts , callback ) {
287
310
file ( outFile , prereqs , function ( ) {
311
+ var startCompileTime = mark ( ) ;
288
312
opts = opts || { } ;
289
313
var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler ;
290
314
var options = "--noImplicitAny --noImplicitThis --noEmitOnError --types "
@@ -361,11 +385,13 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
361
385
callback ( ) ;
362
386
}
363
387
388
+ measure ( startCompileTime ) ;
364
389
complete ( ) ;
365
390
} ) ;
366
391
ex . addListener ( "error" , function ( ) {
367
392
fs . unlinkSync ( outFile ) ;
368
393
fail ( "Compilation of " + outFile + " unsuccessful" ) ;
394
+ measure ( startCompileTime ) ;
369
395
} ) ;
370
396
ex . run ( ) ;
371
397
} , { async : true } ) ;
@@ -551,7 +577,7 @@ var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibr
551
577
compileFile (
552
578
tsserverLibraryFile ,
553
579
languageServiceLibrarySources ,
554
- [ builtLocalDirectory , copyright ] . concat ( languageServiceLibrarySources ) ,
580
+ [ builtLocalDirectory , copyright , builtLocalCompiler ] . concat ( languageServiceLibrarySources ) . concat ( libraryTargets ) ,
555
581
/*prefixes*/ [ copyright ] ,
556
582
/*useBuiltCompiler*/ true ,
557
583
{ noOutFile : false , generateDeclarations : true } ) ;
@@ -560,9 +586,19 @@ compileFile(
560
586
desc ( "Builds language service server library" ) ;
561
587
task ( "lssl" , [ tsserverLibraryFile , tsserverLibraryDefinitionFile ] ) ;
562
588
589
+ desc ( "Emit the start of the build fold" ) ;
590
+ task ( "build-fold-start" , [ ] , function ( ) {
591
+ if ( fold . isTravis ( ) ) console . log ( fold . start ( "build" ) ) ;
592
+ } ) ;
593
+
594
+ desc ( "Emit the end of the build fold" ) ;
595
+ task ( "build-fold-end" , [ ] , function ( ) {
596
+ if ( fold . isTravis ( ) ) console . log ( fold . end ( "build" ) ) ;
597
+ } ) ;
598
+
563
599
// Local target to build the compiler and services
564
600
desc ( "Builds the full compiler and services" ) ;
565
- task ( "local" , [ "generate-diagnostics" , "lib" , tscFile , servicesFile , nodeDefinitionsFile , serverFile , builtGeneratedDiagnosticMessagesJSON ] ) ;
601
+ task ( "local" , [ "build-fold-start" , " generate-diagnostics", "lib" , tscFile , servicesFile , nodeDefinitionsFile , serverFile , builtGeneratedDiagnosticMessagesJSON , "lssl" , "build-fold-end" ] ) ;
566
602
567
603
// Local target to build only tsc.js
568
604
desc ( "Builds only the compiler" ) ;
@@ -617,7 +653,7 @@ task("generate-spec", [specMd]);
617
653
618
654
// Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory
619
655
desc ( "Makes a new LKG out of the built js files" ) ;
620
- task ( "LKG" , [ "clean" , "release" , "local" , "lssl" ] . concat ( libraryTargets ) , function ( ) {
656
+ task ( "LKG" , [ "clean" , "release" , "local" ] . concat ( libraryTargets ) , function ( ) {
621
657
var expectedFiles = [ tscFile , servicesFile , serverFile , nodePackageFile , nodeDefinitionsFile , standaloneDefinitionsFile , tsserverLibraryFile , tsserverLibraryDefinitionFile ] . concat ( libraryTargets ) ;
622
658
var missingFiles = expectedFiles . filter ( function ( f ) {
623
659
return ! fs . existsSync ( f ) ;
@@ -758,6 +794,7 @@ function runConsoleTests(defaultReporter, runInParallel) {
758
794
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
759
795
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
760
796
if ( ! runInParallel ) {
797
+ var startTime = mark ( ) ;
761
798
tests = tests ? ' -g "' + tests + '"' : '' ;
762
799
var cmd = "mocha" + ( debug ? " --debug-brk" : "" ) + " -R " + reporter + tests + colors + bail + ' -t ' + testTimeout + ' ' + run ;
763
800
console . log ( cmd ) ;
@@ -766,20 +803,23 @@ function runConsoleTests(defaultReporter, runInParallel) {
766
803
process . env . NODE_ENV = "development" ;
767
804
exec ( cmd , function ( ) {
768
805
process . env . NODE_ENV = savedNodeEnv ;
806
+ measure ( startTime ) ;
769
807
runLinter ( ) ;
770
808
finish ( ) ;
771
809
} , function ( e , status ) {
772
810
process . env . NODE_ENV = savedNodeEnv ;
811
+ measure ( startTime ) ;
773
812
finish ( status ) ;
774
813
} ) ;
775
814
776
815
}
777
816
else {
778
817
var savedNodeEnv = process . env . NODE_ENV ;
779
818
process . env . NODE_ENV = "development" ;
819
+ var startTime = mark ( ) ;
780
820
runTestsInParallel ( taskConfigsFolder , run , { testTimeout : testTimeout , noColors : colors === " --no-colors " } , function ( err ) {
781
821
process . env . NODE_ENV = savedNodeEnv ;
782
-
822
+ measure ( startTime ) ;
783
823
// last worker clean everything and runs linter in case if there were no errors
784
824
deleteTemporaryProjectOutput ( ) ;
785
825
jake . rmRf ( taskConfigsFolder ) ;
@@ -998,12 +1038,22 @@ var tslintRulesOutFiles = tslintRules.map(function(p) {
998
1038
return path . join ( builtLocalDirectory , "tslint" , p + ".js" ) ;
999
1039
} ) ;
1000
1040
desc ( "Compiles tslint rules to js" ) ;
1001
- task ( "build-rules" , tslintRulesOutFiles ) ;
1041
+ task ( "build-rules" , [ "build-rules-start" ] . concat ( tslintRulesOutFiles ) . concat ( [ "build-rules-end" ] ) ) ;
1002
1042
tslintRulesFiles . forEach ( function ( ruleFile , i ) {
1003
1043
compileFile ( tslintRulesOutFiles [ i ] , [ ruleFile ] , [ ruleFile ] , [ ] , /*useBuiltCompiler*/ false ,
1004
1044
{ noOutFile : true , generateDeclarations : false , outDir : path . join ( builtLocalDirectory , "tslint" ) } ) ;
1005
1045
} ) ;
1006
1046
1047
+ desc ( "Emit the start of the build-rules fold" ) ;
1048
+ task ( "build-rules-start" , [ ] , function ( ) {
1049
+ if ( fold . isTravis ( ) ) console . log ( fold . start ( "build-rules" ) ) ;
1050
+ } ) ;
1051
+
1052
+ desc ( "Emit the end of the build-rules fold" ) ;
1053
+ task ( "build-rules-end" , [ ] , function ( ) {
1054
+ if ( fold . isTravis ( ) ) console . log ( fold . end ( "build-rules" ) ) ;
1055
+ } ) ;
1056
+
1007
1057
function getLinterOptions ( ) {
1008
1058
return {
1009
1059
configuration : require ( "./tslint.json" ) ,
@@ -1047,6 +1097,8 @@ var lintTargets = compilerSources
1047
1097
1048
1098
desc ( "Runs tslint on the compiler sources. Optional arguments are: f[iles]=regex" ) ;
1049
1099
task ( "lint" , [ "build-rules" ] , function ( ) {
1100
+ if ( fold . isTravis ( ) ) console . log ( fold . start ( "lint" ) ) ;
1101
+ var startTime = mark ( ) ;
1050
1102
var lintOptions = getLinterOptions ( ) ;
1051
1103
var failed = 0 ;
1052
1104
var fileMatcher = RegExp ( process . env . f || process . env . file || process . env . files || "" ) ;
@@ -1062,6 +1114,8 @@ task("lint", ["build-rules"], function() {
1062
1114
done [ target ] = true ;
1063
1115
}
1064
1116
}
1117
+ measure ( startTime ) ;
1118
+ if ( fold . isTravis ( ) ) console . log ( fold . end ( "lint" ) ) ;
1065
1119
if ( failed > 0 ) {
1066
1120
fail ( 'Linter errors.' , failed ) ;
1067
1121
}
0 commit comments