hspec-core 2.0.1 → 2.0.2
raw patch · 8 files changed
+41/−24 lines, 8 files
Files
- hspec-core.cabal +1/−1
- src/Test/Hspec/Config.hs +2/−1
- src/Test/Hspec/Core/Example.hs +7/−1
- src/Test/Hspec/Core/Formatters.hs +13/−10
- src/Test/Hspec/Options.hs +2/−1
- test/Helper.hs +1/−1
- test/Test/Hspec/Core/FormattersSpec.hs +6/−6
- test/Test/Hspec/Core/RunnerSpec.hs +9/−3
hspec-core.cabal view
@@ -1,5 +1,5 @@ name: hspec-core-version: 2.0.1+version: 2.0.2 license: MIT license-file: LICENSE copyright: (c) 2011-2014 Simon Hengel,
src/Test/Hspec/Config.hs view
@@ -16,6 +16,7 @@ import Test.Hspec.Options import Test.Hspec.FailureReport import Test.Hspec.Core.QuickCheckUtil (mkGen)+import Test.Hspec.Core.Example (Params(..), defaultParams) -- | Add a filter predicate to config. If there is already a filter predicate, -- then combine them with `||`.@@ -50,7 +51,7 @@ maybe id setSeed (configQuickCheckSeed c) . maybe id setMaxDiscardRatio (configQuickCheckMaxDiscardRatio c) . maybe id setMaxSize (configQuickCheckMaxSize c)- . maybe id setMaxSuccess (configQuickCheckMaxSuccess c)) QC.stdArgs+ . maybe id setMaxSuccess (configQuickCheckMaxSuccess c)) (paramsQuickCheckArgs defaultParams) setMaxSuccess :: Int -> QC.Args -> QC.Args setMaxSuccess n args = args {QC.maxSuccess = n}
src/Test/Hspec/Core/Example.hs view
@@ -2,6 +2,7 @@ module Test.Hspec.Core.Example ( Example (..) , Params (..)+, defaultParams , ActionWith , Progress , ProgressCallback@@ -18,7 +19,6 @@ import qualified Test.QuickCheck.State as QC import qualified Test.QuickCheck.Property as QCP-import qualified Test.QuickCheck.IO () import Test.Hspec.Core.QuickCheckUtil import Test.Hspec.Core.Util@@ -36,6 +36,12 @@ paramsQuickCheckArgs :: QC.Args , paramsSmallCheckDepth :: Int } deriving (Show)++defaultParams :: Params+defaultParams = Params {+ paramsQuickCheckArgs = QC.stdArgs+, paramsSmallCheckDepth = 5+} type Progress = (Int, Int) type ProgressCallback = Progress -> IO ()
src/Test/Hspec/Core/Formatters.hs view
@@ -158,15 +158,18 @@ failures <- getFailMessages - forM_ (zip [1..] failures) $ \x -> do- formatFailure x+ unless (null failures) $ do+ writeLine "Failures:" writeLine "" - when (hasBestEffortLocations failures) $ do- withInfoColor $ writeLine "Source locations marked with \"best-effort\" are calculated heuristically and may be incorrect."- writeLine ""+ forM_ (zip [1..] failures) $ \x -> do+ formatFailure x+ writeLine "" - unless (null failures) $ do+ when (hasBestEffortLocations failures) $ do+ withInfoColor $ writeLine "Source locations marked with \"best-effort\" are calculated heuristically and may be incorrect."+ writeLine ""+ write "Randomized with seed " >> usedSeed >>= writeLine . show writeLine "" where@@ -178,17 +181,17 @@ formatFailure :: (Int, FailureRecord) -> FormatM () formatFailure (n, FailureRecord mLoc path reason) = do- write (show n ++ ") ")+ write (" " ++ show n ++ ") ") writeLine (formatRequirement path) withFailColor $ do- unless (null err) $ do- writeLine err+ forM_ (lines err) $ \x -> do+ writeLine (" " ++ x) forM_ mLoc $ \loc -> do writeLine "" withInfoColor $ writeLine (formatLoc loc) where err = either (("uncaught exception: " ++) . formatException) id reason- formatLoc (Location file line _column accuracy) = "# " ++ file ++ ":" ++ show line ++ bestEffortMarking+ formatLoc (Location file line _column accuracy) = " # " ++ file ++ ":" ++ show line ++ bestEffortMarking where bestEffortMarking = case accuracy of ExactLocation -> ""
src/Test/Hspec/Options.hs view
@@ -15,6 +15,7 @@ import Test.Hspec.Core.Formatters import Test.Hspec.Compat import Test.Hspec.Core.Util+import Test.Hspec.Core.Example (Params(..), defaultParams) data Config = Config { configDryRun :: Bool@@ -48,7 +49,7 @@ , configQuickCheckMaxSuccess = Nothing , configQuickCheckMaxDiscardRatio = Nothing , configQuickCheckMaxSize = Nothing-, configSmallCheckDepth = 5+, configSmallCheckDepth = paramsSmallCheckDepth defaultParams , configColorMode = ColorAuto , configFormatter = Nothing , configHtmlOutput = False
test/Helper.hs view
@@ -68,7 +68,7 @@ | otherwise = x defaultParams :: H.Params-defaultParams = H.Params stdArgs {replay = Just (mkGen 23, 0), maxSuccess = 1000} (H.configSmallCheckDepth H.defaultConfig)+defaultParams = H.defaultParams {H.paramsQuickCheckArgs = stdArgs {replay = Just (mkGen 23, 0), maxSuccess = 1000}} noOpProgressCallback :: H.ProgressCallback noOpProgressCallback _ = return ()
test/Test/Hspec/Core/FormattersSpec.hs view
@@ -141,14 +141,14 @@ context "displays a detailed list of failures" $ do it "prints all requirements that are not met" $ do r <- runSpec testSpec- r `shouldSatisfy` any (== "1) Example fail 1")+ r `shouldSatisfy` any (== " 1) Example fail 1") it "prints the exception type for requirements that fail due to an uncaught exception" $ do r <- runSpec $ do H.it "foobar" (undefined :: Bool) r `shouldContain` [- "1) foobar"- , "uncaught exception: ErrorCall (Prelude.undefined)"+ " 1) foobar"+ , " uncaught exception: ErrorCall (Prelude.undefined)" ] it "prints all descriptions when a nested requirement fails" $ do@@ -156,7 +156,7 @@ H.describe "foo" $ do H.describe "bar" $ do H.it "baz" False- r `shouldSatisfy` any (== "1) foo.bar baz")+ r `shouldSatisfy` any (== " 1) foo.bar baz") context "when a failed example has a source location" $ do@@ -168,7 +168,7 @@ addLoc e = e {H.itemLocation = Just loc} r <- runSpec $ H.mapSpecItem_ addLoc $ do H.it "foo" False- r `shouldSatisfy` any (== "# test/FooSpec.hs:23")+ r `shouldSatisfy` any (== " # test/FooSpec.hs:23") it "does not include 'best-effort' explanation" $ do let loc = H.Location "test/FooSpec.hs" 23 0 H.ExactLocation@@ -183,7 +183,7 @@ addLoc e = e {H.itemLocation = Just loc} r <- runSpec $ H.mapSpecItem_ addLoc $ do H.it "foo" False- r `shouldSatisfy` any (== "# test/FooSpec.hs:23 (best-effort)")+ r `shouldSatisfy` any (== " # test/FooSpec.hs:23 (best-effort)") it "includes 'best-effort' explanation" $ do let loc = H.Location "test/FooSpec.hs" 23 0 H.BestEffort
test/Test/Hspec/Core/RunnerSpec.hs view
@@ -151,8 +151,10 @@ "" , "foo FAILED [1]" , ""- , "1) foo"+ , "Failures:" , ""+ , " 1) foo"+ , "" , "Randomized with seed 23" , "" ]@@ -222,8 +224,10 @@ , "foo" , "bar FAILED [1]" , ""- , "1) bar"+ , "Failures:" , ""+ , " 1) bar"+ , "" , "Randomized with seed 23" , "" , "Finished in 0.0000 seconds"@@ -240,7 +244,9 @@ , "foo" , " bar FAILED [1]" , ""- , "1) foo bar"+ , "Failures:"+ , ""+ , " 1) foo bar" , "" , "Randomized with seed 23" , ""