packages feed

tasty-hspec 1.1.4 → 1.1.5

raw patch · 6 files changed

+98/−81 lines, 6 filesdep ~QuickCheckdep ~basedep ~tasty-quickcheckPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: QuickCheck, base, tasty-quickcheck

API changes (from Hackage documentation)

+ Test.Tasty.Hspec: Failure :: TreatPendingAs
+ Test.Tasty.Hspec: Success :: TreatPendingAs
+ Test.Tasty.Hspec: data TreatPendingAs
+ Test.Tasty.Hspec: instance Test.Tasty.Options.IsOption Test.Tasty.Hspec.TreatPendingAs

Files

.gitignore view
@@ -1,4 +1,4 @@-dist/-dist-newstyle/ .ghc.environment.* .stack-work/+dist/+dist-newstyle/
.travis.yml view
@@ -28,60 +28,20 @@  matrix:   include:-    - compiler: "ghc-7.4.1"-    # env: TEST=--disable-tests BENCH=--disable-benchmarks-      addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.4.1], sources: [hvr-ghc]}}     - compiler: "ghc-7.4.2"-    # env: TEST=--disable-tests BENCH=--disable-benchmarks       addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.4.2], sources: [hvr-ghc]}}-    - compiler: "ghc-7.6.1"-    # env: TEST=--disable-tests BENCH=--disable-benchmarks-      addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.6.1], sources: [hvr-ghc]}}-    - compiler: "ghc-7.6.2"-    # env: TEST=--disable-tests BENCH=--disable-benchmarks-      addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.6.2], sources: [hvr-ghc]}}     - compiler: "ghc-7.6.3"-    # env: TEST=--disable-tests BENCH=--disable-benchmarks       addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.6.3], sources: [hvr-ghc]}}-    - compiler: "ghc-7.8.1"-    # env: TEST=--disable-tests BENCH=--disable-benchmarks-      addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.8.1], sources: [hvr-ghc]}}-    - compiler: "ghc-7.8.2"-    # env: TEST=--disable-tests BENCH=--disable-benchmarks-      addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.8.2], sources: [hvr-ghc]}}-    - compiler: "ghc-7.8.3"-    # env: TEST=--disable-tests BENCH=--disable-benchmarks-      addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.8.3], sources: [hvr-ghc]}}     - compiler: "ghc-7.8.4"-    # env: TEST=--disable-tests BENCH=--disable-benchmarks       addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.8.4], sources: [hvr-ghc]}}-    - compiler: "ghc-7.10.1"-    # env: TEST=--disable-tests BENCH=--disable-benchmarks-      addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.10.1], sources: [hvr-ghc]}}-    - compiler: "ghc-7.10.2"-    # env: TEST=--disable-tests BENCH=--disable-benchmarks-      addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.10.2], sources: [hvr-ghc]}}     - compiler: "ghc-7.10.3"-    # env: TEST=--disable-tests BENCH=--disable-benchmarks       addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.10.3], sources: [hvr-ghc]}}-    - compiler: "ghc-8.0.1"-    # env: TEST=--disable-tests BENCH=--disable-benchmarks-      addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.0.1], sources: [hvr-ghc]}}     - compiler: "ghc-8.0.2"-    # env: TEST=--disable-tests BENCH=--disable-benchmarks       addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.0.2], sources: [hvr-ghc]}}-    - compiler: "ghc-8.2.1"-    # env: TEST=--disable-tests BENCH=--disable-benchmarks-      addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.1], sources: [hvr-ghc]}}     - compiler: "ghc-8.2.2"-    # env: TEST=--disable-tests BENCH=--disable-benchmarks       addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.2], sources: [hvr-ghc]}}-    - compiler: "ghc-8.4.1"-      env: GHCHEAD=true-      addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.4.1], sources: [hvr-ghc]}}--  allow_failures:-    - compiler: "ghc-8.4.1"+    - compiler: "ghc-8.4.2"+      addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.4.2], sources: [hvr-ghc]}}  before_install:   - HC=${CC}
CHANGELOG.md view
@@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to the [Haskell Package Versioning Policy](https://pvp.haskell.org/). +## [1.1.5] - 2018-06-27++### Added+- `TreatPendingAs` option, for allowing pending tests to be treated as successes+ ## [1.1.4] - 2018-3-18  ### Changed
+ examples/example.hs view
@@ -0,0 +1,21 @@+import Test.Tasty+import Test.Tasty.Hspec++main :: IO ()+main = do+  tree <- testSpec "hspec tests" hspecSuite+  defaultMain tree++hspecSuite :: Spec+hspecSuite = do+  describe "passing test" $+    it "5 == 5" $+      5 `shouldBe` (5 :: Int)++  describe "pending test" $+    it "pending" $+      pending++  describe "failing test" $+    it "5 == 6" $+      5 `shouldBe` (6 :: Int)
src/Test/Tasty/Hspec.hs view
@@ -9,9 +9,12 @@ --  module Test.Tasty.Hspec-    ( -- * Documentation+    ( -- * Tests       testSpec     , testSpecs+    -- * Options+    , TreatPendingAs(..)+    -- * Re-exports     , module Test.Hspec       -- * Examples       -- $examples@@ -100,16 +103,26 @@   run opts (Item (H.Item _ _ _ ex)) progress = do     qc_args <- tastyOptionSetToQuickCheckArgs opts -    let params :: H.Params-        params = H.Params-          { H.paramsQuickCheckArgs = qc_args-          , H.paramsSmallCheckDepth = sc_depth-          }+    let+      pending_ :: String -> T.Result+      pending_ =+        case T.lookupOption opts of+          Failure ->+            T.testFailed+          Success ->+            T.testPassed +    let+      params :: H.Params+      params = H.Params+        { H.paramsQuickCheckArgs = qc_args+        , H.paramsSmallCheckDepth = sc_depth+        }+ #if MIN_VERSION_hspec(2,4,0) && !MIN_VERSION_hspec(2,5,0)-    either handleUncaughtException hspecResultToTastyResult+    either handleUncaughtException (hspecResultToTastyResult pending_) #else-    hspecResultToTastyResult+    hspecResultToTastyResult pending_ #endif       <$> ex params ($ ()) hprogress @@ -127,7 +140,8 @@    -- testOptions :: Tagged Item [T.OptionDescription]   testOptions = return-    [ T.Option (Proxy :: Proxy TQC.QuickCheckTests)+    [ T.Option (Proxy :: Proxy TreatPendingAs)+    , T.Option (Proxy :: Proxy TQC.QuickCheckTests)     , T.Option (Proxy :: Proxy TQC.QuickCheckReplay)     , T.Option (Proxy :: Proxy TQC.QuickCheckMaxSize)     , T.Option (Proxy :: Proxy TQC.QuickCheckMaxRatio)@@ -153,11 +167,11 @@   TQC.QuickCheckMaxRatio max_ratio = T.lookupOption opts #endif -hspecResultToTastyResult :: H.Result -> T.Result+hspecResultToTastyResult :: (String -> T.Result) -> H.Result -> T.Result #if MIN_VERSION_hspec(2,5,0)-hspecResultToTastyResult (H.Result _ result) =+hspecResultToTastyResult pending_ (H.Result _ result) = #else-hspecResultToTastyResult result =+hspecResultToTastyResult pending_ result = #endif   case result of     H.Success ->@@ -168,7 +182,7 @@ #else     H.Pending x -> #endif-      handleResultPending x+      handleResultPending pending_ x  #if MIN_VERSION_hspec(2,4,0)     H.Failure _ x ->@@ -179,9 +193,9 @@     H.Fail str -> T.testFailed str #endif -handleResultPending :: Maybe String -> T.Result-handleResultPending x =-  T.testFailed ("# PENDING: " ++ fromMaybe "No reason given" x)+handleResultPending :: (String -> T.Result) -> Maybe String -> T.Result+handleResultPending pending_ x =+  pending_ ("# PENDING: " ++ fromMaybe "No reason given" x)  -- FailureReason --@@ -208,3 +222,29 @@ handleUncaughtException :: SomeException -> T.Result handleUncaughtException ex =   T.testFailed ("uncaught exception: " ++ H.formatException ex)++-- | How to treat @hspec@ pending tests.+--+-- @tasty@ does not have the concept of pending tests, so we must map them to+-- either successes or failures. By default, they are treated as failures.+--+-- Set via the command line flag @--treat-pending-as (success|failure)@.+data TreatPendingAs+  = Failure+  | Success++instance T.IsOption TreatPendingAs where+  defaultValue =+    Failure++  parseValue s =+    case s of+      "failure" -> Just Failure+      "success" -> Just Success+      _         -> Nothing++  optionName =+    pure "treat-pending-as"++  optionHelp =+    pure "How to treat pending hspec tests ('failure' or 'success')"
tasty-hspec.cabal view
@@ -1,5 +1,6 @@+cabal-version:       2.0 name:                tasty-hspec-version:             1.1.4+version:             1.1.5 synopsis:            Hspec support for the Tasty test framework. description:         This package provides a Tasty provider for Hspec test                      suites.@@ -11,30 +12,20 @@ maintainer:          mitchellwrosen@gmail.com category:            Testing build-type:          Simple-cabal-version:       >=1.10-tested-with:         GHC == 7.4.1,-                     GHC == 7.4.2,-                     GHC == 7.6.1,-                     GHC == 7.6.2,+tested-with:         GHC == 7.4.2,                      GHC == 7.6.3,-                     GHC == 7.8.1,-                     GHC == 7.8.2,-                     GHC == 7.8.3,                      GHC == 7.8.4,-                     GHC == 7.10.1,-                     GHC == 7.10.2,                      GHC == 7.10.3,-                     GHC == 8.0.1,                      GHC == 8.0.2,-                     GHC == 8.2.1,                      GHC == 8.2.2,-                     GHC == 8.4.1+                     GHC == 8.4.3  extra-source-files:   .gitignore   .travis.yml   cabal.project   CHANGELOG.md+  examples/example.hs   README.md  source-repository head@@ -44,14 +35,14 @@ library   exposed-modules:     Test.Tasty.Hspec   hs-source-dirs:      src-  build-depends:       base             >=4.5 && <5-                     , hspec            >=2   && <2.6-                     , hspec-core       >=2   && <2.6-                     , QuickCheck       >=2.7 && <2.12-                     , tasty            >=0.8 && <1.1-                     , tasty-smallcheck >=0.1 && <0.9+  build-depends:       base             >= 4.5 && < 5+                     , hspec            >= 2   && < 2.6+                     , hspec-core       >= 2   && < 2.6+                     , QuickCheck       >= 2.7 && < 2.12+                     , tasty            >= 0.8 && < 1.2+                     , tasty-smallcheck >= 0.1 && < 0.9                      -- 0.9 is missing 'optionSetToArgs'-                     , tasty-quickcheck >=0.3 && <0.9 || >=0.9.1 && <0.10+                     , tasty-quickcheck >=0.3 && <0.9 || ^>=0.9.1 || ^>= 0.10   if impl(ghc < 7.8)     build-depends:     tagged >= 0.2   other-extensions:    CPP