1
1
// This file contains the build logic for the public repo
2
+ // @ts -check
2
3
3
4
var fs = require ( "fs" ) ;
4
5
var os = require ( "os" ) ;
5
6
var path = require ( "path" ) ;
6
7
var child_process = require ( "child_process" ) ;
7
8
var fold = require ( "travis-fold" ) ;
8
- var runTestsInParallel = require ( "./scripts/mocha-parallel" ) . runTestsInParallel ;
9
9
var ts = require ( "./lib/typescript" ) ;
10
10
11
11
@@ -38,7 +38,7 @@ else if (process.env.PATH !== undefined) {
38
38
39
39
function filesFromConfig ( configPath ) {
40
40
var configText = fs . readFileSync ( configPath ) . toString ( ) ;
41
- var config = ts . parseConfigFileTextToJson ( configPath , configText , /*stripComments*/ true ) ;
41
+ var config = ts . parseConfigFileTextToJson ( configPath , configText ) ;
42
42
if ( config . error ) {
43
43
throw new Error ( diagnosticsToString ( [ config . error ] ) ) ;
44
44
}
@@ -105,6 +105,9 @@ var harnessCoreSources = [
105
105
"loggedIO.ts" ,
106
106
"rwcRunner.ts" ,
107
107
"test262Runner.ts" ,
108
+ "./parallel/shared.ts" ,
109
+ "./parallel/host.ts" ,
110
+ "./parallel/worker.ts" ,
108
111
"runner.ts"
109
112
] . map ( function ( f ) {
110
113
return path . join ( harnessDirectory , f ) ;
@@ -596,7 +599,7 @@ file(typesMapOutputPath, function() {
596
599
var content = fs . readFileSync ( path . join ( serverDirectory , 'typesMap.json' ) ) ;
597
600
// Validate that it's valid JSON
598
601
try {
599
- JSON . parse ( content ) ;
602
+ JSON . parse ( content . toString ( ) ) ;
600
603
} catch ( e ) {
601
604
console . log ( "Parse error in typesMap.json: " + e ) ;
602
605
}
@@ -740,7 +743,7 @@ desc("Builds the test infrastructure using the built compiler");
740
743
task ( "tests" , [ "local" , run ] . concat ( libraryTargets ) ) ;
741
744
742
745
function exec ( cmd , completeHandler , errorHandler ) {
743
- var ex = jake . createExec ( [ cmd ] , { windowsVerbatimArguments : true } ) ;
746
+ var ex = jake . createExec ( [ cmd ] , { windowsVerbatimArguments : true , interactive : true } ) ;
744
747
// Add listeners for output and error
745
748
ex . addListener ( "stdout" , function ( output ) {
746
749
process . stdout . write ( output ) ;
@@ -766,15 +769,16 @@ function exec(cmd, completeHandler, errorHandler) {
766
769
ex . run ( ) ;
767
770
}
768
771
772
+ const del = require ( "del" ) ;
769
773
function cleanTestDirs ( ) {
770
774
// Clean the local baselines directory
771
775
if ( fs . existsSync ( localBaseline ) ) {
772
- jake . rmRf ( localBaseline ) ;
776
+ del . sync ( localBaseline ) ;
773
777
}
774
778
775
779
// Clean the local Rwc baselines directory
776
780
if ( fs . existsSync ( localRwcBaseline ) ) {
777
- jake . rmRf ( localRwcBaseline ) ;
781
+ del . sync ( localRwcBaseline ) ;
778
782
}
779
783
780
784
jake . mkdirP ( localRwcBaseline ) ;
@@ -783,13 +787,14 @@ function cleanTestDirs() {
783
787
}
784
788
785
789
// used to pass data from jake command line directly to run.js
786
- function writeTestConfigFile ( tests , light , taskConfigsFolder , workerCount , stackTraceLimit ) {
790
+ function writeTestConfigFile ( tests , light , taskConfigsFolder , workerCount , stackTraceLimit , colors ) {
787
791
var testConfigContents = JSON . stringify ( {
788
792
test : tests ? [ tests ] : undefined ,
789
793
light : light ,
790
794
workerCount : workerCount ,
791
795
taskConfigsFolder : taskConfigsFolder ,
792
- stackTraceLimit : stackTraceLimit
796
+ stackTraceLimit : stackTraceLimit ,
797
+ noColor : ! colors
793
798
} ) ;
794
799
fs . writeFileSync ( 'test.config' , testConfigContents ) ;
795
800
}
@@ -831,7 +836,7 @@ function runConsoleTests(defaultReporter, runInParallel) {
831
836
}
832
837
833
838
if ( tests || light || taskConfigsFolder ) {
834
- writeTestConfigFile ( tests , light , taskConfigsFolder , workerCount , stackTraceLimit ) ;
839
+ writeTestConfigFile ( tests , light , taskConfigsFolder , workerCount , stackTraceLimit , colors ) ;
835
840
}
836
841
837
842
if ( tests && tests . toLocaleLowerCase ( ) === "rwc" ) {
@@ -894,19 +899,15 @@ function runConsoleTests(defaultReporter, runInParallel) {
894
899
var savedNodeEnv = process . env . NODE_ENV ;
895
900
process . env . NODE_ENV = "development" ;
896
901
var startTime = mark ( ) ;
897
- runTestsInParallel ( taskConfigsFolder , run , { testTimeout : testTimeout , noColors : ! colors } , function ( err ) {
902
+ exec ( host + " " + run , function ( ) {
898
903
process . env . NODE_ENV = savedNodeEnv ;
899
904
measure ( startTime ) ;
900
- // last worker clean everything and runs linter in case if there were no errors
901
- deleteTemporaryProjectOutput ( ) ;
902
- jake . rmRf ( taskConfigsFolder ) ;
903
- if ( err ) {
904
- fail ( err ) ;
905
- }
906
- else {
907
- runLinter ( ) ;
908
- complete ( ) ;
909
- }
905
+ runLinter ( ) ;
906
+ finish ( ) ;
907
+ } , function ( e , status ) {
908
+ process . env . NODE_ENV = savedNodeEnv ;
909
+ measure ( startTime ) ;
910
+ finish ( status ) ;
910
911
} ) ;
911
912
}
912
913
@@ -969,8 +970,8 @@ desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is
969
970
task ( "runtests-browser" , [ "browserify" , nodeServerOutFile ] , function ( ) {
970
971
cleanTestDirs ( ) ;
971
972
host = "node" ;
972
- browser = process . env . browser || process . env . b || ( os . platform ( ) === "linux" ? "chrome" : "IE" ) ;
973
- tests = process . env . test || process . env . tests || process . env . t ;
973
+ var browser = process . env . browser || process . env . b || ( os . platform ( ) === "linux" ? "chrome" : "IE" ) ;
974
+ var tests = process . env . test || process . env . tests || process . env . t ;
974
975
var light = process . env . light || false ;
975
976
var testConfigFile = 'test.config' ;
976
977
if ( fs . existsSync ( testConfigFile ) ) {
@@ -1042,6 +1043,7 @@ function acceptBaseline(sourceFolder, targetFolder) {
1042
1043
if ( fs . existsSync ( target ) ) {
1043
1044
fs . unlinkSync ( target ) ;
1044
1045
}
1046
+ jake . mkdirP ( path . dirname ( target ) ) ;
1045
1047
fs . renameSync ( path . join ( sourceFolder , filename ) , target ) ;
1046
1048
}
1047
1049
}
@@ -1119,7 +1121,7 @@ task("update-sublime", ["local", serverFile], function () {
1119
1121
jake . cpR ( serverFile + ".map" , "../TypeScript-Sublime-Plugin/tsserver/" ) ;
1120
1122
} ) ;
1121
1123
1122
- var tslintRuleDir = "scripts/tslint" ;
1124
+ var tslintRuleDir = "scripts/tslint/rules " ;
1123
1125
var tslintRules = [
1124
1126
"booleanTriviaRule" ,
1125
1127
"debugAssertRule" ,
@@ -1135,13 +1137,27 @@ var tslintRulesFiles = tslintRules.map(function (p) {
1135
1137
return path . join ( tslintRuleDir , p + ".ts" ) ;
1136
1138
} ) ;
1137
1139
var tslintRulesOutFiles = tslintRules . map ( function ( p ) {
1138
- return path . join ( builtLocalDirectory , "tslint" , p + ".js" ) ;
1140
+ return path . join ( builtLocalDirectory , "tslint/rules" , p + ".js" ) ;
1141
+ } ) ;
1142
+ var tslintFormattersDir = "scripts/tslint/formatters" ;
1143
+ var tslintFormatters = [
1144
+ "autolinkableStylishFormatter" ,
1145
+ ] ;
1146
+ var tslintFormatterFiles = tslintFormatters . map ( function ( p ) {
1147
+ return path . join ( tslintFormattersDir , p + ".ts" ) ;
1148
+ } ) ;
1149
+ var tslintFormattersOutFiles = tslintFormatters . map ( function ( p ) {
1150
+ return path . join ( builtLocalDirectory , "tslint/formatters" , p + ".js" ) ;
1139
1151
} ) ;
1140
1152
desc ( "Compiles tslint rules to js" ) ;
1141
- task ( "build-rules" , [ "build-rules-start" ] . concat ( tslintRulesOutFiles ) . concat ( [ "build-rules-end" ] ) ) ;
1153
+ task ( "build-rules" , [ "build-rules-start" ] . concat ( tslintRulesOutFiles ) . concat ( tslintFormattersOutFiles ) . concat ( [ "build-rules-end" ] ) ) ;
1142
1154
tslintRulesFiles . forEach ( function ( ruleFile , i ) {
1143
1155
compileFile ( tslintRulesOutFiles [ i ] , [ ruleFile ] , [ ruleFile ] , [ ] , /*useBuiltCompiler*/ false ,
1144
- { noOutFile : true , generateDeclarations : false , outDir : path . join ( builtLocalDirectory , "tslint" ) , lib : "es6" } ) ;
1156
+ { noOutFile : true , generateDeclarations : false , outDir : path . join ( builtLocalDirectory , "tslint/rules" ) , lib : "es6" } ) ;
1157
+ } ) ;
1158
+ tslintFormatterFiles . forEach ( function ( ruleFile , i ) {
1159
+ compileFile ( tslintFormattersOutFiles [ i ] , [ ruleFile ] , [ ruleFile ] , [ ] , /*useBuiltCompiler*/ false ,
1160
+ { noOutFile : true , generateDeclarations : false , outDir : path . join ( builtLocalDirectory , "tslint/formatters" ) , lib : "es6" } ) ;
1145
1161
} ) ;
1146
1162
1147
1163
desc ( "Emit the start of the build-rules fold" ) ;
@@ -1209,8 +1225,8 @@ task("lint", ["build-rules"], () => {
1209
1225
const fileMatcher = process . env . f || process . env . file || process . env . files ;
1210
1226
const files = fileMatcher
1211
1227
? `src/**/${ fileMatcher } `
1212
- : "Gulpfile.ts 'scripts/tslint/*.ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'" ;
1213
- const cmd = `node node_modules/tslint/bin/tslint ${ files } --format stylish ` ;
1228
+ : "Gulpfile.ts 'scripts/tslint/**/* .ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'" ;
1229
+ const cmd = `node node_modules/tslint/bin/tslint ${ files } --formatters-dir ./built/local/tslint/formatters -- format autolinkableStylish ` ;
1214
1230
console . log ( "Linting: " + cmd ) ;
1215
1231
jake . exec ( [ cmd ] , { interactive : true } , ( ) => {
1216
1232
if ( fold . isTravis ( ) ) console . log ( fold . end ( "lint" ) ) ;
0 commit comments