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 ) ;
@@ -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
}
0 commit comments