@@ -40,19 +40,18 @@ class CompilerBaselineRunner extends RunnerBase {
4040 this . basePath += "/" + this . testSuiteName ;
4141 }
4242
43+ private makeUnitName ( name : string , root : string ) {
44+ return ts . isRootedDiskPath ( name ) ? name : ts . combinePaths ( root , name ) ;
45+ } ;
46+
4347 public checkTestCodeOutput ( fileName : string ) {
4448 describe ( "compiler tests for " + fileName , ( ) => {
4549 // Mocha holds onto the closure environment of the describe callback even after the test is done.
4650 // Everything declared here should be cleared out in the "after" callback.
4751 let justName : string ;
48- let content : string ;
49- let testCaseContent : { settings : Harness . TestCaseParser . CompilerSettings ; testUnitData : Harness . TestCaseParser . TestUnitData [ ] ; } ;
50-
51- let units : Harness . TestCaseParser . TestUnitData [ ] ;
52- let harnessSettings : Harness . TestCaseParser . CompilerSettings ;
5352
5453 let lastUnit : Harness . TestCaseParser . TestUnitData ;
55- let rootDir : string ;
54+ let harnessSettings : Harness . TestCaseParser . CompilerSettings ;
5655
5756 let result : Harness . Compiler . CompilerResult ;
5857 let options : ts . CompilerOptions ;
@@ -63,28 +62,28 @@ class CompilerBaselineRunner extends RunnerBase {
6362
6463 before ( ( ) => {
6564 justName = fileName . replace ( / ^ .* [ \\ \/ ] / , "" ) ; // strips the fileName from the path.
66- content = Harness . IO . readFile ( fileName ) ;
67- testCaseContent = Harness . TestCaseParser . makeUnitsFromTest ( content , fileName ) ;
68- units = testCaseContent . testUnitData ;
65+ const content = Harness . IO . readFile ( fileName ) ;
66+ const testCaseContent = Harness . TestCaseParser . makeUnitsFromTest ( content , fileName ) ;
67+ const units = testCaseContent . testUnitData ;
6968 harnessSettings = testCaseContent . settings ;
7069 lastUnit = units [ units . length - 1 ] ;
71- rootDir = lastUnit . originalFilePath . indexOf ( "conformance" ) === - 1 ? "tests/cases/compiler/" : lastUnit . originalFilePath . substring ( 0 , lastUnit . originalFilePath . lastIndexOf ( "/" ) ) + "/" ;
70+ const rootDir = lastUnit . originalFilePath . indexOf ( "conformance" ) === - 1 ? "tests/cases/compiler/" : lastUnit . originalFilePath . substring ( 0 , lastUnit . originalFilePath . lastIndexOf ( "/" ) ) + "/" ;
7271 // 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)
7372 // 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,
7473 // otherwise, assume all files are just meant to be in the same compilation session without explicit references to one another.
7574 toBeCompiled = [ ] ;
7675 otherFiles = [ ] ;
7776 if ( / 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 ) ) {
78- toBeCompiled . push ( { unitName : ts . combinePaths ( rootDir , lastUnit . name ) , content : lastUnit . content } ) ;
77+ toBeCompiled . push ( { unitName : this . makeUnitName ( lastUnit . name , rootDir ) , content : lastUnit . content } ) ;
7978 units . forEach ( unit => {
8079 if ( unit . name !== lastUnit . name ) {
81- otherFiles . push ( { unitName : ts . combinePaths ( rootDir , unit . name ) , content : unit . content } ) ;
80+ otherFiles . push ( { unitName : this . makeUnitName ( unit . name , rootDir ) , content : unit . content } ) ;
8281 }
8382 } ) ;
8483 }
8584 else {
8685 toBeCompiled = units . map ( unit => {
87- return { unitName : ts . combinePaths ( rootDir , unit . name ) , content : unit . content } ;
86+ return { unitName : this . makeUnitName ( unit . name , rootDir ) , content : unit . content } ;
8887 } ) ;
8988 }
9089
@@ -99,12 +98,7 @@ class CompilerBaselineRunner extends RunnerBase {
9998 // Mocha holds onto the closure environment of the describe callback even after the test is done.
10099 // Therefore we have to clean out large objects after the test is done.
101100 justName = undefined ;
102- content = undefined ;
103- testCaseContent = undefined ;
104- units = undefined ;
105- harnessSettings = undefined ;
106101 lastUnit = undefined ;
107- rootDir = undefined ;
108102 result = undefined ;
109103 options = undefined ;
110104 toBeCompiled = undefined ;
0 commit comments