@@ -21,10 +21,6 @@ namespace RWC {
21
21
}
22
22
}
23
23
24
- function isTsConfigFile ( file : { path : string } ) : boolean {
25
- return file . path . indexOf ( "tsconfig" ) !== - 1 && file . path . indexOf ( "json" ) !== - 1 ;
26
- }
27
-
28
24
export function runRWCTest ( jsonPath : string ) {
29
25
describe ( "Testing a rwc project: " + jsonPath , ( ) => {
30
26
let inputFiles : Harness . Compiler . TestFile [ ] = [ ] ;
@@ -69,11 +65,10 @@ namespace RWC {
69
65
// we will set noEmitOnError flag to be false.
70
66
opts . options . noEmitOnError = false ;
71
67
} ) ;
68
+ let fileNames = opts . fileNames ;
72
69
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 ) ;
77
72
if ( tsconfigFile ) {
78
73
const tsconfigFileContents = getHarnessCompilerInputUnit ( tsconfigFile . path ) ;
79
74
tsconfigFiles . push ( { unitName : tsconfigFile . path , content : tsconfigFileContents . content } ) ;
@@ -103,55 +98,40 @@ namespace RWC {
103
98
}
104
99
105
100
// Add files to compilation
106
- const isInInputList = ( resolvedPath : string ) => ( inputFile : { unitName : string ; content : string ; } ) => inputFile . unitName === resolvedPath ;
107
101
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 ) ;
120
105
otherFiles . push ( getHarnessCompilerInputUnit ( fileRead . path ) ) ;
121
106
}
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 ) ) ;
137
115
}
138
116
}
117
+ } ) ;
139
118
119
+ if ( useCustomLibraryFile ) {
140
120
// do not use lib since we already read it in above
141
121
opts . options . lib = undefined ;
142
122
opts . options . noLib = true ;
123
+ }
143
124
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 ;
155
135
156
136
function getHarnessCompilerInputUnit ( fileName : string ) : Harness . Compiler . TestFile {
157
137
const unitName = ts . normalizeSlashes ( Harness . IO . resolvePath ( fileName ) ) ;
0 commit comments