hspec 1.4.0.1 → 1.4.1
raw patch · 5 files changed
+21/−15 lines, 5 filesdep ~hspec-expectationsPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: hspec-expectations
API changes (from Hackage documentation)
+ Test.Hspec.Runner: configPrintCpuTime :: Config -> Bool
- Test.Hspec.Formatters: getCPUTime :: FormatM Double
+ Test.Hspec.Formatters: getCPUTime :: FormatM (Maybe Double)
- Test.Hspec.Runner: Config :: Bool -> Bool -> Maybe (Path -> Bool) -> Params -> ColorMode -> Formatter -> Bool -> Handle -> Config
+ Test.Hspec.Runner: Config :: Bool -> Bool -> Bool -> Maybe (Path -> Bool) -> Params -> ColorMode -> Formatter -> Bool -> Handle -> Config
Files
- hspec.cabal +2/−2
- src/Test/Hspec/Config.hs +5/−2
- src/Test/Hspec/Formatters.hs +3/−2
- src/Test/Hspec/Formatters/Internal.hs +10/−8
- src/Test/Hspec/Runner.hs +1/−1
hspec.cabal view
@@ -1,5 +1,5 @@ name: hspec-version: 1.4.0.1+version: 1.4.1 license: BSD3 license-file: LICENSE copyright: (c) 2011-2012 Trystan Spangler, (c) 2011-2012 Simon Hengel, (c) 2011 Greg Weber@@ -38,7 +38,7 @@ , transformers >= 0.2.2.0 && < 0.4.0 , HUnit >= 1.2.5 , QuickCheck >= 2.4.0.1 && < 2.6- , hspec-expectations == 0.3.0.*+ , hspec-expectations exposed-modules: Test.Hspec Test.Hspec.Core
src/Test/Hspec/Config.hs view
@@ -23,6 +23,7 @@ data Config = Config { configVerbose :: Bool+, configPrintCpuTime :: Bool , configReRun :: Bool -- |@@ -39,7 +40,7 @@ data ColorMode = ColorAuto | ColorNever | ColorAlway defaultConfig :: Config-defaultConfig = Config False False Nothing defaultParams ColorAuto specdoc False stdout+defaultConfig = Config False False False Nothing defaultParams ColorAuto specdoc False stdout formatters :: [(String, Formatter)] formatters = [@@ -73,12 +74,14 @@ , Option [] ["color"] (OptArg setColor "WHEN") "colorize the output. WHEN defaults to `always' or can be `never' or `auto'." , Option "f" ["format"] (ReqArg setFormatter "FORMATTER") formatHelp , Option "a" ["maximum-generated-tests"] (ReqArg setQC_MaxSuccess "NUMBER") "how many automated tests something like QuickCheck should try, by default"+ , Option [] ["print-cpu-time"] (NoArg setPrintCpuTime) "include used CPU time in summary" ] where setFilter :: String -> Result -> Result setFilter pattern x = configAddFilter (filterPredicate pattern) <$> x - setVerbose x = x >>= \c -> return c {configVerbose = True}+ setVerbose x = x >>= \c -> return c {configVerbose = True}+ setPrintCpuTime x = x >>= \c -> return c {configPrintCpuTime = True} setFormatter name x = x >>= \c -> case lookup name formatters of Nothing -> Left (InvalidArgument "format" name)
src/Test/Hspec/Formatters.hs view
@@ -167,12 +167,13 @@ defaultFooter :: FormatM () defaultFooter = do - writeLine =<< printf "Finished in %1.4f seconds, used %1.4f seconds of CPU time" <$> getRealTime <*> getCPUTime+ writeLine =<< (++)+ <$> (printf "Finished in %1.4f seconds"+ <$> getRealTime) <*> (maybe "" (printf ", used %1.4f seconds of CPU time") <$> getCPUTime) fails <- getFailCount pending <- getPendingCount total <- getTotalCount- writeLine "" let c | fails /= 0 = withFailColor | pending /= 0 = withPendingColor
src/Test/Hspec/Formatters/Internal.hs view
@@ -72,7 +72,7 @@ , pendingCount :: Int , failCount :: Int , failMessages :: [FailureRecord]-, cpuStartTime :: Integer+, cpuStartTime :: Maybe Integer , startTime :: POSIXTime } @@ -83,10 +83,10 @@ newtype FormatM a = FormatM (StateT FormatterState IO a) deriving (Functor, Applicative, Monad) -runFormatM :: Bool -> Bool -> Handle -> FormatM a -> IO a-runFormatM useColor produceHTML_ handle (FormatM action) = do+runFormatM :: Bool -> Bool -> Bool -> Handle -> FormatM a -> IO a+runFormatM useColor produceHTML_ printCpuTime handle (FormatM action) = do time <- getPOSIXTime- cpuTime <- CPUTime.getCPUTime+ cpuTime <- if printCpuTime then Just <$> CPUTime.getCPUTime else pure Nothing evalStateT action (FormatterState handle useColor produceHTML_ False 0 0 0 [] cpuTime time) -- | Increase the counter for successful examples@@ -223,11 +223,13 @@ (runStateT action st) -- | Get the used CPU time since the test run has been started.-getCPUTime :: FormatM Double+getCPUTime :: FormatM (Maybe Double) getCPUTime = do- t1 <- liftIO CPUTime.getCPUTime- t0 <- gets cpuStartTime- return (fromIntegral (t1 - t0) / (10.0^(12::Integer)))+ t1 <- liftIO CPUTime.getCPUTime+ mt0 <- gets cpuStartTime+ return $ toSeconds <$> ((-) <$> pure t1 <*> mt0)+ where+ toSeconds x = fromIntegral x / (10.0 ^ (12 :: Integer)) -- | Get the passed real time since the test run has been started. getRealTime :: FormatM Double
src/Test/Hspec/Runner.hs view
@@ -110,7 +110,7 @@ h = configHandle c useColor <- doesUseColor h c- runFormatM useColor (configHtmlOutput c) h $ do+ runFormatM useColor (configHtmlOutput c) (configPrintCpuTime c) h $ do runFormatter c formatter (maybe id filterSpecs (configFilterPredicate c) $ runSpecM spec) failedFormatter formatter footerFormatter formatter