Skip to content

Commit

Permalink
Add missing HasCallStack to writeGoldenFile, reportGoldenFileMissin…
Browse files Browse the repository at this point in the history
…g, checkAgainstGoldenFile
  • Loading branch information
carbolymer committed May 15, 2024
1 parent 4614d65 commit b991dad
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Hedgehog/Extras/Test/Golden.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,24 @@ recreateGoldenFiles = IO.unsafePerformIO $ do
return $ value == Just "1"

writeGoldenFile :: ()
=> HasCallStack
=> MonadIO m
=> MonadTest m
=> FilePath
-> String
-> m ()
writeGoldenFile goldenFile actualContent = do
writeGoldenFile goldenFile actualContent = GHC.withFrozenCallStack $ do
H.note_ $ "Creating golden file " <> goldenFile
H.createDirectoryIfMissing_ (takeDirectory goldenFile)
H.writeFile goldenFile actualContent

reportGoldenFileMissing :: ()
=> HasCallStack
=> MonadIO m
=> MonadTest m
=> FilePath
-> m ()
reportGoldenFileMissing goldenFile = do
reportGoldenFileMissing goldenFile = GHC.withFrozenCallStack $ do
H.note_ $ unlines
[ "Golden file " <> goldenFile <> " does not exist."
, "To create it, run with CREATE_GOLDEN_FILES=1."
Expand All @@ -82,12 +84,13 @@ reportGoldenFileMissing goldenFile = do
H.failure

checkAgainstGoldenFile :: ()
=> HasCallStack
=> MonadIO m
=> MonadTest m
=> FilePath
-> [String]
-> m ()
checkAgainstGoldenFile goldenFile actualLines = do
checkAgainstGoldenFile goldenFile actualLines = GHC.withFrozenCallStack $ do
referenceLines <- List.lines <$> H.readFile goldenFile
let difference = getGroupedDiff actualLines referenceLines
case difference of
Expand Down

0 comments on commit b991dad

Please sign in to comment.