@@ -1604,31 +1604,7 @@ namespace Harness {
16041604 }
16051605
16061606 const fileCache : { [ idx : string ] : boolean } = { } ;
1607- function generateActual ( actualFileName : string , generateContent : ( ) => string ) : string {
1608- // For now this is written using TypeScript, because sys is not available when running old test cases.
1609- // But we need to move to sys once we have
1610- // Creates the directory including its parent if not already present
1611- function createDirectoryStructure ( dirName : string ) {
1612- if ( fileCache [ dirName ] || IO . directoryExists ( dirName ) ) {
1613- fileCache [ dirName ] = true ;
1614- return ;
1615- }
1616-
1617- const parentDirectory = IO . directoryName ( dirName ) ;
1618- if ( parentDirectory != "" ) {
1619- createDirectoryStructure ( parentDirectory ) ;
1620- }
1621- IO . createDirectory ( dirName ) ;
1622- fileCache [ dirName ] = true ;
1623- }
1624-
1625- // Create folders if needed
1626- createDirectoryStructure ( Harness . IO . directoryName ( actualFileName ) ) ;
1627-
1628- // Delete the actual file in case it fails
1629- if ( IO . fileExists ( actualFileName ) ) {
1630- IO . deleteFile ( actualFileName ) ;
1631- }
1607+ function generateActual ( generateContent : ( ) => string ) : string {
16321608
16331609 const actual = generateContent ( ) ;
16341610
@@ -1664,6 +1640,31 @@ namespace Harness {
16641640 }
16651641
16661642 function writeComparison ( expected : string , actual : string , relativeFileName : string , actualFileName : string ) {
1643+ // For now this is written using TypeScript, because sys is not available when running old test cases.
1644+ // But we need to move to sys once we have
1645+ // Creates the directory including its parent if not already present
1646+ function createDirectoryStructure ( dirName : string ) {
1647+ if ( fileCache [ dirName ] || IO . directoryExists ( dirName ) ) {
1648+ fileCache [ dirName ] = true ;
1649+ return ;
1650+ }
1651+
1652+ const parentDirectory = IO . directoryName ( dirName ) ;
1653+ if ( parentDirectory != "" ) {
1654+ createDirectoryStructure ( parentDirectory ) ;
1655+ }
1656+ IO . createDirectory ( dirName ) ;
1657+ fileCache [ dirName ] = true ;
1658+ }
1659+
1660+ // Create folders if needed
1661+ createDirectoryStructure ( Harness . IO . directoryName ( actualFileName ) ) ;
1662+
1663+ // Delete the actual file in case it fails
1664+ if ( IO . fileExists ( actualFileName ) ) {
1665+ IO . deleteFile ( actualFileName ) ;
1666+ }
1667+
16671668 const encoded_actual = Utils . encodeString ( actual ) ;
16681669 if ( expected !== encoded_actual ) {
16691670 if ( actual === NoContent ) {
@@ -1680,7 +1681,7 @@ namespace Harness {
16801681
16811682 const actualFileName = localPath ( relativeFileName , opts && opts . Baselinefolder , opts && opts . Subfolder ) ;
16821683
1683- const actual = generateActual ( actualFileName , generateContent ) ;
1684+ const actual = generateActual ( generateContent ) ;
16841685 const comparison = compareToBaseline ( actual , relativeFileName , opts ) ;
16851686 writeComparison ( comparison . expected , comparison . actual , relativeFileName , actualFileName ) ;
16861687 }
0 commit comments