@@ -1639,7 +1639,7 @@ Actual: ${stringify(fullActual)}`);
16391639 } ) ;
16401640 }
16411641
1642- public baselineGetEmitOutput ( insertResultsIntoVfs ?: boolean ) {
1642+ private getEmitFiles ( ) : ReadonlyArray < FourSlashFile > {
16431643 // Find file to be emitted
16441644 const emitFiles : FourSlashFile [ ] = [ ] ; // List of FourSlashFile that has emitThisFile flag on
16451645
@@ -1656,12 +1656,31 @@ Actual: ${stringify(fullActual)}`);
16561656 this . raiseError ( "No emitThisFile is specified in the test file" ) ;
16571657 }
16581658
1659+ return emitFiles ;
1660+ }
1661+
1662+ public verifyGetEmitOutput ( expectedOutputFiles : ReadonlyArray < string > ) : void {
1663+ const outputFiles = ts . flatMap ( this . getEmitFiles ( ) , e => this . languageService . getEmitOutput ( e . fileName ) . outputFiles ) ;
1664+
1665+ assert . deepEqual ( outputFiles . map ( f => f . name ) , expectedOutputFiles ) ;
1666+
1667+ for ( const { name, text } of outputFiles ) {
1668+ const fromTestFile = this . getFileContent ( name ) ;
1669+ if ( fromTestFile !== text ) {
1670+ this . raiseError ( "Emit output is not as expected: " + showTextDiff ( fromTestFile , text ) ) ;
1671+ }
1672+ }
1673+ }
1674+
1675+ public baselineGetEmitOutput ( insertResultsIntoVfs ?: boolean ) : void {
1676+ ts . Debug . assert ( this . testType !== FourSlashTestType . Server , "Use verifyGetEmitOutput -- insertResultIntoVfs doesn't work with server" ) ;
1677+
16591678 Harness . Baseline . runBaseline (
1660- this . testData . globalOptions [ MetadataOptionNames . baselineFile ] ,
1679+ ts . Debug . assertDefined ( this . testData . globalOptions [ MetadataOptionNames . baselineFile ] ) ,
16611680 ( ) => {
16621681 let resultString = "" ;
16631682 // Loop through all the emittedFiles and emit them one by one
1664- emitFiles . forEach ( emitFile => {
1683+ for ( const emitFile of this . getEmitFiles ( ) ) {
16651684 const emitOutput = this . languageService . getEmitOutput ( emitFile . fileName ) ;
16661685 // Print emitOutputStatus in readable format
16671686 resultString += "EmitSkipped: " + emitOutput . emitSkipped + Harness . IO . newLine ( ) ;
@@ -1687,13 +1706,13 @@ Actual: ${stringify(fullActual)}`);
16871706
16881707 for ( const outputFile of emitOutput . outputFiles ) {
16891708 const fileName = "FileName : " + outputFile . name + Harness . IO . newLine ( ) ;
1690- resultString = resultString + fileName + outputFile . text ;
1709+ resultString = resultString + Harness . IO . newLine ( ) + fileName + outputFile . text ;
16911710 if ( insertResultsIntoVfs ) {
16921711 this . languageServiceAdapterHost . addScript ( ts . getNormalizedAbsolutePath ( outputFile . name , "/" ) , outputFile . text , /*isRootFile*/ true ) ;
16931712 }
16941713 }
16951714 resultString += Harness . IO . newLine ( ) ;
1696- } ) ;
1715+ }
16971716
16981717 return resultString ;
16991718 } ) ;
@@ -3567,8 +3586,13 @@ ${code}
35673586
35683587 function getNonFileNameOptionInObject ( optionObject : { [ s : string ] : string } ) : string | undefined {
35693588 for ( const option in optionObject ) {
3570- if ( option !== MetadataOptionNames . fileName ) {
3571- return option ;
3589+ switch ( option ) {
3590+ case MetadataOptionNames . fileName :
3591+ case MetadataOptionNames . baselineFile :
3592+ case MetadataOptionNames . emitThisFile :
3593+ break ;
3594+ default :
3595+ return option ;
35723596 }
35733597 }
35743598 return undefined ;
@@ -4278,6 +4302,10 @@ namespace FourSlashInterface {
42784302 this . state . baselineCurrentFileNameOrDottedNameSpans ( ) ;
42794303 }
42804304
4305+ public getEmitOutput ( expectedOutputFiles : ReadonlyArray < string > ) : void {
4306+ this . state . verifyGetEmitOutput ( expectedOutputFiles ) ;
4307+ }
4308+
42814309 public baselineGetEmitOutput ( insertResultsIntoVfs ?: boolean ) {
42824310 this . state . baselineGetEmitOutput ( insertResultsIntoVfs ) ;
42834311 }
0 commit comments