@@ -20,9 +20,7 @@ function _Test_runThunk(thunk)
2020
2121const fs = require ( 'node:fs' ) ;
2222const path = require ( 'node:path' ) ;
23- const os = require ( 'node:os' ) ;
2423const process = require ( 'node:process' ) ;
25- const crypto = require ( 'node:crypto' ) ;
2624
2725function _Test_readFile ( filePath )
2826{
@@ -69,6 +67,25 @@ function WriteFile(root, filePath, contents)
6967 return __Result_Err ( __File_PathEscapesDirectory ) ;
7068 }
7169
70+ // Remove failed file if it exists
71+ var failedPath = null ;
72+ if ( ! fullPath . endsWith ( ".failed.html" ) && fullPath . endsWith ( ".html" ) )
73+ failedPath = fullPath . slice ( 0 , - 5 ) + ".failed.html" ;
74+ else if ( ! fullPath . endsWith ( ".failed" ) )
75+ failedPath = fullPath + ".failed" ;
76+
77+ if ( failedPath )
78+ {
79+ try
80+ {
81+ fs . unlinkSync ( failedPath ) ;
82+ }
83+ catch ( error )
84+ {
85+ // Ignore failure if file doesn't exist
86+ }
87+ }
88+
7289 const fullDir = path . dirname ( fullPath ) ;
7390
7491 // Note that this does not throw an error if the directory exists
@@ -89,18 +106,6 @@ var _Test_writeFile = F2(function(filePath, contents)
89106 return WriteFile ( path . resolve ( "tests" ) , filePath , contents ) ;
90107} )
91108
92- var tempDir = null ;
93- var _Test_writeTempFile = F2 ( function ( filePath , contents )
94- {
95- if ( tempDir === null )
96- {
97- tempDir = os . tmpdir ( ) + "/" + crypto . randomUUID ( ) ;
98- fs . mkdirSync ( tempDir ) ;
99- }
100-
101- return WriteFile ( tempDir , filePath , contents ) ;
102- } )
103-
104109var overwriteGoldenFiles = null ;
105110function _Test_overwriteGoldenFiles ( unused )
106111{
0 commit comments