@@ -49,7 +49,7 @@ class CompilerBaselineRunner extends RunnerBase {
4949 let testCaseContent : { settings : Harness . TestCaseParser . CompilerSettings ; testUnitData : Harness . TestCaseParser . TestUnitData [ ] ; } ;
5050
5151 let units : Harness . TestCaseParser . TestUnitData [ ] ;
52- let tcSettings : Harness . TestCaseParser . CompilerSettings ;
52+ let harnessSettings : Harness . TestCaseParser . CompilerSettings ;
5353
5454 let lastUnit : Harness . TestCaseParser . TestUnitData ;
5555 let rootDir : string ;
@@ -58,46 +58,43 @@ class CompilerBaselineRunner extends RunnerBase {
5858 let program : ts . Program ;
5959 let options : ts . CompilerOptions ;
6060 // equivalent to the files that will be passed on the command line
61- let toBeCompiled : { unitName : string ; content : string } [ ] ;
61+ let toBeCompiled : Harness . Compiler . TestFile [ ] ;
6262 // equivalent to other files on the file system not directly passed to the compiler (ie things that are referenced by other files)
63- let otherFiles : { unitName : string ; content : string } [ ] ;
64- let harnessCompiler : Harness . Compiler . HarnessCompiler ;
63+ let otherFiles : Harness . Compiler . TestFile [ ] ;
6564
6665 before ( ( ) => {
6766 justName = fileName . replace ( / ^ .* [ \\ \/ ] / , "" ) ; // strips the fileName from the path.
6867 content = Harness . IO . readFile ( fileName ) ;
6968 testCaseContent = Harness . TestCaseParser . makeUnitsFromTest ( content , fileName ) ;
7069 units = testCaseContent . testUnitData ;
71- tcSettings = testCaseContent . settings ;
70+ harnessSettings = testCaseContent . settings ;
7271 lastUnit = units [ units . length - 1 ] ;
7372 rootDir = lastUnit . originalFilePath . indexOf ( "conformance" ) === - 1 ? "tests/cases/compiler/" : lastUnit . originalFilePath . substring ( 0 , lastUnit . originalFilePath . lastIndexOf ( "/" ) ) + "/" ;
74- harnessCompiler = Harness . Compiler . getCompiler ( ) ;
7573 // 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)
7674 // 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,
7775 // otherwise, assume all files are just meant to be in the same compilation session without explicit references to one another.
7876 toBeCompiled = [ ] ;
7977 otherFiles = [ ] ;
8078 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 ) ) {
81- toBeCompiled . push ( { unitName : rootDir + lastUnit . name , content : lastUnit . content } ) ;
79+ toBeCompiled . push ( { unitName : ts . combinePaths ( rootDir , lastUnit . name ) , content : lastUnit . content } ) ;
8280 units . forEach ( unit => {
8381 if ( unit . name !== lastUnit . name ) {
84- otherFiles . push ( { unitName : rootDir + unit . name , content : unit . content } ) ;
82+ otherFiles . push ( { unitName : ts . combinePaths ( rootDir , unit . name ) , content : unit . content } ) ;
8583 }
8684 } ) ;
8785 }
8886 else {
8987 toBeCompiled = units . map ( unit => {
90- return { unitName : rootDir + unit . name , content : unit . content } ;
88+ return { unitName : ts . combinePaths ( rootDir , unit . name ) , content : unit . content } ;
9189 } ) ;
9290 }
9391
94- options = harnessCompiler . compileFiles ( toBeCompiled , otherFiles , function ( compileResult , _program ) {
95- result = compileResult ;
96- // The program will be used by typeWriter
97- program = _program ;
98- } , function ( settings ) {
99- harnessCompiler . setCompilerSettings ( tcSettings ) ;
100- } ) ;
92+ const output = Harness . Compiler . HarnessCompiler . compileFiles (
93+ toBeCompiled , otherFiles , harnessSettings , /* options */ undefined , /* currentDirectory */ undefined ) ;
94+
95+ options = output . options ;
96+ result = output . result ;
97+ program = output . program ;
10198 } ) ;
10299
103100 after ( ( ) => {
@@ -107,22 +104,21 @@ class CompilerBaselineRunner extends RunnerBase {
107104 content = undefined ;
108105 testCaseContent = undefined ;
109106 units = undefined ;
110- tcSettings = undefined ;
107+ harnessSettings = undefined ;
111108 lastUnit = undefined ;
112109 rootDir = undefined ;
113110 result = undefined ;
114111 program = undefined ;
115112 options = undefined ;
116113 toBeCompiled = undefined ;
117114 otherFiles = undefined ;
118- harnessCompiler = undefined ;
119115 } ) ;
120116
121117 function getByteOrderMarkText ( file : Harness . Compiler . GeneratedFile ) : string {
122118 return file . writeByteOrderMark ? "\u00EF\u00BB\u00BF" : "" ;
123119 }
124120
125- function getErrorBaseline ( toBeCompiled : { unitName : string ; content : string } [ ] , otherFiles : { unitName : string ; content : string } [ ] , result : Harness . Compiler . CompilerResult ) {
121+ function getErrorBaseline ( toBeCompiled : Harness . Compiler . TestFile [ ] , otherFiles : Harness . Compiler . TestFile [ ] , result : Harness . Compiler . CompilerResult ) {
126122 return Harness . Compiler . getErrorBaseline ( toBeCompiled . concat ( otherFiles ) , result . errors ) ;
127123 }
128124
@@ -184,9 +180,9 @@ class CompilerBaselineRunner extends RunnerBase {
184180 }
185181 }
186182
187- const declFileCompilationResult = harnessCompiler . compileDeclarationFiles ( toBeCompiled , otherFiles , result , function ( settings ) {
188- harnessCompiler . setCompilerSettings ( tcSettings ) ;
189- } , options ) ;
183+ const declFileCompilationResult =
184+ Harness . Compiler . HarnessCompiler . compileDeclarationFiles (
185+ toBeCompiled , otherFiles , result , harnessSettings , options , /* currentDirectory */ undefined ) ;
190186
191187 if ( declFileCompilationResult && declFileCompilationResult . declResult . errors . length ) {
192188 jsCode += "\r\n\r\n//// [DtsFileErrors]\r\n" ;
@@ -367,7 +363,6 @@ class CompilerBaselineRunner extends RunnerBase {
367363 public initializeTests ( ) {
368364 describe ( this . testSuiteName + " tests" , ( ) => {
369365 describe ( "Setup compiler for compiler baselines" , ( ) => {
370- const harnessCompiler = Harness . Compiler . getCompiler ( ) ;
371366 this . parseOptions ( ) ;
372367 } ) ;
373368
0 commit comments