@@ -1604,31 +1604,7 @@ namespace Harness {
1604
1604
}
1605
1605
1606
1606
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 {
1632
1608
1633
1609
const actual = generateContent ( ) ;
1634
1610
@@ -1664,6 +1640,31 @@ namespace Harness {
1664
1640
}
1665
1641
1666
1642
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
+
1667
1668
const encoded_actual = Utils . encodeString ( actual ) ;
1668
1669
if ( expected !== encoded_actual ) {
1669
1670
if ( actual === NoContent ) {
@@ -1680,7 +1681,7 @@ namespace Harness {
1680
1681
1681
1682
const actualFileName = localPath ( relativeFileName , opts && opts . Baselinefolder , opts && opts . Subfolder ) ;
1682
1683
1683
- const actual = generateActual ( actualFileName , generateContent ) ;
1684
+ const actual = generateActual ( generateContent ) ;
1684
1685
const comparison = compareToBaseline ( actual , relativeFileName , opts ) ;
1685
1686
writeComparison ( comparison . expected , comparison . actual , relativeFileName , actualFileName ) ;
1686
1687
}
0 commit comments