From 358fd1462086eb2f167654d936a38f59df553a80 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Wed, 20 Nov 2024 15:56:29 -0800 Subject: [PATCH] Only `--hide-successes` when `--quiet` is used --- cabal-validate/src/Cli.hs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cabal-validate/src/Cli.hs b/cabal-validate/src/Cli.hs index 70120497926..6a3a33c8f40 100644 --- a/cabal-validate/src/Cli.hs +++ b/cabal-validate/src/Cli.hs @@ -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]) @@ -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 @@ -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" ) @@ -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