packages feed

tasty-silver 3.1.3 → 3.1.4

raw patch · 4 files changed

+55/−5 lines, 4 filesdep +regex-tdfa

Dependencies added: regex-tdfa

Files

CHANGELOG.md view
@@ -1,6 +1,12 @@ Changes ======= +Version 3.1.4+-------------++* Add experimental --regex-exclude option to filter out tests using a regex.+  This option is highly experimental and may change in later versions!+ Version 3.1.3 ------------- 
Test/Tasty/Silver/Interactive.hs view
@@ -59,7 +59,8 @@ import qualified Data.Map as M import System.Console.ANSI import qualified System.Process.Text as PTL-+import qualified Text.Regex.TDFA.String as RS+import qualified Text.Regex.TDFA as R -- | Like @defaultMain@ from the main tasty package, but also includes the -- golden test management capabilities. defaultMain :: TestTree -> IO ()@@ -74,7 +75,29 @@   optionHelp = return "Run tests in interactive mode."   optionCLParser = flagCLParser (Just 'i') (Interactive True) +-- we have to store the regex as String, as there is no Typeable instance+-- for the Regex data type with GHC < 7.8+data RegexFilter+  = RFInclude String -- include tests that match+  | RFExclude String -- exclude tests that match+  | RFNone+  deriving (Typeable) +{-instance IsOption RegexFilter where+  defaultValue = RFNone+  parseValue = fmap RFInclude . either (const Nothing) Just . RS.compile R.defaultCompOpt R.defaultExecOpt+  optionName = return "regex-include"+  optionHelp = return "Include only tests matching a regex (experimental)."-}++compileRegex :: String -> Maybe RS.Regex+compileRegex = either (const Nothing) Just . RS.compile R.defaultCompOpt R.defaultExecOpt++instance IsOption RegexFilter where+  defaultValue = RFNone+  parseValue = \x -> fmap (const (RFExclude x)) $ compileRegex x+  optionName = return "regex-exclude"+  optionHelp = return "Exclude tests matching a regex (experimental)."+ data ResultStatus = RPass | RFail | RMismatch GoldenResultI  type GoldenStatus = GoldenResultI@@ -87,9 +110,29 @@     , Option (Proxy :: Proxy HideSuccesses)     , Option (Proxy :: Proxy UseColor)     , Option (Proxy :: Proxy NumThreads)+    , Option (Proxy :: Proxy RegexFilter)     ] $   \opts tree ->-      Just $ runTestsInteractive opts tree+      Just $ runTestsInteractive opts (filterWithRegex opts tree)++filterWithRegex :: OptionSet -> TestTree -> TestTree+filterWithRegex opts tree = case lookupOption opts of+    RFNone -> tree+    RFInclude rgx -> filter' (R.matchTest $ fromJust $ compileRegex rgx)+    RFExclude rgx -> filter' (not . R.matchTest (fromJust $ compileRegex rgx))+  where x <//> y = x ++ "/" ++ y+        filter' :: (String -> Bool) -> TestTree+        filter' pred' =+            let alg :: TreeFold [String -> Maybe TestTree]+                alg = trivialFold+                    { foldSingle = \_ nm t -> [\pth -> if pred' (pth <//> nm) then Just (SingleTest nm t) else Nothing]+                    , foldGroup  = \nm chlds -> [\pth -> let pth' = pth <//> nm+                                        in if pred' pth'+                                            then Just $ TestGroup nm (catMaybes $ map (\x -> x (pth <//> nm)) chlds)+                                            else Nothing]+                    }+                [root] = foldTestTree alg opts tree+             in maybe (testGroup "" []) (id) (root "")   runSingleTest ::  IsTest t => GoldenStatusMap -> TestName -> OptionSet -> t -> (Progress -> IO ()) -> IO Result
tasty-silver.cabal view
@@ -1,5 +1,5 @@ name:                tasty-silver-version:             3.1.3+version:             3.1.4 synopsis:            Golden tests support for tasty. Fork of tasty-golden. description:   This package provides support for «golden testing».@@ -49,6 +49,7 @@     optparse-applicative,     process >= 1.2,     process-extras >= 0.2,+    regex-tdfa >= 1.2.0,     stm >= 2.4.2,     tagged,     tasty >= 0.8,
tests/test.hs view
@@ -1,7 +1,7 @@-import Test.Tasty+import Test.Tasty hiding (defaultMain) import Test.Tasty.HUnit import Test.Tasty.Silver-import Test.Tasty.Silver.Interactive hiding (defaultMain)+import Test.Tasty.Silver.Interactive import Test.Tasty.Runners import Test.Tasty.Silver.Advanced import Test.Tasty.Silver.Internal