tasty-rerun 1.1.14 → 1.1.15
raw patch · 3 files changed
+72/−62 lines, 3 filesdep −reducersdep ~basenew-uploaderPVP ok
version bump matches the API change (PVP)
Dependencies removed: reducers
Dependency ranges changed: base
API changes (from Hackage documentation)
+ Test.Tasty.Ingredients.Rerun: instance GHC.Enum.Bounded Test.Tasty.Ingredients.Rerun.Filter
+ Test.Tasty.Ingredients.Rerun: instance GHC.Enum.Enum Test.Tasty.Ingredients.Rerun.Filter
+ Test.Tasty.Ingredients.Rerun: instance GHC.Show.Show Test.Tasty.Ingredients.Rerun.Filter
Files
- Changelog.md +5/−0
- src/Test/Tasty/Ingredients/Rerun.hs +59/−56
- tasty-rerun.cabal +8/−6
Changelog.md view
@@ -1,3 +1,8 @@+# 1.1.15++* Bump upper bound of base.+* Restore missing -j command-line option.+ # 1.1.14 * Support tasty 1.2.
src/Test/Tasty/Ingredients/Rerun.hs view
@@ -8,14 +8,13 @@ import Control.Arrow ((>>>)) import Control.Monad (when) import Control.Monad.Trans.Class (lift)-import Data.Char (isSpace)+import Data.Char (isSpace, toLower) import Data.Foldable (asum)+import Data.List (intercalate) import Data.List.Split (endBy) import Data.Maybe (fromMaybe)-import Data.Monoid (mconcat)+import Data.Monoid (mempty) import Data.Proxy (Proxy(..))-import Data.Semigroup.Applicative (Traversal(..))-import Data.Tagged (Tagged(..), untag) import Data.Typeable (Typeable) import System.IO.Error (catchIOError, isDoesNotExistError) @@ -34,65 +33,49 @@ deriving (Typeable) instance Tasty.IsOption RerunLogFile where- optionName = Tagged "rerun-log-file"- optionHelp = Tagged "The path to which rerun's state file should be saved"+ optionName = return "rerun-log-file"+ optionHelp = return "Location of the log file (default: .tasty-rerun-log)" defaultValue = RerunLogFile ".tasty-rerun-log" parseValue = Just . RerunLogFile-+ optionCLParser = Tasty.mkOptionCLParser (OptParse.metavar "FILE") -------------------------------------------------------------------------------- newtype UpdateLog = UpdateLog Bool deriving (Typeable) instance Tasty.IsOption UpdateLog where- optionName = Tagged "rerun-update"-- optionHelp = Tagged "If present the log file will be updated, otherwise it \- \will be left unchanged"-+ optionName = return "rerun-update"+ optionHelp = return "Update the log file to reflect latest test outcomes" defaultValue = UpdateLog False-- parseValue = Just . UpdateLog . const True-- optionCLParser = fmap UpdateLog $ OptParse.switch $ mconcat- [ OptParse.long name- , OptParse.help helpString- ]- where- name = untag (Tasty.optionName :: Tagged UpdateLog String)- helpString = untag (Tasty.optionHelp :: Tagged UpdateLog String)+ parseValue = fmap UpdateLog . Tasty.safeReadBool+ optionCLParser = Tasty.mkFlagCLParser mempty (UpdateLog True) -------------------------------------------------------------------------------- data Filter = Failures | Exceptions | New | Successful- deriving (Eq, Ord)+ deriving (Eq, Ord, Enum, Bounded, Show) parseFilter :: String -> Maybe Filter-parseFilter "failures" = Just Failures-parseFilter "exceptions" = Just Exceptions-parseFilter "new" = Just New-parseFilter "successful" = Just Successful-parseFilter _ = Nothing+parseFilter s = lookup s (map (\x -> (map toLower (show x), x)) everything) -------------------------------------------------------------------------------- everything :: [Filter]-everything = [Failures, Exceptions, New, Successful]+everything = [minBound..maxBound] -------------------------------------------------------------------------------- newtype FilterOption = FilterOption (Set.Set Filter) deriving (Typeable) instance Tasty.IsOption FilterOption where- optionName = Tagged "rerun-filter"-- optionHelp = Tagged "A comma separated list to specify which tests to run when\- \ comparing against previous test runs. Valid options \- \are: everything, failures, exceptions, new"-+ optionName = return "rerun-filter"+ optionHelp = return+ $ "Read the log file and rerun only tests from a given comma-separated list of categories: "+ ++ map toLower (intercalate ", " (map show everything))+ ++ ". If this option is omitted or the log file is missing, rerun everything." defaultValue = FilterOption (Set.fromList everything)- parseValue = fmap (FilterOption . Set.fromList) . mapM (parseFilter . trim) . endBy "," where trim = reverse . dropWhile isSpace . reverse . dropWhile isSpace+ optionCLParser = Tasty.mkOptionCLParser (OptParse.metavar "CATEGORIES") -------------------------------------------------------------------------------- data TestResult = Completed Bool | ThrewException@@ -100,18 +83,43 @@ ----------------------------------------------------------------------------------- | This 'Tasty.Ingredient' transformer adds various @--rerun@ options to your--- test program. These flags add stateful execution of your test suite, allowing--- you to rerun only tests that are failing from the previous run, or tests that--- that have been added since the last test ran, once the 'Tasty.TestTree' has--- been filtered.+-- | This 'Tasty.Ingredient' transformer allows to control+-- which tests to run depending on their previous outcomes.+-- For example, you can rerun only failing tests or only new tests.+-- The behaviour is controlled by command-line options: ----- The input list of 'Tasty.Ingredient's specifies the 'Tasty.Ingredients's that--- will actually work with the filtered 'Tasty.TestTree'. Normally, you'll want--- at least 'Tasty.Test.Runners.consoleTestReporter'.+-- * @--rerun-update@ @ @+--+-- Update the log file to reflect latest test outcomes.+--+-- * @--rerun-filter@ @CATEGORIES@+--+-- Read the log file and rerun only tests from a given+-- comma-separated list of categories: @failures@,+-- @exceptions@, @new@, @successful@. If this option is+-- omitted or the log file is missing, rerun everything.+--+-- * @--rerun-log-file@ @FILE@+--+-- Location of the log file (default: @.tasty-rerun-log@).+--+-- Usage example:+--+-- > import Test.Tasty+-- > import Test.Tasty.Runners+-- > import Test.Tasty.Ingredients.Rerun+-- >+-- > main :: IO ()+-- > main =+-- > defaultMainWithIngredients+-- > [ rerunningTests [ listingTests, consoleTestReporter ] ]+-- > tests+-- >+-- > tests :: TestTree+-- > tests = undefined rerunningTests :: [Tasty.Ingredient] -> Tasty.Ingredient rerunningTests ingredients =- Tasty.TestManager (rerunOptions ++ existingOptions) $+ Tasty.TestManager (rerunOptions ++ Tasty.ingredientsOptions ingredients) $ \options testTree -> Just $ do let RerunLogFile stateFile = Tasty.lookupOption options UpdateLog updateLog = Tasty.lookupOption options@@ -132,7 +140,7 @@ fmap getConst $ flip State.evalStateT 0 $ Functor.getCompose $- getTraversal $+ Tasty.getTraversal $ Tasty.foldTestTree (observeResults statusMap) options filteredTestTree @@ -151,14 +159,9 @@ -- simply run the above constructed IO action. Just e -> e where- existingOptions = flip concatMap ingredients $ \ingredient ->- case ingredient of- Tasty.TestReporter options _ -> options- Tasty.TestManager options _ -> options-- rerunOptions = [ Tasty.Option (Proxy :: Proxy RerunLogFile)- , Tasty.Option (Proxy :: Proxy UpdateLog)+ rerunOptions = [ Tasty.Option (Proxy :: Proxy UpdateLog) , Tasty.Option (Proxy :: Proxy FilterOption)+ , Tasty.Option (Proxy :: Proxy RerunLogFile) ] ------------------------------------------------------------------------------@@ -203,7 +206,7 @@ ------------------------------------------------------------------------------ observeResults statusMap =- let foldSingle _ name _ = Traversal $ Functor.Compose $ do+ let foldSingle _ name _ = Tasty.Traversal $ Functor.Compose $ do i <- State.get status <- lift $ STM.atomically $ do@@ -218,8 +221,8 @@ Const (Map.singleton [name] status) <$ State.modify (+ 1) - foldGroup name children = Traversal $ Functor.Compose $ do- Const soFar <- Functor.getCompose $ getTraversal children+ foldGroup name children = Tasty.Traversal $ Functor.Compose $ do+ Const soFar <- Functor.getCompose $ Tasty.getTraversal children pure $ Const (Map.mapKeys (name :) soFar) in Tasty.trivialFold
tasty-rerun.cabal view
@@ -1,11 +1,12 @@ name: tasty-rerun-version: 1.1.14+version: 1.1.15 homepage: http://github.com/ocharles/tasty-rerun license: BSD3 license-file: LICENSE author: Oliver Charles maintainer: ollie@ocharles.org.uk-copyright: Oliver Charles (c) 2014+copyright: Oliver Charles (c) 2014,+ Andrew Lelechenko (c) 2019 category: Testing build-type: Simple cabal-version: >=1.10@@ -13,8 +14,7 @@ Changelog.md synopsis:- Run tests by filtering the test tree depending on the result of previous test- runs+ Rerun only tests which failed in a previous test run description: This ingredient adds the ability to run tests by first filtering the test tree@@ -29,6 +29,7 @@ . > import Test.Tasty > import Test.Tasty.Runners+ > import Test.Tasty.Ingredients.Rerun > > main :: IO () > main =@@ -69,14 +70,15 @@ . Defaults to all filters, which means all tests will be ran. +tested-with: GHC==8.8.1, GHC==8.6.5, GHC==8.4.4, GHC==8.2.2, GHC==8.0.2, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3+ library exposed-modules: Test.Tasty.Ingredients.Rerun build-depends:- base >=4.6 && <4.13,+ base >=4.6 && <4.14, containers >= 0.5.0.0, mtl >= 2.1.2, optparse-applicative >= 0.6,- reducers >= 3.10.1, split >= 0.1 && < 0.3, stm >= 2.4.2, tagged >= 0.7 && <0.9,