packages feed

hspec-meta 2.5.6 → 2.6.0

raw patch · 14 files changed

+141/−49 lines, 14 filesdep ~QuickCheckdep ~hspec-expectationsPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: QuickCheck, hspec-expectations

API changes (from Hackage documentation)

+ Test.Hspec.Meta: fcontext :: HasCallStack => String -> SpecWith a -> SpecWith a
+ Test.Hspec.Meta: fdescribe :: HasCallStack => String -> SpecWith a -> SpecWith a
+ Test.Hspec.Meta: fit :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a)
+ Test.Hspec.Meta: focus :: SpecWith a -> SpecWith a
+ Test.Hspec.Meta: fspecify :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a)
+ Test.Hspec.Meta: type family Arg e

Files

CHANGES.markdown view
@@ -1,3 +1,20 @@+## Changes in 2.6.0+   - Allow to focus individual spec items (see #319)+   - Do not calculate diff on `--no-diff` (see #332)+   - Remove deprecated module Test.Hspec.Core++## Changes in 2.5.9+   - Extract source locations from RecConError (see #375)++## Changes in 2.5.8+   - Add `modifyArgs` and `modifyMaxShrinks` to `Test.Hspec.QuickCheck` (see #380)++## Changes in 2.5.7+   - GHC 8.6.1 related changes++## Changes in 2.5.6+   - Compatibility with `QuickCheck-2.12`+ ## Changes in 2.5.5   - Use `module[line:column]` instead of `module:line:column` as default label     for `describe`/`it` (fixes #366)
hspec-core/src/Test/Hspec/Core/Example/Location.hs view
@@ -26,7 +26,11 @@ } deriving (Eq, Show, Read)  extractLocation :: SomeException -> Maybe Location-extractLocation e = locationFromErrorCall e <|> locationFromPatternMatchFail e <|> locationFromIOException e+extractLocation e =+      locationFromErrorCall e+  <|> locationFromPatternMatchFail e+  <|> locationFromRecConError e+  <|> locationFromIOException e  locationFromErrorCall :: SomeException -> Maybe Location locationFromErrorCall e = case fromException e of@@ -42,6 +46,11 @@ locationFromPatternMatchFail :: SomeException -> Maybe Location locationFromPatternMatchFail e = case fromException e of   Just (PatternMatchFail s) -> listToMaybe (words s) >>= parseSourceSpan+  Nothing -> Nothing++locationFromRecConError :: SomeException -> Maybe Location+locationFromRecConError e = case fromException e of+  Just (RecConError s) -> listToMaybe (words s) >>= parseSourceSpan   Nothing -> Nothing  locationFromIOException :: SomeException -> Maybe Location
hspec-core/src/Test/Hspec/Core/Formatters.hs view
@@ -48,6 +48,7 @@ , withPendingColor , withFailColor +, useDiff , extraChunk , missingChunk @@ -94,6 +95,7 @@   , withPendingColor   , withFailColor +  , useDiff   , extraChunk   , missingChunk   )@@ -209,7 +211,11 @@         ExpectedButGot preface expected actual -> do           mapM_ indent preface -          let chunks = diff expected actual+          b <- useDiff+          let+            chunks+              | b = diff expected actual+              | otherwise = [First expected, Second actual]            withFailColor $ write (indentation ++ "expected: ")           forM_ chunks $ \chunk -> case chunk of
hspec-core/src/Test/Hspec/Core/Formatters/Internal.hs view
@@ -68,6 +68,7 @@ , environmentWithSuccessColor = withSuccessColor , environmentWithPendingColor = withPendingColor , environmentWithInfoColor = withInfoColor+, environmentUseDiff = gets (formatConfigUseDiff . stateConfig) , environmentExtraChunk = extraChunk , environmentMissingChunk = missingChunk , environmentLiftIO = liftIO
hspec-core/src/Test/Hspec/Core/Formatters/Monad.hs view
@@ -30,6 +30,7 @@ , withPendingColor , withFailColor +, useDiff , extraChunk , missingChunk @@ -97,6 +98,7 @@   | forall a. WithSuccessColor (FormatM a) (a -> next)   | forall a. WithPendingColor (FormatM a) (a -> next)   | forall a. WithInfoColor (FormatM a) (a -> next)+  | UseDiff (Bool -> next)   | ExtraChunk String next   | MissingChunk String next   | forall a. LiftIO (IO a) (a -> next)@@ -115,6 +117,7 @@     WithSuccessColor action next -> WithSuccessColor action (fmap f next)     WithPendingColor action next -> WithPendingColor action (fmap f next)     WithInfoColor action next -> WithInfoColor action (fmap f next)+    UseDiff next -> UseDiff (fmap f next)     ExtraChunk s next -> ExtraChunk s (f next)     MissingChunk s next -> MissingChunk s (f next)     LiftIO action next -> LiftIO action (fmap f next)@@ -137,6 +140,7 @@ , environmentWithSuccessColor :: forall a. m a -> m a , environmentWithPendingColor :: forall a. m a -> m a , environmentWithInfoColor :: forall a. m a -> m a+, environmentUseDiff :: m Bool , environmentExtraChunk :: String -> m () , environmentMissingChunk :: String -> m () , environmentLiftIO :: forall a. IO a -> m a@@ -161,6 +165,7 @@         WithSuccessColor inner next -> environmentWithSuccessColor (go inner) >>= go . next         WithPendingColor inner next -> environmentWithPendingColor (go inner) >>= go . next         WithInfoColor inner next -> environmentWithInfoColor (go inner) >>= go . next+        UseDiff next -> environmentUseDiff >>= go . next         ExtraChunk s next -> environmentExtraChunk s >> go next         MissingChunk s next -> environmentMissingChunk s >> go next         LiftIO inner next -> environmentLiftIO inner >>= go . next@@ -227,6 +232,10 @@ -- default color. withInfoColor :: FormatM a -> FormatM a withInfoColor s = liftF (WithInfoColor s id)++-- | Return `True` if the user requested colorized diffs, `False` otherwise.+useDiff :: FormatM Bool+useDiff = liftF (UseDiff id)  -- | Output given chunk in red. extraChunk :: String -> FormatM ()
hspec-core/src/Test/Hspec/Core/QuickCheck.hs view
@@ -1,9 +1,10 @@ -- | Stability: provisional module Test.Hspec.Core.QuickCheck (-  modifyMaxSuccess+  modifyArgs+, modifyMaxSuccess , modifyMaxDiscardRatio , modifyMaxSize-+, modifyMaxShrinks ) where  import           Test.QuickCheck@@ -30,6 +31,14 @@     modify :: (Int -> Int) -> Args -> Args     modify f args = args {maxSize = f (maxSize args)} +-- | Use a modified `maxShrinks` for given spec.+modifyMaxShrinks :: (Int -> Int) -> SpecWith a -> SpecWith a+modifyMaxShrinks = modifyArgs . modify+  where+    modify :: (Int -> Int) -> Args -> Args+    modify f args = args {maxShrinks = f (maxShrinks args)}++-- | Use modified `Args` for given spec. modifyArgs :: (Args -> Args) -> SpecWith a -> SpecWith a modifyArgs = modifyParams . modify   where
hspec-core/src/Test/Hspec/Core/Runner.hs view
@@ -47,24 +47,24 @@ -- | Filter specs by given predicate. -- -- The predicate takes a list of "describe" labels and a "requirement".-filterSpecs :: Config -> [SpecTree a] -> [SpecTree a]+filterSpecs :: Config -> [EvalTree] -> [EvalTree] filterSpecs c = go []   where     p :: Path -> Bool     p path = (fromMaybe (const True) (configFilterPredicate c) path) &&                not (fromMaybe (const False) (configSkipPredicate c) path) -    go :: [String] -> [SpecTree a] -> [SpecTree a]+    go :: [String] -> [EvalTree] -> [EvalTree]     go groups = mapMaybe (goSpec groups) -    goSpecs :: [String] -> [SpecTree a] -> ([SpecTree a] -> b) -> Maybe b+    goSpecs :: [String] -> [EvalTree] -> ([EvalTree] -> b) -> Maybe b     goSpecs groups specs ctor = case go groups specs of       [] -> Nothing       xs -> Just (ctor xs) -    goSpec :: [String] -> SpecTree a -> Maybe (SpecTree a)+    goSpec :: [String] -> EvalTree -> Maybe (EvalTree)     goSpec groups spec = case spec of-      Leaf item -> guard (p (groups, itemRequirement item)) >> return spec+      Leaf item -> guard (p (groups, evalItemDescription item)) >> return spec       Node group specs -> goSpecs (groups ++ [group]) specs (Node group)       NodeWithCleanup action specs -> goSpecs groups specs (NodeWithCleanup action) @@ -159,7 +159,7 @@      let params = Params (configQuickCheckArgs config) (configSmallCheckDepth config) -    filteredSpec <- map (toEvalTree params) . filterSpecs config . applyDryRun config <$> runSpecM spec+    filteredSpec <- filterSpecs config . mapMaybe (toEvalTree params) . applyDryRun config <$> runSpecM (focus spec)      (total, failures) <- withHiddenCursor useColor h $ do       let@@ -181,13 +181,15 @@     dumpFailureReport config seed qcArgs failures     return (Summary total (length failures)) -toEvalTree :: Params -> SpecTree () -> EvalTree+toEvalTree :: Params -> SpecTree () -> Maybe EvalTree toEvalTree params = go   where+    go :: Tree (() -> c) (Item ()) -> Maybe (Tree c EvalItem)     go t = case t of-      Node s xs -> Node s (map go xs)-      NodeWithCleanup c xs -> NodeWithCleanup (c ()) (map go xs)-      Leaf (Item requirement loc isParallelizable e)  -> Leaf (EvalItem requirement loc (fromMaybe False isParallelizable) (e params $ ($ ())))+      Node s xs -> Just $ Node s (mapMaybe go xs)+      NodeWithCleanup c xs -> Just $ NodeWithCleanup (c ()) (mapMaybe go xs)+      Leaf (Item requirement loc isParallelizable isFocused e) ->+        guard isFocused >> return (Leaf (EvalItem requirement loc (fromMaybe False isParallelizable) (e params $ ($ ()))))  dumpFailureReport :: Config -> Integer -> QC.Args -> [Path] -> IO () dumpFailureReport config seed qcArgs xs = do
hspec-core/src/Test/Hspec/Core/Spec.hs view
@@ -18,6 +18,13 @@ , xspecify , xdescribe , xcontext++, focus+, fit+, fspecify+, fdescribe+, fcontext+ , parallel , sequential @@ -91,6 +98,34 @@ -- | @xspecify@ is an alias for `xit`. xspecify :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a) xspecify = xit++-- | `focus` focuses all spec items of the given spec.+--+-- Applying `focus` to a spec with focused spec items has no effect.+focus :: SpecWith a -> SpecWith a+focus spec = do+  xs <- runIO (runSpecM spec)+  let+    ys+      | any (any itemIsFocused) xs = xs+      | otherwise = map (bimapTree id (\ item -> item {itemIsFocused = True})) xs+  fromSpecList ys++-- | @fit@ is an alias for @fmap focus . it@+fit :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a)+fit = fmap focus . it++-- | @fspecify@ is an alias for `fit`.+fspecify :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a)+fspecify = fit++-- | @fdescribe@ is an alias for @fmap focus . describe@+fdescribe :: HasCallStack => String -> SpecWith a -> SpecWith a+fdescribe = fmap focus . describe++-- | @fcontext@ is an alias for `fdescribe`.+fcontext :: HasCallStack => String -> SpecWith a -> SpecWith a+fcontext = fdescribe  -- | `parallel` marks all spec items of the given spec to be safe for parallel -- evaluation.
hspec-core/src/Test/Hspec/Core/Spec/Monad.hs view
@@ -53,12 +53,7 @@ mapSpecTree f (SpecM specs) = SpecM (mapWriterT (fmap (second (map f))) specs)  mapSpecItem :: (ActionWith a -> ActionWith b) -> (Item a -> Item b) -> SpecWith a -> SpecWith b-mapSpecItem g f = mapSpecTree go-  where-    go spec = case spec of-      Node d xs -> Node d (map go xs)-      NodeWithCleanup cleanup xs -> NodeWithCleanup (g cleanup) (map go xs)-      Leaf item -> Leaf (f item)+mapSpecItem g f = mapSpecTree (bimapTree g f)  mapSpecItem_ :: (Item a -> Item a) -> SpecWith a -> SpecWith a mapSpecItem_ = mapSpecItem id
hspec-core/src/Test/Hspec/Core/Tree.hs view
@@ -12,6 +12,7 @@ , Item (..) , specGroup , specItem+, bimapTree , location ) where @@ -28,12 +29,20 @@     Node String [Tree c a]   | NodeWithCleanup c [Tree c a]   | Leaf a-  deriving (Functor, Foldable, Traversable)+  deriving (Show, Eq, Functor, Foldable, Traversable)  -- | A tree is used to represent a spec internally.  The tree is parametrize -- over the type of cleanup actions and the type of the actual spec items. type SpecTree a = Tree (ActionWith a) (Item a) +bimapTree :: (a -> b) -> (c -> d) -> Tree a c -> Tree b d+bimapTree g f = go+  where+    go spec = case spec of+      Node d xs -> Node d (map go xs)+      NodeWithCleanup cleanup xs -> NodeWithCleanup (g cleanup) (map go xs)+      Leaf item -> Leaf (f item)+ -- | -- @Item@ is used to represent spec items internally.  A spec item consists of: --@@ -45,13 +54,20 @@ -- example, including QuickCheck properties, Hspec expectations and HUnit -- assertions. data Item a = Item {+   -- | Textual description of behavior   itemRequirement :: String+   -- | Source location of the spec item , itemLocation :: Maybe Location+   -- | A flag that indicates whether it is safe to evaluate this spec item in   -- parallel with other spec items , itemIsParallelizable :: Maybe Bool++  -- | A flag that indicates whether this spec item is focused.+, itemIsFocused :: Bool+   -- | Example for behavior , itemExample :: Params -> (ActionWith a -> IO ()) -> ProgressCallback -> IO Result }@@ -67,7 +83,7 @@  -- | The @specItem@ function creates a spec item. specItem :: (HasCallStack, Example a) => String -> a -> SpecTree (Arg a)-specItem s e = Leaf $ Item requirement location Nothing (safeEvaluateExample e)+specItem s e = Leaf $ Item requirement location Nothing False (safeEvaluateExample e)   where     requirement :: HasCallStack => String     requirement
hspec-meta.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.30.0.+-- This file has been generated from package.yaml by hpack version 0.31.0. -- -- see: https://github.com/sol/hpack ----- hash: b9089eec6ed9c224790a988a565a1089609beb176824d8eafe653098556dc71c+-- hash: 09929585045f559b6f4dc8e49667a90bf2260d46c6a0ef0d02b2bdd4d40fb9de  name:             hspec-meta-version:          2.5.6+version:          2.6.0 license:          MIT license-file:     LICENSE copyright:        (c) 2011-2018 Simon Hengel,@@ -34,7 +34,6 @@       Test.Hspec.Meta   other-modules:       Test.Hspec-      Test.Hspec.Core       Test.Hspec.Discover       Test.Hspec.Formatters       Test.Hspec.QuickCheck@@ -73,7 +72,7 @@       hspec-core/vendor   build-depends:       HUnit-    , QuickCheck >=2.5.1+    , QuickCheck >=2.10     , ansi-terminal     , array     , base ==4.*@@ -82,7 +81,7 @@     , deepseq     , directory     , filepath-    , hspec-expectations >=0.8.0+    , hspec-expectations ==0.8.2.*     , quickcheck-io     , random     , setenv@@ -99,7 +98,7 @@   ghc-options: -Wall   build-depends:       HUnit-    , QuickCheck >=2.5.1+    , QuickCheck >=2.10     , ansi-terminal     , array     , base ==4.*@@ -108,7 +107,7 @@     , deepseq     , directory     , filepath-    , hspec-expectations >=0.8.0+    , hspec-expectations ==0.8.2.*     , quickcheck-io     , random     , setenv
src/Test/Hspec.hs view
@@ -39,6 +39,16 @@ , xdescribe , xcontext +-- * Focused spec items+-- |+-- During a test run, when a spec contains /focused/ spec items, all other spec+-- items are ignored.+, focus+, fit+, fspecify+, fdescribe+, fcontext+ -- * Hooks , ActionWith , before
− src/Test/Hspec/Core.hs
@@ -1,18 +0,0 @@--- | Stability: unstable-module Test.Hspec.Core {-# DEPRECATED "use \"Test.Hspec.Core.Spec\" instead" #-} (-  module Test.Hspec.Core.Spec--- * Deprecated functions-, describe-, it-) where--import           Test.Hspec.Core.Spec hiding (describe, it)---{-# DEPRECATED describe "use `specGroup` instead" #-}-describe :: String -> [SpecTree a] -> SpecTree a-describe = specGroup--{-# DEPRECATED it "use `specItem` instead" #-}-it :: Example a => String -> a -> SpecTree (Arg a)-it = specItem
src/Test/Hspec/QuickCheck.hs view
@@ -2,9 +2,11 @@ {-# LANGUAGE ConstraintKinds #-} module Test.Hspec.QuickCheck ( -- * Params-  modifyMaxSuccess+  modifyArgs+, modifyMaxSuccess , modifyMaxDiscardRatio , modifyMaxSize+, modifyMaxShrinks  -- * Shortcuts , prop