Skip to content

Commit 3b6db29

Browse files
jutaromgmeier
authored andcommitted
cardano-node | tests: internal/external subdir resolution for new
tracing
1 parent 437f2db commit 3b6db29

File tree

2 files changed

+35
-26
lines changed

2 files changed

+35
-26
lines changed

cardano-node/test/Test/Cardano/Tracing/NewTracing/Consistency.hs

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ module Test.Cardano.Tracing.NewTracing.Consistency (tests) where
66

77
import Cardano.Node.Tracing.Consistency (checkNodeTraceConfiguration)
88

9-
import Control.Monad.IO.Class (MonadIO, liftIO)
9+
import Control.Monad.IO.Class (MonadIO)
1010
import Data.Text
11-
import System.Directory (canonicalizePath)
11+
import qualified System.Directory as IO
1212
import System.FilePath ((</>))
1313

1414
import Hedgehog (Property)
@@ -22,38 +22,46 @@ tests = do
2222
H.checkSequential
2323
$ H.Group "Configuration Consistency tests"
2424
$ Prelude.map test
25-
[ ( []
26-
-- This file name shoud reference the current standard config with new tracing
25+
[ ( []
26+
-- This file name should reference the current standard config with new tracing
27+
, configSubdir
2728
, "mainnet-config-new-tracing.json"
28-
, configPrefix)
29-
, ( []
29+
)
30+
,
31+
( []
32+
, testSubdir
3033
, "goodConfig.yaml"
31-
, testPrefix)
34+
)
3235
, ( [ "Config namespace error: Illegal namespace ChainDB.CopyToImmutableDBEvent2.CopiedBlockToImmutableDB"
3336
, "Config namespace error: Illegal namespace SubscriptionDNS"
3437
]
38+
, testSubdir
3539
, "badConfig.yaml"
36-
, testPrefix)
40+
)
3741
]
3842
where
39-
test (actualValue, goldenBaseName, prefix) =
40-
(PropertyName goldenBaseName, goldenTestJSON actualValue goldenBaseName prefix)
41-
42-
43-
goldenTestJSON :: [Text] -> FilePath -> (FilePath -> IO FilePath) -> Property
44-
goldenTestJSON expectedOutcome goldenFileBaseName prefixFunc =
45-
H.withTests 1 $ H.withShrinks 0 $ H.property $ do
46-
basePath <- H.getProjectBase
47-
prefixPath <- liftIO $ prefixFunc basePath
48-
goldenFp <- H.note $ prefixPath </> goldenFileBaseName
49-
actualValue <- liftIO $ checkNodeTraceConfiguration goldenFp
50-
actualValue H.=== expectedOutcome
43+
test (actualValue, subDir, goldenBaseName) =
44+
(PropertyName goldenBaseName, goldenTestJSON subDir actualValue goldenBaseName)
5145

46+
goldenTestJSON :: SubdirSelection -> [Text] -> FilePath -> Property
47+
goldenTestJSON subDir expectedOutcome goldenFileBaseName =
48+
H.withTests 1 $ H.withShrinks 0 $ H.property $ do
49+
base <- resolveDir
50+
goldenFp <- H.note $ base </> goldenFileBaseName
51+
actualValue <- H.evalIO $ checkNodeTraceConfiguration goldenFp
52+
actualValue H.=== expectedOutcome
53+
where
54+
resolveDir = case subDir of
55+
ExternalSubdir d -> do
56+
base <- H.evalIO . IO.canonicalizePath =<< H.getProjectBase
57+
pure $ base </> d
58+
InternalSubdir d ->
59+
pure d
5260

53-
configPrefix :: FilePath -> IO FilePath
54-
configPrefix projectBase = do
55-
base <- canonicalizePath projectBase
56-
return $ base </> "configuration/cardano"
61+
data SubdirSelection =
62+
InternalSubdir FilePath
63+
| ExternalSubdir FilePath
5764

58-
testPrefix :: FilePath -> IO FilePath
59-
testPrefix _ = pure "test/Test/Cardano/Tracing/NewTracing/data/"
65+
testSubdir, configSubdir :: SubdirSelection
66+
testSubdir = InternalSubdir "test/Test/Cardano/Tracing/NewTracing/data"
67+
configSubdir = ExternalSubdir $ "configuration" </> "cardano"

configuration/cardano/update-config-files.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ copyFile "mainnet-alonzo-genesis.json"
2020
copyFile "mainnet-byron-genesis.json"
2121
copyFile "mainnet-conway-genesis.json"
2222
copyFile "mainnet-config.json"
23+
copyFile "mainnet-config-new-tracing.json"
2324
copyFile "mainnet-shelley-genesis.json"
2425
copyFile "mainnet-topology.json"
2526

0 commit comments

Comments
 (0)