Skip to content

Commit 48d33d4

Browse files
newhoggyJohn Ky
authored andcommitted
Upgrade tasty-discover
1 parent 2124f5a commit 48d33d4

File tree

5 files changed

+56
-46
lines changed

5 files changed

+56
-46
lines changed

cabal.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repository cardano-haskell-packages
1313
-- See CONTRIBUTING for information about these, including some Nix commands
1414
-- you need to run if you change them
1515
index-state:
16-
, hackage.haskell.org 2025-06-22T20:18:27Z
16+
, hackage.haskell.org 2025-08-10T03:21:06Z
1717
, cardano-haskell-packages 2025-07-14T17:31:29Z
1818

1919
packages:

cardano-cli/cardano-cli.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ test-suite cardano-cli-golden
449449
regex-tdfa,
450450
rio,
451451
tasty,
452+
tasty-discover,
452453
tasty-hedgehog,
453454
text,
454455

cardano-cli/test/cardano-cli-golden/Test/Golden/Help.hs

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
module Test.Golden.Help
77
( hprop_golden_HelpAll
8-
, test_golden_HelpCmds
8+
, tasty_golden_HelpCmds
99
)
1010
where
1111

@@ -32,6 +32,7 @@ import Hedgehog qualified as H
3232
import Hedgehog.Extras.Stock.OS (isWin32)
3333
import Hedgehog.Extras.Test qualified as H
3434
import Test.Tasty (TestTree, testGroup)
35+
import Test.Tasty.Discover (Flavored, flavored, platform)
3536
import Test.Tasty.Hedgehog (testProperty)
3637

3738
ansiRegex :: Regex
@@ -104,50 +105,48 @@ stripMetavar =
104105
selectCmd :: Text -> Maybe Text
105106
selectCmd = fmap stripMetavar . selectAndDropPrefix "Usage: cardano-cli "
106107

107-
test_golden_HelpCmds :: IO TestTree
108-
test_golden_HelpCmds =
108+
tasty_golden_HelpCmds :: Flavored (IO TestTree)
109+
tasty_golden_HelpCmds =
109110
-- These tests are not run on Windows because the cardano-cli usage
110111
-- output is slightly different on Windows. For example it uses
111112
-- "cardano-cli.exe" instead of "cardano-cli".
112-
if isWin32
113-
then return $ testGroup "help-commands" []
114-
else do
115-
helpText <-
116-
filterAnsi
117-
<$> readProcess
118-
"cardano-cli"
119-
[ "help"
120-
]
121-
""
122-
123-
let lines = Text.lines (Text.pack helpText)
124-
usages = [] : nub (List.filter (not . null) (fmap extractCmd $ maybeToList . selectCmd =<< lines))
125-
126-
return $
127-
testGroup
128-
"help-commands"
129-
[ testProperty
130-
(subPath usage)
131-
( watchdogProp . propertyOnce $ do
132-
H.noteShow_ usage
133-
let expectedCmdHelpFp =
134-
"test/cardano-cli-golden/files/golden" </> subPath usage
135-
136-
(exitCode, stdout, stderr) <- H.execDetailCardanoCLI (Text.unpack <$> usage <> ["--help"])
137-
let cmdHelp = filterAnsi stdout
138-
139-
case exitCode of
140-
ExitSuccess ->
141-
H.diffVsGoldenFile cmdHelp expectedCmdHelpFp
142-
ExitFailure _ -> do
143-
H.note_ "Failed to generate correct help text"
144-
H.noteShow_ exitCode
145-
H.note_ $ filterAnsi stderr
146-
H.note_ cmdHelp -- stdout
147-
H.failure
148-
)
149-
| usage <- usages
113+
flavored (platform "!windows") $ do
114+
helpText <-
115+
filterAnsi
116+
<$> readProcess
117+
"cardano-cli"
118+
[ "help"
150119
]
120+
""
121+
122+
let lines = Text.lines (Text.pack helpText)
123+
usages = [] : nub (List.filter (not . null) (fmap extractCmd $ maybeToList . selectCmd =<< lines))
124+
125+
return $
126+
testGroup
127+
"help-command"
128+
[ testProperty
129+
(subPath usage)
130+
( watchdogProp . propertyOnce $ do
131+
H.noteShow_ usage
132+
let expectedCmdHelpFp =
133+
"test/cardano-cli-golden/files/golden" </> subPath usage
134+
135+
(exitCode, stdout, stderr) <- H.execDetailCardanoCLI (Text.unpack <$> usage <> ["--help"])
136+
let cmdHelp = filterAnsi stdout
137+
138+
case exitCode of
139+
ExitSuccess ->
140+
H.diffVsGoldenFile cmdHelp expectedCmdHelpFp
141+
ExitFailure _ -> do
142+
H.note_ "Failed to generate correct help text"
143+
H.noteShow_ exitCode
144+
H.note_ $ filterAnsi stderr
145+
H.note_ cmdHelp -- stdout
146+
H.failure
147+
)
148+
| usage <- usages
149+
]
151150
where
152151
subPath :: [Text] -> FilePath
153152
subPath [] =

cardano-cli/test/cardano-cli-test/Test/Cli/Run/Hash.hs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
{-# LANGUAGE FlexibleContexts #-}
2+
13
{- HLINT ignore "Use camelCase" -}
24

35
module Test.Cli.Run.Hash where
46

57
import Control.Monad (void)
68
import Control.Monad.Catch (MonadCatch)
9+
import Control.Monad.Trans.Control (MonadBaseControl)
710
import Control.Monad.Trans.Resource (MonadResource)
811
import GHC.Stack
912

@@ -24,7 +27,14 @@ hprop_hash_trip =
2427
-- Test that @cardano-cli hash --text > file1@ and
2528
-- @cardano-cli --text --out-file file2@ yields
2629
-- similar @file1@ and @file2@ files.
27-
hash_trip_fun :: (MonadTest m, MonadCatch m, MonadResource m, HasCallStack) => String -> m ()
30+
hash_trip_fun
31+
:: MonadBaseControl IO m
32+
=> MonadTest m
33+
=> MonadCatch m
34+
=> MonadResource m
35+
=> HasCallStack
36+
=> String
37+
-> m ()
2838
hash_trip_fun input =
2939
H.moduleWorkspace "tmp" $ \tempDir -> do
3040
hashFile <- noteTempFile tempDir "hash.txt"

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)