Skip to content

Commit 8be2c20

Browse files
committed
New noteGoldenFile function
1 parent 22beffb commit 8be2c20

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

cardano-cli/cardano-cli.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ test-suite cardano-cli-golden
519519
Test.Golden.Shelley.Transaction.Id
520520
Test.Golden.Shelley.Transaction.Sign
521521
Test.Golden.TxView
522+
Test.Golden.Util
522523
Test.Golden.Version
523524

524525
ghc-options:
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module Test.Golden.Util where
2+
3+
import Data.Text qualified as Text
4+
import GHC.Exts qualified as GHC
5+
import GHC.Stack (HasCallStack)
6+
import GHC.Stack qualified as GHC
7+
import System.FilePath (joinPath)
8+
9+
import Hedgehog.Extras (UnitIO)
10+
import Hedgehog.Extras qualified as H
11+
12+
noteGoldenFile
13+
:: HasCallStack
14+
=> FilePath
15+
-> UnitIO FilePath
16+
noteGoldenFile fileName =
17+
GHC.withFrozenCallStack $ do
18+
case GHC.toList GHC.callStack of
19+
top : _ -> do
20+
let dirs = Text.unpack $ Text.intercalate "/" $ Text.splitOn "." $ Text.pack $ GHC.srcLocModule (snd top)
21+
22+
H.note $ joinPath ["test/cardano-cli-golden/files/golden", dirs, fileName]
23+
_ -> H.failMessage GHC.callStack $ "No call stack available for golden file: " <> fileName

0 commit comments

Comments
 (0)