@@ -5,6 +5,7 @@ var os = require("os");
55var path = require ( "path" ) ;
66var child_process = require ( "child_process" ) ;
77var Linter = require ( "tslint" ) ;
8+ var fold = require ( "travis-fold" ) ;
89var runTestsInParallel = require ( "./scripts/mocha-parallel" ) . runTestsInParallel ;
910
1011// Variables
@@ -32,6 +33,28 @@ if (process.env.path !== undefined) {
3233 process . env . PATH = nodeModulesPathPrefix + process . env . PATH ;
3334}
3435
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+
3558var compilerSources = [
3659 "core.ts" ,
3760 "performance.ts" ,
@@ -285,6 +308,7 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
285308 */
286309function compileFile ( outFile , sources , prereqs , prefixes , useBuiltCompiler , opts , callback ) {
287310 file ( outFile , prereqs , function ( ) {
311+ var startCompileTime = mark ( ) ;
288312 opts = opts || { } ;
289313 var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler ;
290314 var options = "--noImplicitAny --noImplicitThis --noEmitOnError --types "
@@ -361,11 +385,13 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
361385 callback ( ) ;
362386 }
363387
388+ measure ( startCompileTime ) ;
364389 complete ( ) ;
365390 } ) ;
366391 ex . addListener ( "error" , function ( ) {
367392 fs . unlinkSync ( outFile ) ;
368393 fail ( "Compilation of " + outFile + " unsuccessful" ) ;
394+ measure ( startCompileTime ) ;
369395 } ) ;
370396 ex . run ( ) ;
371397 } , { async : true } ) ;
@@ -551,7 +577,7 @@ var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibr
551577compileFile (
552578 tsserverLibraryFile ,
553579 languageServiceLibrarySources ,
554- [ builtLocalDirectory , copyright ] . concat ( languageServiceLibrarySources ) ,
580+ [ builtLocalDirectory , copyright , builtLocalCompiler ] . concat ( languageServiceLibrarySources ) . concat ( libraryTargets ) ,
555581 /*prefixes*/ [ copyright ] ,
556582 /*useBuiltCompiler*/ true ,
557583 { noOutFile : false , generateDeclarations : true } ) ;
@@ -560,9 +586,19 @@ compileFile(
560586desc ( "Builds language service server library" ) ;
561587task ( "lssl" , [ tsserverLibraryFile , tsserverLibraryDefinitionFile ] ) ;
562588
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+
563599// Local target to build the compiler and services
564600desc ( "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" ] ) ;
566602
567603// Local target to build only tsc.js
568604desc ( "Builds only the compiler" ) ;
@@ -617,7 +653,7 @@ task("generate-spec", [specMd]);
617653
618654// Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory
619655desc ( "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 ( ) {
621657 var expectedFiles = [ tscFile , servicesFile , serverFile , nodePackageFile , nodeDefinitionsFile , standaloneDefinitionsFile , tsserverLibraryFile , tsserverLibraryDefinitionFile ] . concat ( libraryTargets ) ;
622658 var missingFiles = expectedFiles . filter ( function ( f ) {
623659 return ! fs . existsSync ( f ) ;
@@ -758,6 +794,7 @@ function runConsoleTests(defaultReporter, runInParallel) {
758794 // timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
759795 // default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
760796 if ( ! runInParallel ) {
797+ var startTime = mark ( ) ;
761798 tests = tests ? ' -g "' + tests + '"' : '' ;
762799 var cmd = "mocha" + ( debug ? " --debug-brk" : "" ) + " -R " + reporter + tests + colors + bail + ' -t ' + testTimeout + ' ' + run ;
763800 console . log ( cmd ) ;
@@ -766,20 +803,23 @@ function runConsoleTests(defaultReporter, runInParallel) {
766803 process . env . NODE_ENV = "development" ;
767804 exec ( cmd , function ( ) {
768805 process . env . NODE_ENV = savedNodeEnv ;
806+ measure ( startTime ) ;
769807 runLinter ( ) ;
770808 finish ( ) ;
771809 } , function ( e , status ) {
772810 process . env . NODE_ENV = savedNodeEnv ;
811+ measure ( startTime ) ;
773812 finish ( status ) ;
774813 } ) ;
775814
776815 }
777816 else {
778817 var savedNodeEnv = process . env . NODE_ENV ;
779818 process . env . NODE_ENV = "development" ;
819+ var startTime = mark ( ) ;
780820 runTestsInParallel ( taskConfigsFolder , run , { testTimeout : testTimeout , noColors : colors === " --no-colors " } , function ( err ) {
781821 process . env . NODE_ENV = savedNodeEnv ;
782-
822+ measure ( startTime ) ;
783823 // last worker clean everything and runs linter in case if there were no errors
784824 deleteTemporaryProjectOutput ( ) ;
785825 jake . rmRf ( taskConfigsFolder ) ;
@@ -998,12 +1038,22 @@ var tslintRulesOutFiles = tslintRules.map(function(p) {
9981038 return path . join ( builtLocalDirectory , "tslint" , p + ".js" ) ;
9991039} ) ;
10001040desc ( "Compiles tslint rules to js" ) ;
1001- task ( "build-rules" , tslintRulesOutFiles ) ;
1041+ task ( "build-rules" , [ "build-rules-start" ] . concat ( tslintRulesOutFiles ) . concat ( [ "build-rules-end" ] ) ) ;
10021042tslintRulesFiles . forEach ( function ( ruleFile , i ) {
10031043 compileFile ( tslintRulesOutFiles [ i ] , [ ruleFile ] , [ ruleFile ] , [ ] , /*useBuiltCompiler*/ false ,
10041044 { noOutFile : true , generateDeclarations : false , outDir : path . join ( builtLocalDirectory , "tslint" ) } ) ;
10051045} ) ;
10061046
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+
10071057function getLinterOptions ( ) {
10081058 return {
10091059 configuration : require ( "./tslint.json" ) ,
@@ -1047,6 +1097,8 @@ var lintTargets = compilerSources
10471097
10481098desc ( "Runs tslint on the compiler sources. Optional arguments are: f[iles]=regex" ) ;
10491099task ( "lint" , [ "build-rules" ] , function ( ) {
1100+ if ( fold . isTravis ( ) ) console . log ( fold . start ( "lint" ) ) ;
1101+ var startTime = mark ( ) ;
10501102 var lintOptions = getLinterOptions ( ) ;
10511103 var failed = 0 ;
10521104 var fileMatcher = RegExp ( process . env . f || process . env . file || process . env . files || "" ) ;
@@ -1062,6 +1114,8 @@ task("lint", ["build-rules"], function() {
10621114 done [ target ] = true ;
10631115 }
10641116 }
1117+ measure ( startTime ) ;
1118+ if ( fold . isTravis ( ) ) console . log ( fold . end ( "lint" ) ) ;
10651119 if ( failed > 0 ) {
10661120 fail ( 'Linter errors.' , failed ) ;
10671121 }
0 commit comments