@@ -9,6 +9,10 @@ interface ExecResult {
9
9
status : number ;
10
10
}
11
11
12
+ interface UserConfig {
13
+ types : string [ ] ;
14
+ }
15
+
12
16
abstract class ExternalCompileRunnerBase extends RunnerBase {
13
17
abstract testDir : string ;
14
18
abstract report ( result : ExecResult , cwd : string ) : string ;
@@ -33,18 +37,34 @@ abstract class ExternalCompileRunnerBase extends RunnerBase {
33
37
const cp = require ( "child_process" ) ;
34
38
35
39
it ( "should build successfully" , ( ) => {
36
- const cwd = path . join ( __dirname , "../../" , this . testDir , directoryName ) ;
40
+ let cwd = path . join ( __dirname , "../../" , this . testDir , directoryName ) ;
37
41
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 , "Git is the only reason for using test.json right now" ) ;
50
+ types = config . types ;
51
+
52
+ cwd = path . join ( cwd , directoryName ) ;
53
+ }
38
54
if ( fs . existsSync ( path . join ( cwd , "package.json" ) ) ) {
39
55
if ( fs . existsSync ( path . join ( cwd , "package-lock.json" ) ) ) {
40
56
fs . unlinkSync ( path . join ( cwd , "package-lock.json" ) ) ;
41
57
}
42
- const stdio = isWorker ? "pipe" : "inherit" ;
43
58
const install = cp . spawnSync ( `npm` , [ "i" ] , { cwd, timeout, shell : true , stdio } ) ;
44
59
if ( install . status !== 0 ) throw new Error ( `NPM Install for ${ directoryName } failed!` ) ;
45
60
}
61
+ const args = [ path . join ( __dirname , "tsc.js" ) ] ;
62
+ if ( types ) {
63
+ args . push ( "--types" , types . join ( "," ) ) ;
64
+ }
65
+ args . push ( "--noEmit" ) ;
46
66
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 ) ;
48
68
} ) ;
49
69
} ) ;
50
70
} ) ;
0 commit comments