@@ -6,9 +6,9 @@ module Test.Cardano.Tracing.NewTracing.Consistency (tests) where
66
77import Cardano.Node.Tracing.Consistency (checkNodeTraceConfiguration )
88
9- import Control.Monad.IO.Class (MonadIO , liftIO )
9+ import Control.Monad.IO.Class (MonadIO )
1010import Data.Text
11- import System.Directory ( canonicalizePath )
11+ import qualified System.Directory as IO
1212import System.FilePath ((</>) )
1313
1414import 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"
0 commit comments