Skip to content

Commit

Permalink
Only --hide-successes when --quiet is used
Browse files Browse the repository at this point in the history
  • Loading branch information
9999years authored and Mikolaj committed Dec 13, 2024
1 parent acc21fa commit 358fd14
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions cabal-validate/src/Cli.hs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,12 @@ resolveOpts opts = do
else "cabal.validate.project"

tastyArgs' =
optional (rawTastyHideSuccesses opts) "--hide-successes"
maybe
-- If neither `--hide-successes` or `--no-hide-successes` was given, then
-- only `--hide-successes` if `--quiet` is given.
(optional (rawVerbosity opts <= Quiet) "--hide-successes")
(\hideSuccesses -> optional hideSuccesses "--hide-successes")
(rawTastyHideSuccesses opts)
++ maybe
[]
(\tastyPattern -> ["--pattern", tastyPattern])
Expand Down Expand Up @@ -290,7 +295,7 @@ data RawOpts = RawOpts
, rawExtraCompilers :: [FilePath]
, rawTastyPattern :: Maybe String
, rawTastyArgs :: [String]
, rawTastyHideSuccesses :: Bool
, rawTastyHideSuccesses :: Maybe Bool
, rawDoctest :: Bool
, rawSteps :: [Step]
, rawListSteps :: Bool
Expand Down Expand Up @@ -361,8 +366,7 @@ rawOptsParser =
<> help "Extra arguments to pass to Tasty test suites"
)
)
<*> boolOption
True
<*> maybeBoolOption
"hide-successes"
( help "Do not print tests that passed successfully"
)
Expand Down Expand Up @@ -444,6 +448,12 @@ boolOption :: Bool -> String -> Mod FlagFields Bool -> Parser Bool
boolOption defaultValue trueName =
boolOption' defaultValue trueName ("no-" <> trueName)

-- | Like `boolOption`, but can tell if an option was passed or not.
maybeBoolOption :: String -> Mod FlagFields (Maybe Bool) -> Parser (Maybe Bool)
maybeBoolOption trueName modifiers =
flag' (Just True) (modifiers <> long trueName)
<|> flag Nothing (Just False) (modifiers <> hidden <> long ("no-" <> trueName))

-- | Full `Parser` for `RawOpts`, which includes a @--help@ argument and
-- information about the program.
fullRawOptsParser :: ParserInfo RawOpts
Expand Down

0 comments on commit 358fd14

Please sign in to comment.