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