@@ -21,10 +21,6 @@ namespace RWC {
2121 }
2222 }
2323
24- function isTsConfigFile ( file : { path : string } ) : boolean {
25- return file . path . indexOf ( "tsconfig" ) !== - 1 && file . path . indexOf ( "json" ) !== - 1 ;
26- }
27-
2824 export function runRWCTest ( jsonPath : string ) {
2925 describe ( "Testing a rwc project: " + jsonPath , ( ) => {
3026 let inputFiles : Harness . Compiler . TestFile [ ] = [ ] ;
@@ -69,11 +65,10 @@ namespace RWC {
6965 // we will set noEmitOnError flag to be false.
7066 opts . options . noEmitOnError = false ;
7167 } ) ;
68+ let fileNames = opts . fileNames ;
7269
73- runWithIOLog ( ioLog , oldIO => {
74- let fileNames = opts . fileNames ;
75-
76- const tsconfigFile = ts . forEach ( ioLog . filesRead , f => isTsConfigFile ( f ) ? f : undefined ) ;
70+ runWithIOLog ( ioLog , ( ) => {
71+ const tsconfigFile = ts . forEach ( ioLog . filesRead , f => vpath . isTsConfigFile ( f . path ) ? f : undefined ) ;
7772 if ( tsconfigFile ) {
7873 const tsconfigFileContents = getHarnessCompilerInputUnit ( tsconfigFile . path ) ;
7974 tsconfigFiles . push ( { unitName : tsconfigFile . path , content : tsconfigFileContents . content } ) ;
@@ -103,55 +98,40 @@ namespace RWC {
10398 }
10499
105100 // Add files to compilation
106- const isInInputList = ( resolvedPath : string ) => ( inputFile : { unitName : string ; content : string ; } ) => inputFile . unitName === resolvedPath ;
107101 for ( const fileRead of ioLog . filesRead ) {
108- // Check if the file is already added into the set of input files.
109- const resolvedPath = ts . normalizeSlashes ( Harness . IO . resolvePath ( fileRead . path ) ) ;
110- const inInputList = ts . forEach ( inputFiles , isInInputList ( resolvedPath ) ) ;
111-
112- if ( isTsConfigFile ( fileRead ) ) {
113- continue ;
114- }
115-
116- if ( ! Harness . isDefaultLibraryFile ( fileRead . path ) ) {
117- if ( inInputList ) {
118- continue ;
119- }
102+ const normalized = ts . normalizeSlashes ( fileRead . path ) ;
103+ if ( ! uniqueNames . has ( normalized ) && ! Harness . isDefaultLibraryFile ( fileRead . path ) ) {
104+ uniqueNames . set ( normalized , true ) ;
120105 otherFiles . push ( getHarnessCompilerInputUnit ( fileRead . path ) ) ;
121106 }
122- else if ( ! opts . options . noLib && Harness . isDefaultLibraryFile ( fileRead . path ) ) {
123- if ( ! inInputList ) {
124- // If useCustomLibraryFile is true, we will use lib.d.ts from json object
125- // otherwise use the lib.d.ts from built/local
126- // Majority of RWC code will be using built/local/lib.d.ts instead of
127- // lib.d.ts inside json file. However, some RWC cases will still use
128- // their own version of lib.d.ts because they have customized lib.d.ts
129- if ( useCustomLibraryFile ) {
130- inputFiles . push ( getHarnessCompilerInputUnit ( fileRead . path ) ) ;
131- }
132- else {
133- // set the flag to put default library to the beginning of the list
134- inputFiles . unshift ( Harness . getDefaultLibraryFile ( fileRead . path , oldIO ) ) ;
135- }
136- }
107+ else if ( ! opts . options . noLib && Harness . isDefaultLibraryFile ( fileRead . path ) && ! uniqueNames . has ( normalized ) && useCustomLibraryFile ) {
108+ // If useCustomLibraryFile is true, we will use lib.d.ts from json object
109+ // otherwise use the lib.d.ts from built/local
110+ // Majority of RWC code will be using built/local/lib.d.ts instead of
111+ // lib.d.ts inside json file. However, some RWC cases will still use
112+ // their own version of lib.d.ts because they have customized lib.d.ts
113+ uniqueNames . set ( normalized , true ) ;
114+ inputFiles . push ( getHarnessCompilerInputUnit ( fileRead . path ) ) ;
137115 }
138116 }
117+ } ) ;
139118
119+ if ( useCustomLibraryFile ) {
140120 // do not use lib since we already read it in above
141121 opts . options . lib = undefined ;
142122 opts . options . noLib = true ;
123+ }
143124
144- // Emit the results
145- compilerResult = Harness . Compiler . compileFiles (
146- inputFiles ,
147- otherFiles ,
148- /* harnessOptions */ undefined ,
149- opts . options ,
150- // Since each RWC json file specifies its current directory in its json file, we need
151- // to pass this information in explicitly instead of acquiring it from the process.
152- currentDirectory ) ;
153- compilerOptions = compilerResult . options ;
154- } ) ;
125+ // Emit the results
126+ compilerResult = Harness . Compiler . compileFiles (
127+ inputFiles ,
128+ otherFiles ,
129+ /* harnessOptions */ undefined ,
130+ opts . options ,
131+ // Since each RWC json file specifies its current directory in its json file, we need
132+ // to pass this information in explicitly instead of acquiring it from the process.
133+ currentDirectory ) ;
134+ compilerOptions = compilerResult . options ;
155135
156136 function getHarnessCompilerInputUnit ( fileName : string ) : Harness . Compiler . TestFile {
157137 const unitName = ts . normalizeSlashes ( Harness . IO . resolvePath ( fileName ) ) ;
0 commit comments