Skip to content

Commit 44cdfb1

Browse files
committed
Make checkTxCddlFormat support RECREATE_GOLDEN_FILES
1 parent 8fa4e1e commit 44cdfb1

File tree

1 file changed

+10
-4
lines changed
  • cardano-cli/test/cardano-cli-test-lib/Test/Cardano/CLI

1 file changed

+10
-4
lines changed

cardano-cli/test/cardano-cli-test-lib/Test/Cardano/CLI/Util.hs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,15 @@ checkTxCddlFormat
213213
checkTxCddlFormat referencePath createdPath = do
214214
fileExists <- liftIO $ IO.doesFileExist referencePath
215215

216-
if fileExists
216+
if fileExists && not recreateGoldenFiles
217217
then do
218218
reference <- H.evalIO $ fileOrPipe referencePath
219219
created <- H.evalIO $ fileOrPipe createdPath
220220
r <- H.evalIO $ readCddlTx reference
221221
c <- H.evalIO $ readCddlTx created
222222
r H.=== c
223223
else
224-
if createFiles
224+
if createGoldenFiles || recreateGoldenFiles
225225
then do
226226
-- CREATE_GOLDEN_FILES is set, so we create any golden files that don't
227227
-- already exist.
@@ -237,11 +237,17 @@ checkTxCddlFormat referencePath createdPath = do
237237
H.failure
238238

239239
-- | Whether the test should create the golden files if the file does ont exist.
240-
createFiles :: Bool
241-
createFiles = IO.unsafePerformIO $ do
240+
createGoldenFiles :: Bool
241+
createGoldenFiles = IO.unsafePerformIO $ do
242242
value <- IO.lookupEnv "CREATE_GOLDEN_FILES"
243243
return $ value == Just "1"
244244

245+
-- | Whether the test should create the golden files if the file does ont exist.
246+
recreateGoldenFiles :: Bool
247+
recreateGoldenFiles = IO.unsafePerformIO $ do
248+
value <- IO.lookupEnv "RECREATE_GOLDEN_FILES"
249+
return $ value == Just "1"
250+
245251
-- | Asserts that the given directory is missing.
246252
assertDirectoryMissing :: (MonadTest m, MonadIO m, HasCallStack) => FilePath -> m ()
247253
assertDirectoryMissing dir = GHC.withFrozenCallStack $ do

0 commit comments

Comments
 (0)