22/// <reference path="runnerbase.ts" />
33class DefinitelyTypedRunner extends RunnerBase {
44 private static readonly testDir = "../DefinitelyTyped/types/" ;
5+
6+ public workingDirectory = DefinitelyTypedRunner . testDir ;
7+
58 public enumerateTestFiles ( ) {
6- return Harness . IO . getDirectories ( DefinitelyTypedRunner . testDir ) . map ( dir => DefinitelyTypedRunner . testDir + dir ) ;
9+ return Harness . IO . getDirectories ( DefinitelyTypedRunner . testDir ) ;
710 }
811
912 public kind ( ) : TestRunnerKind {
@@ -28,16 +31,19 @@ class DefinitelyTypedRunner extends RunnerBase {
2831 describe ( directoryName , ( ) => {
2932 const cp = require ( "child_process" ) ;
3033 const path = require ( "path" ) ;
34+ const fs = require ( "fs" ) ;
3135
3236 it ( "should build successfully" , ( ) => {
33- const cwd = path . join ( __dirname , "../../" , directoryName ) ;
37+ const cwd = path . join ( __dirname , "../../" , DefinitelyTypedRunner . testDir , directoryName ) ;
3438 const timeout = 600000 ; // 600s = 10 minutes
35- const stdio = isWorker ? "pipe" : "inherit" ;
36- const install = cp . spawnSync ( `npm` , [ "i" ] , { cwd, timeout, shell : true , stdio } ) ;
37- if ( install . status !== 0 ) throw new Error ( `NPM Install for ${ directoryName } failed!` ) ;
39+ if ( fs . existsSync ( path . join ( cwd , 'package.json' ) ) ) {
40+ const stdio = isWorker ? "pipe" : "inherit" ;
41+ const install = cp . spawnSync ( `npm` , [ "i" ] , { cwd, timeout, shell : true , stdio } ) ;
42+ if ( install . status !== 0 ) throw new Error ( `NPM Install for ${ directoryName } failed!` ) ;
43+ }
3844 Harness . Baseline . runBaseline ( `${ this . kind ( ) } /${ directoryName } .log` , ( ) => {
39- const result = cp . spawnSync ( `node` , [ path . join ( __dirname , "tsc.js" ) , "--lib dom,es6" , "--strict" ] , { cwd, timeout, shell : true } ) ;
40- return `Exit Code: ${ result . status }
45+ const result = cp . spawnSync ( `node` , [ path . join ( __dirname , "tsc.js" ) ] , { cwd, timeout, shell : true } ) ;
46+ return result . status === 0 ? null : `Exit Code: ${ result . status }
4147Standard output:
4248${ result . stdout . toString ( ) . replace ( / \r \n / g, "\n" ) }
4349
0 commit comments