packages feed

hspec 1.4.2.3 → 1.4.3

raw patch · 15 files changed

+108/−75 lines, 15 filesdep +hspec-metadep ~HUnitdep ~QuickCheckdep ~basePVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies added: hspec-meta

Dependency ranges changed: HUnit, QuickCheck, base, doctest, silently, time, transformers

API changes (from Hackage documentation)

+ Test.Hspec.Runner: configDryRun :: Config -> Bool
- Test.Hspec.Runner: Config :: Bool -> Bool -> Bool -> Maybe (Path -> Bool) -> Params -> ColorMode -> Formatter -> Bool -> Handle -> Config
+ Test.Hspec.Runner: Config :: Bool -> Bool -> Bool -> Bool -> Maybe (Path -> Bool) -> Params -> ColorMode -> Formatter -> Bool -> Handle -> Config

Files

+ hspec-discover/example/Spec.hs view
@@ -0,0 +1,1 @@+{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
+ hspec-discover/integration-test/empty/Spec.hs view
@@ -0,0 +1,1 @@+{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
hspec-discover/test/Spec.hs view
@@ -1,5 +1,1 @@-{-# LINE 1 "hspec-discover/test/Spec.hs" #-}module Main where-import Test.Hspec-import qualified RunSpec-main :: IO ()-main = hspec $ describe "Run" RunSpec.spec+{-# OPTIONS_GHC -F -pgmF hspec-meta-discover #-}
− hspec-discover/test/Test/Hspec/Meta.hs
@@ -1,2 +0,0 @@-module Test.Hspec.Meta (module Test.Hspec) where-import Test.Hspec
hspec.cabal view
@@ -1,5 +1,5 @@ name:             hspec-version:          1.4.2.3+version:          1.4.3 license:          BSD3 license-file:     LICENSE copyright:        (c) 2011-2012 Trystan Spangler, (c) 2011-2012 Simon Hengel, (c) 2011 Greg Weber@@ -48,14 +48,14 @@   hs-source-dirs:       src   build-depends:-      base >= 4 && <= 5+      base          == 4.*     , setenv-    , silently >= 1.1.1 && < 2+    , silently      >= 1.1.1     , ansi-terminal == 0.5.*-    , time < 1.5-    , transformers >= 0.2.2.0 && < 0.4.0-    , HUnit >= 1.2.5-    , QuickCheck >= 2.4.0.1 && < 2.6+    , time+    , transformers  >= 0.2.2.0 && < 0.4.0+    , HUnit         >= 1.2.5+    , QuickCheck    >= 2.4.0.1     , hspec-expectations == 0.3.0.*   exposed-modules:       Test.Hspec@@ -84,8 +84,6 @@   other-modules:       Mock       Util-      Test.Hspec.Meta-      -- actual spec files       Test.HspecSpec       Test.Hspec.CompatSpec       Test.Hspec.Core.TypeSpec@@ -98,16 +96,17 @@   ghc-options:       -Wall -Werror   build-depends:-      base >= 4 && <= 5+      base          == 4.*     , setenv-    , silently >= 1.1.1 && < 2+    , silently      >= 1.2.4     , ansi-terminal-    , time < 1.5-    , transformers >= 0.2.2.0 && < 0.4.0-    , HUnit >= 1.2.5-    , QuickCheck >= 2.4.0.1 && < 2.6+    , time+    , transformers+    , HUnit+    , QuickCheck     , hspec-expectations +    , hspec-meta     , process     , ghc-paths @@ -121,8 +120,8 @@   hs-source-dirs:       test   build-depends:-      base-    , doctest >= 0.8+      base    == 4.*+    , doctest >= 0.9.4.1  test-suite example   type:@@ -134,7 +133,7 @@   ghc-options:       -Wall -Werror   build-depends:-      base+      base    == 4.*     , hspec     , QuickCheck @@ -149,7 +148,7 @@   other-modules:       Run   build-depends:-      base >= 4 && <= 5+      base    == 4.*     , filepath     , directory @@ -164,11 +163,38 @@   main-is:       Spec.hs   other-modules:-      Test.Hspec.Meta-      -- actual spec files       RunSpec   build-depends:-      base >= 4 && <= 5+      base    == 4.*     , filepath     , directory+    , hspec-meta++test-suite hspec-discover-example+  buildable: False+  type:+      exitcode-stdio-1.0+  ghc-options:+      -Wall -Werror+  hs-source-dirs:+      hspec-discover/example+  main-is:+      Spec.hs+  build-depends:+      base    == 4.*+    , hspec+    , QuickCheck++test-suite hspec-discover-integration-test-empty+  buildable: False+  type:+      exitcode-stdio-1.0+  ghc-options:+      -Wall -Werror+  hs-source-dirs:+      hspec-discover/integration-test/empty+  main-is:+      Spec.hs+  build-depends:+      base    == 4.*     , hspec
src/Test/Hspec/Compat.hs view
@@ -3,14 +3,14 @@  import           Data.Typeable (Typeable, typeOf, typeRepTyCon) -#if MIN_VERSION_base(4,5,0)-import           Data.Typeable (tyConModule, tyConName)+#if MIN_VERSION_base(4,4,0)+import           Data.Typeable.Internal (tyConModule, tyConName) #endif   showType :: Typeable a => a -> String showType a = let t = typeRepTyCon (typeOf a) in-#if MIN_VERSION_base(4,5,0)+#if MIN_VERSION_base(4,4,0)   tyConModule t ++ "." ++ tyConName t #else   show t
src/Test/Hspec/Config.hs view
@@ -23,6 +23,7 @@  data Config = Config {   configVerbose         :: Bool+, configDryRun          :: Bool , configPrintCpuTime    :: Bool , configReRun           :: Bool @@ -40,7 +41,7 @@ data ColorMode = ColorAuto | ColorNever | ColorAlway  defaultConfig :: Config-defaultConfig = Config False False False Nothing defaultParams ColorAuto specdoc False stdout+defaultConfig = Config False False False False Nothing defaultParams ColorAuto specdoc False stdout  formatters :: [(String, Formatter)] formatters = [@@ -81,13 +82,15 @@   , Option "f" ["format"]                  (ReqArg setFormatter "FORMATTER")  formatHelp   , Option "a" ["qc-max-success"]          (ReqArg setQC_MaxSuccess "N")      "maximum number of successful tests before a\nQuickCheck property succeeds"   , Option []  ["print-cpu-time"]          (NoArg setPrintCpuTime)            "include used CPU time in summary"+  , Option []  ["dry-run"]                 (NoArg setDryRun)                  "pretend that everything passed; don't verify\nanything"   ]   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}+    setDryRun       x = x >>= \c -> return c {configDryRun       = True}      setFormatter name x = x >>= \c -> case lookup name formatters of       Nothing -> Left (InvalidArgument "format" name)
src/Test/Hspec/Runner.hs view
@@ -54,13 +54,17 @@       | configVerbose c = id       | otherwise       = silence +    eval+      | configDryRun c = \_ -> return (Right Success)+      | otherwise      = liftIO . safeEvaluate . silence_+     go :: [String] -> (Int, SpecTree) -> FormatM ()     go rGroups (n, SpecGroup group xs) = do       exampleGroupStarted formatter n (reverse rGroups) group       mapM_ (go (group : rGroups)) (zip [0..] xs)       exampleGroupDone formatter     go rGroups (_, SpecItem requirement example) = do-      result <- (liftIO . safeEvaluate . silence_) (example $ configParams c)+      result <- eval (example $ configParams c)       case result of         Right Success -> do           increaseSuccessCount
test/Spec.hs view
@@ -1,13 +1,1 @@-{-# LINE 1 "test/Spec.hs" #-}module Main where-import Test.Hspec-import qualified Test.HspecSpec-import qualified Test.Hspec.CompatSpec-import qualified Test.Hspec.Core.TypeSpec-import qualified Test.Hspec.FailureReportSpec-import qualified Test.Hspec.FormattersSpec-import qualified Test.Hspec.HUnitSpec-import qualified Test.Hspec.QuickCheckSpec-import qualified Test.Hspec.RunnerSpec-import qualified Test.Hspec.UtilSpec-main :: IO ()-main = hspec $ describe "Test.Hspec" Test.HspecSpec.spec >> describe "Test.Hspec.Compat" Test.Hspec.CompatSpec.spec >> describe "Test.Hspec.Core.Type" Test.Hspec.Core.TypeSpec.spec >> describe "Test.Hspec.FailureReport" Test.Hspec.FailureReportSpec.spec >> describe "Test.Hspec.Formatters" Test.Hspec.FormattersSpec.spec >> describe "Test.Hspec.HUnit" Test.Hspec.HUnitSpec.spec >> describe "Test.Hspec.QuickCheck" Test.Hspec.QuickCheckSpec.spec >> describe "Test.Hspec.Runner" Test.Hspec.RunnerSpec.spec >> describe "Test.Hspec.Util" Test.Hspec.UtilSpec.spec+{-# OPTIONS_GHC -F -pgmF hspec-meta-discover #-}
test/Test/Hspec/FormattersSpec.hs view
@@ -38,7 +38,7 @@     failed_examplesSpec H.failed_examples    describe "progress" $ do-    let runSpec = capture__ . H.hspecWith H.defaultConfig {H.configFormatter = H.progress}+    let runSpec = captureLines . H.hspecWith H.defaultConfig {H.configFormatter = H.progress}      it "produces '..F...FF.F' style output" $ do       r <- runSpec testSpec@@ -48,7 +48,7 @@       failed_examplesSpec H.progress    describe "specdoc" $ do-    let runSpec = capture__ . H.hspecWith H.defaultConfig {H.configFormatter = H.specdoc}+    let runSpec = captureLines . H.hspecWith H.defaultConfig {H.configFormatter = H.specdoc}      it "displays a header for each thing being described" $ do       _:x:_ <- runSpec testSpec@@ -164,7 +164,7 @@  failed_examplesSpec :: H.Formatter -> Spec failed_examplesSpec formatter = do-  let runSpec = capture__ . H.hspecWith H.defaultConfig {H.configFormatter = formatter}+  let runSpec = captureLines . H.hspecWith H.defaultConfig {H.configFormatter = formatter}    it "summarizes the time it takes to finish" $ do     r <- runSpec (return ())@@ -198,22 +198,22 @@   -- colorized output, hence the following tests do not work on Windows. #ifndef mingw32_HOST_OS   it "shows summary in green if there are no failures" $ do-    r <- capture__ $ H.hspecWith H.defaultConfig {H.configColorMode = H.ColorAlway} $ do+    r <- captureLines $ H.hspecWith H.defaultConfig {H.configColorMode = H.ColorAlway} $ do       H.it "foobar" True     r `shouldSatisfy` any (== (green ++ "1 example, 0 failures" ++ reset))    it "shows summary in yellow if there are pending examples" $ do-    r <- capture__ $ H.hspecWith H.defaultConfig {H.configColorMode = H.ColorAlway} $ do+    r <- captureLines $ H.hspecWith H.defaultConfig {H.configColorMode = H.ColorAlway} $ do       H.it "foobar" H.pending     r `shouldSatisfy` any (== (yellow ++ "1 example, 0 failures, 1 pending" ++ reset))    it "shows summary in red if there are failures" $ do-    r <- capture__ $ H.hspecWith H.defaultConfig {H.configColorMode = H.ColorAlway} $ do+    r <- captureLines $ H.hspecWith H.defaultConfig {H.configColorMode = H.ColorAlway} $ do       H.it "foobar" False     r `shouldSatisfy` any (== (red ++ "1 example, 1 failure" ++ reset))    it "shows summary in red if there are both failures and pending examples" $ do-    r <- capture__ $ H.hspecWith H.defaultConfig {H.configColorMode = H.ColorAlway} $ do+    r <- captureLines $ H.hspecWith H.defaultConfig {H.configColorMode = H.ColorAlway} $ do       H.it "foo" False       H.it "bar" H.pending     r `shouldSatisfy` any (== (red ++ "2 examples, 1 failure, 1 pending" ++ reset))
test/Test/Hspec/HUnitSpec.hs view
@@ -1,7 +1,7 @@ module Test.Hspec.HUnitSpec (main, spec) where  import           Test.Hspec.Meta-import           Util (capture__)+import           Util (captureLines) import           Control.Applicative  import qualified Test.Hspec as H@@ -67,13 +67,13 @@      it "will show the failed assertion text if available (e.g. assertBool)" $ do       let assertionText = "some assertion text"-      r <- capture__ . runSpec $ do+      r <- captureLines . runSpec $ do         H.describe "foo" $ do           H.it "bar" (assertFailure assertionText)       r `shouldSatisfy` any (== assertionText)      it "will show the failed assertion expected and actual values if available (e.g. assertEqual)" $ do-      r <- capture__ . runSpec $ do+      r <- captureLines . runSpec $ do         H.describe "foo" $ do           H.it "bar" (assertEqual "trivial" (1::Int) 2)       assertBool "should find assertion text" $ any (=="trivial") r
− test/Test/Hspec/Meta.hs
@@ -1,2 +0,0 @@-module Test.Hspec.Meta (module Test.Hspec) where-import Test.Hspec
test/Test/Hspec/RunnerSpec.hs view
@@ -1,7 +1,7 @@ module Test.Hspec.RunnerSpec (main, spec) where  import           Test.Hspec.Meta-import           System.IO.Silently (hCapture, hSilence)+import           System.IO.Silently import           System.IO (stderr) import           Control.Applicative import           System.Environment (withArgs, withProgName, getArgs)@@ -38,7 +38,7 @@       `shouldThrow` (== ExitFailure 1)      it "suppresses output to stdout when evaluating examples" $ do-      r <- capture__ . H.hspec $ do+      r <- captureLines . H.hspec $ do         H.it "foobar" $ do           putStrLn "baz"       r `shouldSatisfy` notElem "baz"@@ -61,22 +61,43 @@     context "with --help" $ do       let printHelp = withProgName "spec" . withArgs ["--help"] . H.hspec $ pure ()       it "prints help" $ do-        r <- (capture__ . ignoreExitCode) printHelp+        r <- (captureLines . ignoreExitCode) printHelp         r `shouldStartWith` ["Usage: spec [OPTION]..."]         printHelp `shouldThrow` (== ExitSuccess)        it "constrains lines to 80 characters" $ do-        r <- (capture__ . ignoreExitCode) printHelp+        r <- (captureLines . ignoreExitCode) printHelp         r `shouldSatisfy` all ((<= 80) . length)         r `shouldSatisfy` any ((78 <=) . length)      context "with --verbose" $ do       it "does not suppress output to stdout" $ do-        r <- capture__ . withArgs ["--verbose"] . H.hspec $ do+        r <- captureLines . withArgs ["--verbose"] . H.hspec $ do           H.it "foobar" $ do             putStrLn "baz"         r `shouldSatisfy` elem "baz" +    context "with --dry-run" $ do+      it "produces a report" $ do+        r <- captureLines . withArgs ["--dry-run"] . H.hspec $ do+          H.it "foo" True+          H.it "bar" True+        normalizeSummary r `shouldBe` [+            ""+          , "- foo"+          , "- bar"+          , ""+          , "Finished in 0.0000 seconds"+          , "2 examples, 0 failures"+          ]++      it "does not verify anything" $ do+        e <- newMock+        _ <- captureLines . withArgs ["--dry-run"] . H.hspec $ do+          H.it "foo" (mockAction e)+          H.it "bar" False+        mockCounter e `shouldReturn` 0+     context "with --match" $ do       it "only runs examples that match a given pattern" $ do         e1 <- newMock@@ -150,7 +171,7 @@       getEnv "HSPEC_FAILURES" `shouldReturn` Just "[([\"foo\",\"bar\"],\"example 2\"),([\"baz\"],\"example 3\")]"      describe "with --re-run" $ do-      let runSpec = (capture__ . ignoreExitCode . H.hspec) $ do+      let runSpec = (captureLines . ignoreExitCode . H.hspec) $ do             H.it "example 1" True             H.it "example 2" False             H.it "example 3" False@@ -202,7 +223,7 @@       `shouldReturn` H.Summary 1 1      it "uses the specdoc formatter by default" $ do-      _:r:_ <- capture__ . H.hspecWith H.defaultConfig $ do+      _:r:_ <- captureLines . H.hspecWith H.defaultConfig $ do         H.describe "Foo.Bar" $ do           H.it "some example" True       r `shouldBe` "Foo.Bar"
test/Test/HspecSpec.hs view
@@ -1,7 +1,7 @@ module Test.HspecSpec (main, spec) where  import           Test.Hspec.Meta-import           Util (capture__)+import           Util (captureLines) import           Data.List (isPrefixOf)  import qualified Test.Hspec.Core.Type as H (defaultParams)@@ -61,4 +61,4 @@       pending   where     runSpec :: H.Spec -> IO [String]-    runSpec = capture__ . H.hspecWith defaultConfig+    runSpec = captureLines . H.hspecWith defaultConfig
test/Util.hs view
@@ -3,13 +3,10 @@ import           Data.List import           Data.Char import           Test.Hspec.Meta-import qualified System.IO.Silently as S--capture_ :: IO a -> IO String-capture_ = fmap fst . S.capture+import           System.IO.Silently -capture__ :: IO a -> IO [String]-capture__ = fmap lines . capture_+captureLines :: IO a -> IO [String]+captureLines = fmap lines . capture_  shouldContain :: (Eq a, Show a) => [a] -> [a] -> Expectation x `shouldContain` y = x `shouldSatisfy` isInfixOf y