@@ -9,6 +9,10 @@ interface ExecResult {
99 status : number ;
1010}
1111
12+ interface UserConfig {
13+ types : string [ ] ;
14+ }
15+
1216abstract class ExternalCompileRunnerBase extends RunnerBase {
1317 abstract testDir : string ;
1418 abstract report ( result : ExecResult , cwd : string ) : string ;
@@ -33,18 +37,34 @@ abstract class ExternalCompileRunnerBase extends RunnerBase {
3337 const cp = require ( "child_process" ) ;
3438
3539 it ( "should build successfully" , ( ) => {
36- const cwd = path . join ( __dirname , "../../" , this . testDir , directoryName ) ;
40+ let cwd = path . join ( __dirname , "../../" , this . testDir , directoryName ) ;
3741 const timeout = 600000 ; // 600s = 10 minutes
42+ const stdio = isWorker ? "pipe" : "inherit" ;
43+ let types : string [ ] ;
44+ if ( fs . existsSync ( path . join ( cwd , "test.json" ) ) ) {
45+ const update = cp . spawnSync ( "git" , [ "submodule" , "update" , "--remote" ] , { cwd, timeout, shell : true , stdio } ) ;
46+ if ( update . status !== 0 ) throw new Error ( `git submodule update for ${ directoryName } failed!` ) ;
47+
48+ const config = JSON . parse ( fs . readFileSync ( path . join ( cwd , "test.json" ) , { encoding : "utf8" } ) ) as UserConfig ;
49+ ts . Debug . assert ( ! ! config . types , "Bad format from test.json: Types field must be present." ) ;
50+ types = config . types ;
51+
52+ cwd = path . join ( cwd , directoryName ) ;
53+ }
3854 if ( fs . existsSync ( path . join ( cwd , "package.json" ) ) ) {
3955 if ( fs . existsSync ( path . join ( cwd , "package-lock.json" ) ) ) {
4056 fs . unlinkSync ( path . join ( cwd , "package-lock.json" ) ) ;
4157 }
42- const stdio = isWorker ? "pipe" : "inherit" ;
4358 const install = cp . spawnSync ( `npm` , [ "i" ] , { cwd, timeout, shell : true , stdio } ) ;
4459 if ( install . status !== 0 ) throw new Error ( `NPM Install for ${ directoryName } failed!` ) ;
4560 }
61+ const args = [ path . join ( __dirname , "tsc.js" ) ] ;
62+ if ( types ) {
63+ args . push ( "--types" , types . join ( "," ) ) ;
64+ }
65+ args . push ( "--noEmit" ) ;
4666 Harness . Baseline . runBaseline ( `${ this . kind ( ) } /${ directoryName } .log` , ( ) => {
47- return this . report ( cp . spawnSync ( `node` , [ path . join ( __dirname , "tsc.js" ) ] , { cwd, timeout, shell : true } ) , cwd ) ;
67+ return this . report ( cp . spawnSync ( `node` , args , { cwd, timeout, shell : true } ) , cwd ) ;
4868 } ) ;
4969 } ) ;
5070 } ) ;
0 commit comments