Skip to content

Commit

Permalink
Allow --pattern|-p option to repeat
Browse files Browse the repository at this point in the history
The effect of multiple -p options is the same as &&-ing the expressions
together, but allowing them to be specified in separate options makes
scripting test commands simpler.
  • Loading branch information
rhendric committed Aug 6, 2023
1 parent 959fe91 commit 762f0a4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion core/Test/Tasty/Patterns.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Test.Tasty.Patterns.Parser
import Test.Tasty.Patterns.Eval

import Data.Char
import Data.Foldable (foldl')
import Data.Typeable
import Options.Applicative hiding (Success)
#if !MIN_VERSION_base(4,11,0)
Expand All @@ -44,7 +45,11 @@ instance IsOption TestPattern where
parseValue = parseTestPattern
optionName = return "pattern"
optionHelp = return "Select only tests which satisfy a pattern or awk expression"
optionCLParser = mkOptionCLParser (short 'p' <> metavar "PATTERN")
optionCLParser = fmap (foldl' testPatternAnd noPattern) $ some $ mkOptionCLParser (short 'p' <> metavar "PATTERN")
where
testPatternAnd (TestPattern Nothing) (TestPattern mbY) = TestPattern mbY
testPatternAnd (TestPattern mbX) (TestPattern Nothing) = TestPattern mbX
testPatternAnd (TestPattern (Just x)) (TestPattern (Just y)) = TestPattern (Just (And x y))

-- | @since 1.2
parseExpr :: String -> Maybe Expr
Expand Down

0 comments on commit 762f0a4

Please sign in to comment.