tasty-silver 3.3.1.2 → 3.3.1.3
raw patch · 4 files changed
+57/−37 lines, 4 filesdep ~basedep ~tasty
Dependency ranges changed: base, tasty
Files
- CHANGELOG.md +11/−0
- Test/Tasty/Silver/Filter.hs +30/−23
- Test/Tasty/Silver/Interactive.hs +4/−4
- tasty-silver.cabal +12/−10
CHANGELOG.md view
@@ -1,6 +1,17 @@ Changes ======= +Version 3.3.1.3 (20 Oct 2023)+---------------++_Dedicated to Anne-Christine. Happy birthday!_++* Fix test reporting when built with `tasty-1.5`+ (regression in 3.3.1.2, see [#41](https://github.com/phile314/tasty-silver/issues/41)).+* `filterWithRedex` is now the identity if no inclusion/exclusion regexes are given in the options.+* Drop support for GHC 7.4 for the sake of `LambdaCase`.+* Tested with GHC 8.0 - 9.8.1.+ Version 3.3.1.2 (10 Sep 2023) ---------------
Test/Tasty/Silver/Filter.hs view
@@ -44,17 +44,15 @@ -- 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+ = RFInclude String -- ^ Include tests that match.+ | RFExclude String -- ^ Exclude tests that match. deriving (Typeable) --- | Tests to completely exlucde, treating them--- like they do not exist.+-- | Tests to completely exclude, treating them like they do not exist. newtype ExcludeFilters = ExcludeFilters [RegexFilter] deriving (Typeable) --- | Tests to completely include, treating all--- other tests like they do not exist.+-- | Tests to completely include, treating all other tests like they do not exist. newtype IncludeFilters = IncludeFilters [RegexFilter] deriving (Typeable) @@ -85,13 +83,20 @@ <$> RS.compile R.defaultCompOpt R.defaultExecOpt) parseValue1 :: (String -> RegexFilter) -> String -> Maybe [RegexFilter]-parseValue1 f x = fmap (const $ [f x]) $ compileRegex x+parseValue1 f x = fmap (const [f x]) $ compileRegex x filterWithRegex :: OptionSet -> TestTree -> TestTree-filterWithRegex opts = filterWithPred (checkRF True $ excRgxs ++ incRgxs)- where ExcludeFilters excRgxs = lookupOption opts- IncludeFilters incRgxs = lookupOption opts-+filterWithRegex opts =+ -- Andreas, 2023-10-20: Since @filterWithPred (const True)@ is not the identity+ -- when the test tree contains 'WithResource' etc.,+ -- we skip it if it does not actually filter out anything.+ if null filters+ then id+ else filterWithPred (checkRF True filters)+ where+ ExcludeFilters excRgxs = lookupOption opts+ IncludeFilters incRgxs = lookupOption opts+ filters = excRgxs ++ incRgxs -- | Check if the given path should be kept using regex filters. -- A Tree leaf is retained if the following conditions@@ -118,17 +123,19 @@ filterWithPred :: (TestPath -> Bool) -> TestTree -> TestTree-filterWithPred prd tree = fromMaybe emptyTest (filter' "/" tree)- where x <//> y = x ++ "/" ++ y+filterWithPred f tree = fromMaybe emptyTest $ filter' "/" tree+ where+ filter' :: TestPath -> TestTree -> Maybe TestTree+ filter' path = \case+ SingleTest n t -> if f (path <//> n) then Just $ SingleTest n t else Nothing+ TestGroup n ts -> Just $ TestGroup n $ mapMaybe (filter' $ path <//> n) ts+ PlusTestOptions o t -> PlusTestOptions o <$> filter' path t+ -- we don't know at tree construction time what the tree wrapped inside an AskOptions/WithResource+ -- is going to look like. We always return something, and just return an empty test group+ -- if later on we see that the child subtree was excluded.+ WithResource r t -> Just $ WithResource r $ \ x -> fromMaybe emptyTest $ filter' path $ t x+ AskOptions t -> Just $ AskOptions $ \ o -> fromMaybe emptyTest $ filter' path $ t o - filter' :: TestPath -> TestTree -> Maybe TestTree- filter' pth (SingleTest n t) = if prd (pth <//> n) then Just $ SingleTest n t else Nothing- filter' pth (TestGroup n ts) = Just $ TestGroup n (catMaybes $ map (filter' $ pth <//> n) ts)- filter' pth (PlusTestOptions o t) = PlusTestOptions o <$> filter' pth t- -- we don't know at tree construction time what the tree wrapped inside an AskOptions/WithResource- -- is going to look like. We always return something, and just return an empty test group- -- if later on we see that the child subtree was excluded.- filter' pth (WithResource r t) = Just $ WithResource r (\x -> fromMaybe emptyTest (filter' pth (t x)))- filter' pth (AskOptions t) = Just $ AskOptions (\o -> fromMaybe emptyTest (filter' pth (t o)))+ x <//> y = x ++ "/" ++ y - emptyTest = testGroup "" []+ emptyTest = testGroup "" []
Test/Tasty/Silver/Interactive.hs view
@@ -565,12 +565,12 @@ let handleTestResult' = (if isInteractive then handleTestResultInteractive else handleTestResult) return $ HandleTest name printTestName handleTestResult' - handleGroup :: OptionSet -> TestName -> Ap (Reader Level) TestOutput -> Ap (Reader Level) TestOutput+ handleGroup :: OptionSet -> TestName -> [Ap (Reader Level) TestOutput] -> Ap (Reader Level) TestOutput handleGroup _ name grp = Ap $ do level <- ask let printHeading = printf "%s%s\n" (indent level) name- printBody = runReader (getApp grp) (level + 1)+ printBody = runReader (getApp $ mconcat grp) (level + 1) return $ PrintHeading printHeading printBody in@@ -579,9 +579,9 @@ trivialFold { foldSingle = handleSingleTest #if MIN_VERSION_tasty(1,5,0)- , foldGroup = \ opts name -> foldMap (handleGroup opts name)+ , foldGroup = \ opts name ts -> handleGroup opts name ts #else- , foldGroup = \ opts name -> id (handleGroup opts name)+ , foldGroup = \ opts name t -> handleGroup opts name [t] #endif } opts tree
tasty-silver.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.14 name: tasty-silver-version: 3.3.1.2+version: 3.3.1.3 synopsis: A fancy test runner, including support for golden tests. description: This package provides a fancy test runner and support for «golden testing».@@ -29,8 +29,8 @@ README.md tested-with:- GHC == 9.8.0- GHC == 9.6.2+ GHC == 9.8.1+ GHC == 9.6.3 GHC == 9.4.7 GHC == 9.2.8 GHC == 9.0.2@@ -40,12 +40,12 @@ GHC == 8.4.4 GHC == 8.2.2 GHC == 8.0.2- GHC == 7.10.3- GHC == 7.8.4- GHC == 7.6.3- GHC == 7.4.2- -- GHC 7.0 is not supported by regex-tdfa, needing array >= 0.4+ -- Drop testing with GHC 7+ -- GHC == 7.10.3+ -- GHC == 7.8.4+ -- GHC == 7.6.3 + Source-repository head type: git location: https://github.com/phile314/tasty-silver.git@@ -53,6 +53,8 @@ library Default-language: Haskell2010+ Default-extensions:+ LambdaCase exposed-modules: Test.Tasty.Silver Test.Tasty.Silver.Advanced Test.Tasty.Silver.Filter@@ -67,8 +69,8 @@ -Wcompat build-depends:- base >= 4.5 && < 5- -- regex-tdfa has this lower bound on base, so we make it explicit here+ base >= 4.6 && < 5+ -- LambdaCase supported since GHC 7.6 (base-4.6) , ansi-terminal >= 0.6.2.1 , async , bytestring >= 0.9.2.1