11// This file contains the build logic for the public repo
2+ // @ts -check
23
34var fs = require ( "fs" ) ;
45var os = require ( "os" ) ;
56var path = require ( "path" ) ;
67var child_process = require ( "child_process" ) ;
78var fold = require ( "travis-fold" ) ;
8- var runTestsInParallel = require ( "./scripts/mocha-parallel" ) . runTestsInParallel ;
99var ts = require ( "./lib/typescript" ) ;
1010
1111
@@ -38,7 +38,7 @@ else if (process.env.PATH !== undefined) {
3838
3939function filesFromConfig ( configPath ) {
4040 var configText = fs . readFileSync ( configPath ) . toString ( ) ;
41- var config = ts . parseConfigFileTextToJson ( configPath , configText , /*stripComments*/ true ) ;
41+ var config = ts . parseConfigFileTextToJson ( configPath , configText ) ;
4242 if ( config . error ) {
4343 throw new Error ( diagnosticsToString ( [ config . error ] ) ) ;
4444 }
@@ -104,6 +104,9 @@ var harnessCoreSources = [
104104 "loggedIO.ts" ,
105105 "rwcRunner.ts" ,
106106 "test262Runner.ts" ,
107+ "./parallel/shared.ts" ,
108+ "./parallel/host.ts" ,
109+ "./parallel/worker.ts" ,
107110 "runner.ts"
108111] . map ( function ( f ) {
109112 return path . join ( harnessDirectory , f ) ;
@@ -596,7 +599,7 @@ file(typesMapOutputPath, function() {
596599 var content = fs . readFileSync ( path . join ( serverDirectory , 'typesMap.json' ) ) ;
597600 // Validate that it's valid JSON
598601 try {
599- JSON . parse ( content ) ;
602+ JSON . parse ( content . toString ( ) ) ;
600603 } catch ( e ) {
601604 console . log ( "Parse error in typesMap.json: " + e ) ;
602605 }
@@ -740,7 +743,7 @@ desc("Builds the test infrastructure using the built compiler");
740743task ( "tests" , [ "local" , run ] . concat ( libraryTargets ) ) ;
741744
742745function exec ( cmd , completeHandler , errorHandler ) {
743- var ex = jake . createExec ( [ cmd ] , { windowsVerbatimArguments : true } ) ;
746+ var ex = jake . createExec ( [ cmd ] , { windowsVerbatimArguments : true , interactive : true } ) ;
744747 // Add listeners for output and error
745748 ex . addListener ( "stdout" , function ( output ) {
746749 process . stdout . write ( output ) ;
@@ -766,15 +769,16 @@ function exec(cmd, completeHandler, errorHandler) {
766769 ex . run ( ) ;
767770}
768771
772+ const del = require ( "del" ) ;
769773function cleanTestDirs ( ) {
770774 // Clean the local baselines directory
771775 if ( fs . existsSync ( localBaseline ) ) {
772- jake . rmRf ( localBaseline ) ;
776+ del . sync ( localBaseline ) ;
773777 }
774778
775779 // Clean the local Rwc baselines directory
776780 if ( fs . existsSync ( localRwcBaseline ) ) {
777- jake . rmRf ( localRwcBaseline ) ;
781+ del . sync ( localRwcBaseline ) ;
778782 }
779783
780784 jake . mkdirP ( localRwcBaseline ) ;
@@ -783,13 +787,14 @@ function cleanTestDirs() {
783787}
784788
785789// 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 ) {
787791 var testConfigContents = JSON . stringify ( {
788792 test : tests ? [ tests ] : undefined ,
789793 light : light ,
790794 workerCount : workerCount ,
791795 taskConfigsFolder : taskConfigsFolder ,
792- stackTraceLimit : stackTraceLimit
796+ stackTraceLimit : stackTraceLimit ,
797+ noColor : ! colors
793798 } ) ;
794799 fs . writeFileSync ( 'test.config' , testConfigContents ) ;
795800}
@@ -831,7 +836,7 @@ function runConsoleTests(defaultReporter, runInParallel) {
831836 }
832837
833838 if ( tests || light || taskConfigsFolder ) {
834- writeTestConfigFile ( tests , light , taskConfigsFolder , workerCount , stackTraceLimit ) ;
839+ writeTestConfigFile ( tests , light , taskConfigsFolder , workerCount , stackTraceLimit , colors ) ;
835840 }
836841
837842 if ( tests && tests . toLocaleLowerCase ( ) === "rwc" ) {
@@ -894,19 +899,15 @@ function runConsoleTests(defaultReporter, runInParallel) {
894899 var savedNodeEnv = process . env . NODE_ENV ;
895900 process . env . NODE_ENV = "development" ;
896901 var startTime = mark ( ) ;
897- runTestsInParallel ( taskConfigsFolder , run , { testTimeout : testTimeout , noColors : ! colors } , function ( err ) {
902+ exec ( host + " " + run , function ( ) {
898903 process . env . NODE_ENV = savedNodeEnv ;
899904 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 ) ;
910911 } ) ;
911912 }
912913
@@ -969,8 +970,8 @@ desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is
969970task ( "runtests-browser" , [ "browserify" , nodeServerOutFile ] , function ( ) {
970971 cleanTestDirs ( ) ;
971972 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 ;
974975 var light = process . env . light || false ;
975976 var testConfigFile = 'test.config' ;
976977 if ( fs . existsSync ( testConfigFile ) ) {
@@ -1042,6 +1043,7 @@ function acceptBaseline(sourceFolder, targetFolder) {
10421043 if ( fs . existsSync ( target ) ) {
10431044 fs . unlinkSync ( target ) ;
10441045 }
1046+ jake . mkdirP ( path . dirname ( target ) ) ;
10451047 fs . renameSync ( path . join ( sourceFolder , filename ) , target ) ;
10461048 }
10471049 }
0 commit comments