@@ -13,6 +13,7 @@ import {
1313} from "./_namespaces/Harness" ;
1414import * as ts from "./_namespaces/ts" ;
1515import * as Utils from "./_namespaces/Utils" ;
16+ import * as vfs from "./_namespaces/vfs" ;
1617import * as vpath from "./_namespaces/vpath" ;
1718
1819export const enum CompilerTestType {
@@ -91,11 +92,12 @@ export class CompilerBaselineRunner extends RunnerBase {
9192 let compilerTest ! : CompilerTest ;
9293 before ( ( ) => {
9394 let payload ;
95+ let rootDir = ts . combinePaths ( vfs . srcFolder , fileName . indexOf ( "conformance" ) === - 1 ? "tests/cases/compiler/" : ts . getDirectoryPath ( fileName ) + "/" ) ;
9496 if ( test && test . content ) {
95- const rootDir = test . file . indexOf ( "conformance" ) === - 1 ? "tests/cases/compiler/" : ts . getDirectoryPath ( test . file ) + "/" ;
97+ rootDir = ts . combinePaths ( vfs . srcFolder , test . file . indexOf ( "conformance" ) === - 1 ? "tests/cases/compiler/" : ts . getDirectoryPath ( test . file ) + "/" ) ;
9698 payload = TestCaseParser . makeUnitsFromTest ( test . content , test . file , rootDir ) ;
9799 }
98- compilerTest = new CompilerTest ( fileName , payload , configuration ) ;
100+ compilerTest = new CompilerTest ( fileName , rootDir , payload , configuration ) ;
99101 } ) ;
100102 it ( `Correct errors for ${ fileName } ` , ( ) => compilerTest . verifyDiagnostics ( ) ) ;
101103 it ( `Correct module resolution tracing for ${ fileName } ` , ( ) => compilerTest . verifyModuleResolution ( ) ) ;
@@ -167,7 +169,6 @@ class CompilerTest {
167169 private fileName : string ;
168170 private justName : string ;
169171 private configuredName : string ;
170- private lastUnit : TestCaseParser . TestUnitData ;
171172 private harnessSettings : TestCaseParser . CompilerSettings ;
172173 private hasNonDtsFiles : boolean ;
173174 private result : compiler . CompilationResult ;
@@ -178,7 +179,7 @@ class CompilerTest {
178179 // equivalent to other files on the file system not directly passed to the compiler (ie things that are referenced by other files)
179180 private otherFiles : Compiler . TestFile [ ] ;
180181
181- constructor ( fileName : string , testCaseContent ?: TestCaseParser . TestCaseContent , configurationOverrides ?: TestCaseParser . CompilerSettings ) {
182+ constructor ( fileName : string , rootDir : string , testCaseContent ?: TestCaseParser . TestCaseContent , configurationOverrides ?: TestCaseParser . CompilerSettings ) {
182183 this . fileName = fileName ;
183184 this . justName = vpath . basename ( fileName ) ;
184185 this . configuredName = this . justName ;
@@ -200,8 +201,6 @@ class CompilerTest {
200201 }
201202 }
202203
203- const rootDir = fileName . indexOf ( "conformance" ) === - 1 ? "tests/cases/compiler/" : ts . getDirectoryPath ( fileName ) + "/" ;
204-
205204 if ( testCaseContent === undefined ) {
206205 testCaseContent = TestCaseParser . makeUnitsFromTest ( IO . readFile ( fileName ) ! , fileName , rootDir ) ;
207206 }
@@ -211,43 +210,48 @@ class CompilerTest {
211210 }
212211
213212 const units = testCaseContent . testUnitData ;
213+ this . toBeCompiled = [ ] ;
214+ this . otherFiles = [ ] ;
215+ this . hasNonDtsFiles = units . some ( unit => ! ts . fileExtensionIs ( unit . name , ts . Extension . Dts ) ) ;
214216 this . harnessSettings = testCaseContent . settings ;
215217 let tsConfigOptions : ts . CompilerOptions | undefined ;
216218 this . tsConfigFiles = [ ] ;
217219 if ( testCaseContent . tsConfig ) {
218- assert . equal ( testCaseContent . tsConfig . fileNames . length , 0 , `list of files in tsconfig is not currently supported` ) ;
219- assert . equal ( testCaseContent . tsConfig . raw . exclude , undefined , `exclude in tsconfig is not currently supported` ) ;
220-
221220 tsConfigOptions = ts . cloneCompilerOptions ( testCaseContent . tsConfig . options ) ;
222- this . tsConfigFiles . push ( this . createHarnessTestFile ( testCaseContent . tsConfigFileUnitData ! , rootDir , ts . combinePaths ( rootDir , tsConfigOptions . configFilePath ) ) ) ;
221+ this . tsConfigFiles . push ( this . createHarnessTestFile ( testCaseContent . tsConfigFileUnitData ! , rootDir , tsConfigOptions . configFilePath ) ) ;
222+ for ( const unit of units ) {
223+ if ( testCaseContent . tsConfig . fileNames . includes ( ts . getNormalizedAbsolutePath ( unit . name , rootDir ) ) ) {
224+ this . toBeCompiled . push ( this . createHarnessTestFile ( unit , rootDir ) ) ;
225+ }
226+ else {
227+ this . otherFiles . push ( this . createHarnessTestFile ( unit , rootDir ) ) ;
228+ }
229+ }
223230 }
224231 else {
225232 const baseUrl = this . harnessSettings . baseUrl ;
226233 if ( baseUrl !== undefined && ! ts . isRootedDiskPath ( baseUrl ) ) {
227234 this . harnessSettings . baseUrl = ts . getNormalizedAbsolutePath ( baseUrl , rootDir ) ;
228235 }
229- }
230-
231- this . lastUnit = units [ units . length - 1 ] ;
232- this . hasNonDtsFiles = units . some ( unit => ! ts . fileExtensionIs ( unit . name , ts . Extension . Dts ) ) ;
233- // We need to assemble the list of input files for the compiler and other related files on the 'filesystem' (ie in a multi-file test)
234- // If the last file in a test uses require or a triple slash reference we'll assume all other files will be brought in via references,
235- // otherwise, assume all files are just meant to be in the same compilation session without explicit references to one another.
236- this . toBeCompiled = [ ] ;
237- this . otherFiles = [ ] ;
238236
239- if ( testCaseContent . settings . noImplicitReferences || / r e q u i r e \( / . test ( this . lastUnit . content ) || / r e f e r e n c e \s p a t h / . test ( this . lastUnit . content ) ) {
240- this . toBeCompiled . push ( this . createHarnessTestFile ( this . lastUnit , rootDir ) ) ;
241- units . forEach ( unit => {
242- if ( unit . name !== this . lastUnit . name ) {
243- this . otherFiles . push ( this . createHarnessTestFile ( unit , rootDir ) ) ;
244- }
245- } ) ;
246- }
247- else {
248- this . toBeCompiled = units . map ( unit => {
249- return this . createHarnessTestFile ( unit , rootDir ) ;
250- } ) ;
237+ const lastUnit = units [ units . length - 1 ] ;
238+ // We need to assemble the list of input files for the compiler and other related files on the 'filesystem' (ie in a multi-file test)
239+ // If the last file in a test uses require or a triple slash reference we'll assume all other files will be brought in via references,
240+ // otherwise, assume all files are just meant to be in the same compilation session without explicit references to one another.
241+
242+ if ( testCaseContent . settings . noImplicitReferences || / r e q u i r e \( / . test ( lastUnit . content ) || / r e f e r e n c e \s p a t h / . test ( lastUnit . content ) ) {
243+ this . toBeCompiled . push ( this . createHarnessTestFile ( lastUnit , rootDir ) ) ;
244+ units . forEach ( unit => {
245+ if ( unit . name !== lastUnit . name ) {
246+ this . otherFiles . push ( this . createHarnessTestFile ( unit , rootDir ) ) ;
247+ }
248+ } ) ;
249+ }
250+ else {
251+ this . toBeCompiled = units . map ( unit => {
252+ return this . createHarnessTestFile ( unit , rootDir ) ;
253+ } ) ;
254+ }
251255 }
252256
253257 if ( tsConfigOptions && tsConfigOptions . configFilePath !== undefined ) {
0 commit comments