packages feed

hspec-core 2.7.9 → 2.7.10

raw patch · 9 files changed

+83/−26 lines, 9 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Test.Hspec.Core.Formatters: [exampleStarted] :: Formatter -> Path -> FormatM ()
+ Test.Hspec.Core.Formatters: checks :: Formatter
- Test.Hspec.Core.Formatters: Formatter :: FormatM () -> ([String] -> String -> FormatM ()) -> FormatM () -> (Path -> Progress -> FormatM ()) -> (Path -> String -> FormatM ()) -> (Path -> String -> FailureReason -> FormatM ()) -> (Path -> String -> Maybe String -> FormatM ()) -> FormatM () -> FormatM () -> Formatter
+ Test.Hspec.Core.Formatters: Formatter :: FormatM () -> ([String] -> String -> FormatM ()) -> FormatM () -> (Path -> FormatM ()) -> (Path -> Progress -> FormatM ()) -> (Path -> String -> FormatM ()) -> (Path -> String -> FailureReason -> FormatM ()) -> (Path -> String -> Maybe String -> FormatM ()) -> FormatM () -> FormatM () -> Formatter

Files

hspec-core.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.3.+-- This file has been generated from package.yaml by hpack version 0.34.4. -- -- see: https://github.com/sol/hpack  name:             hspec-core-version:          2.7.9+version:          2.7.10 license:          MIT license-file:     LICENSE copyright:        (c) 2011-2021 Simon Hengel,
src/Test/Hspec/Core/Config/Options.hs view
@@ -159,7 +159,8 @@   where     formatters :: [(String, Formatter)]     formatters = [-        ("specdoc", specdoc)+        ("checks", checks)+      , ("specdoc", specdoc)       , ("progress", progress)       , ("failed-examples", failed_examples)       , ("silent", silent)
src/Test/Hspec/Core/Format.hs view
@@ -33,5 +33,6 @@ , formatGroupStarted :: Path -> m () , formatGroupDone :: Path -> m () , formatProgress :: Path -> Progress -> m ()-, formatItem :: Path -> Item -> m ()+, formatItemStarted :: Path -> m ()+, formatItemDone :: Path -> Item -> m () }
src/Test/Hspec/Core/Formatters.hs view
@@ -8,6 +8,7 @@  -- * Formatters   silent+, checks , specdoc , progress , failed_examples@@ -110,6 +111,7 @@   headerFormatter     = return () , exampleGroupStarted = \_ _ -> return () , exampleGroupDone    = return ()+, exampleStarted      = \_ -> return () , exampleProgress     = \_ _ -> return () , exampleSucceeded    = \ _ _ -> return () , exampleFailed       = \_ _ _ -> return ()@@ -117,6 +119,40 @@ , failedFormatter     = return () , footerFormatter     = return () }++checks :: Formatter+checks = specdoc {+  exampleStarted = \(nesting, requirement) -> do+    writeTransient $ indentationFor nesting ++ requirement ++ " [ ]"++, exampleProgress = \(nesting, requirement) p -> do+    writeTransient $ indentationFor nesting ++ requirement ++ " [" ++ (formatProgress p) ++ "]"++, exampleSucceeded = \(nesting, requirement) info -> do+    writeResult nesting requirement info $ withSuccessColor $ write "✔"++, exampleFailed = \(nesting, requirement) info _ -> do+    writeResult nesting requirement info $ withFailColor $ write "✘"++, examplePending = \(nesting, requirement) info reason -> do+    writeResult nesting requirement info $ withPendingColor $ write "‐"++    withPendingColor $ do+      writeLine $ indentationFor ("" : nesting) ++ "# PENDING: " ++ fromMaybe "No reason given" reason+} where+    indentationFor nesting = replicate (length nesting * 2) ' '++    writeResult :: [String] -> String -> String -> FormatM () -> FormatM ()+    writeResult nesting requirement info action = do+      write $ indentationFor nesting ++ requirement ++ " ["+      action+      writeLine "]"+      forM_ (lines info) $ \ s ->+        writeLine $ indentationFor ("" : nesting) ++ s++    formatProgress (current, total)+      | total == 0 = show current+      | otherwise  = show current ++ "/" ++ show total  specdoc :: Formatter specdoc = silent {
src/Test/Hspec/Core/Formatters/Internal.hs view
@@ -40,9 +40,14 @@     return a , formatGroupStarted = \ (nesting, name) -> interpret $ M.exampleGroupStarted formatter nesting name , formatGroupDone = \ _ -> interpret (M.exampleGroupDone formatter)-, formatProgress = \ path progress -> when useColor $ do++, formatProgress = \ path progress -> do     interpret $ M.exampleProgress formatter path progress-, formatItem = \ path (Item loc _duration info result) -> do++, formatItemStarted = \ path -> do+    interpret $ M.exampleStarted formatter path++, formatItemDone = \ path (Item loc _duration info result) -> do     clearTransientOutput     case result of       Success -> do@@ -54,8 +59,7 @@       Failure err -> do         addFailMessage loc path err         interpret $ M.exampleFailed formatter path info err-} where-    useColor = formatConfigUseColor config+}  interpret :: M.FormatM a -> FormatM a interpret = interpretWith Environment {@@ -161,11 +165,13 @@  writeTransient :: String -> FormatM () writeTransient new = do-  old <- gets stateTransientOutput-  write $ old `overwriteWith` new-  modify $ \ state -> state {stateTransientOutput = new}-  h <- getHandle-  liftIO $ IO.hFlush h+  useColor <- getConfig formatConfigUseColor+  when (useColor) $ do+    old <- gets stateTransientOutput+    write $ old `overwriteWith` new+    modify $ \ state -> state {stateTransientOutput = new}+    h <- getHandle+    liftIO $ IO.hFlush h  clearTransientOutput :: FormatM () clearTransientOutput = do
src/Test/Hspec/Core/Formatters/Monad.hs view
@@ -56,11 +56,13 @@ -- | evaluated before each test group , exampleGroupStarted :: [String] -> String -> FormatM () +-- | evaluated after each test group , exampleGroupDone :: FormatM () +-- | evaluated before each example+, exampleStarted :: Path -> FormatM ()+ -- | used to notify the progress of the currently evaluated example------ /Note/: This is only called when interactive/color mode. , exampleProgress :: Path -> Progress -> FormatM ()  -- | evaluated after each successful example
src/Test/Hspec/Core/Runner/Eval.hs view
@@ -66,10 +66,20 @@ getFormat :: Monad m => (Format m -> a) -> EvalM m a getFormat format = gets (format . evalConfigFormat . stateConfig) -reportItem :: Monad m => Path -> Format.Item -> EvalM m ()-reportItem path item = do+reportItem :: Monad m => Path -> Maybe Location -> EvalM m (Seconds, Result)  -> EvalM m ()+reportItem path loc action = do+  reportItemStarted path+  action >>= reportResult path loc++reportItemStarted :: Monad m => Path -> EvalM m ()+reportItemStarted path = do+  format <- getFormat formatItemStarted+  lift (format path)++reportItemDone :: Monad m => Path -> Format.Item -> EvalM m ()+reportItemDone path item = do   addResult path item-  format <- getFormat formatItem+  format <- getFormat formatItemDone   lift (format path item)  failureItem :: Maybe Location -> Seconds -> String -> FailureReason -> Format.Item@@ -79,10 +89,10 @@ reportResult path loc (duration, result) = do   case result of     Result info status -> case status of-      Success -> reportItem path (Format.Item loc duration info Format.Success)-      Pending loc_ reason -> reportItem path (Format.Item (loc_ <|> loc) duration info $ Format.Pending reason)-      Failure loc_ err@(Error _ e) -> reportItem path (failureItem (loc_ <|> extractLocation e <|> loc) duration info err)-      Failure loc_ err -> reportItem path (failureItem (loc_ <|> loc) duration info err)+      Success -> reportItemDone path (Format.Item loc duration info Format.Success)+      Pending loc_ reason -> reportItemDone path (Format.Item (loc_ <|> loc) duration info $ Format.Pending reason)+      Failure loc_ err@(Error _ e) -> reportItemDone path (failureItem (loc_ <|> extractLocation e <|> loc) duration info err)+      Failure loc_ err -> reportItemDone path (failureItem (loc_ <|> loc) duration info err)  groupStarted :: Monad m => Path -> EvalM m () groupStarted path = do@@ -214,13 +224,13 @@       r <- liftIO $ measure $ safeEvaluate (action >> return (Result "" Success))       case r of         (_, Result "" Success) -> return ()-        _ -> reportResult path Nothing r+        _ -> reportItem path Nothing (return r)       where         path = (groups, "afterAll-hook")      evalItem :: [String] -> RunningItem m -> EvalM m ()     evalItem groups (Item requirement loc action) = do-      lift (action path) >>= reportResult path loc+      reportItem path loc $ lift (action path)       where         path :: Path         path = (groups, requirement)
test/Test/Hspec/Core/HooksSpec.hs view
@@ -30,7 +30,8 @@     , formatGroupStarted = \ _ -> return ()     , formatGroupDone = \ _ -> return ()     , formatProgress = \ _ _ -> return ()-    , formatItem = \ _ _ -> return ()+    , formatItemStarted = \ _ -> return ()+    , formatItemDone = \ _ _ -> return ()     }     normalize = map $ \ (path, item) -> (pathToList path, normalizeItem item)     normalizeItem item = item {itemLocation = Nothing, itemDuration = 0}
version.yaml view
@@ -1,1 +1,1 @@-&version 2.7.9+&version 2.7.10