packages feed

tasty-expected-failure 0.11.0.4 → 0.11.1

raw patch · 3 files changed

+45/−17 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Test.Tasty.ExpectedFailure: expectFailBecause :: String -> TestTree -> TestTree
+ Test.Tasty.ExpectedFailure: ignoreTestBecause :: String -> TestTree -> TestTree

Files

README.md view
@@ -33,7 +33,7 @@ Instead I wrote 37 lines of cabal file, a similar number of lines of README, created a git repository, created a travis file, run travis to figure out on what versions it builds (something that would have happened automatically with-a pull request for tasty), upload to hackge, add to stackage.+a pull request for tasty), upload to hackage, add to stackage.  Furthermore, there is little discoverability: If it were part of the tasty API, users would stumble over it. Now they likely won’t. And if they do, they have
Test/Tasty/ExpectedFailure.hs view
@@ -1,11 +1,13 @@ {-# LANGUAGE DeriveDataTypeable, ScopedTypeVariables #-}-module Test.Tasty.ExpectedFailure (expectFail, ignoreTest, wrapTest) where+module Test.Tasty.ExpectedFailure (expectFail, expectFailBecause, ignoreTest, ignoreTestBecause, wrapTest) where  import Test.Tasty.Options import Test.Tasty.Runners import Test.Tasty.Providers import Data.Typeable import Data.Tagged+import Data.Maybe+import Data.Monoid  data WrappedTest t = WrappedTest (IO Result -> IO Result) t     deriving Typeable@@ -14,7 +16,7 @@     run opts (WrappedTest wrap t) prog = wrap (run opts t prog)     testOptions = retag (testOptions :: Tagged t [OptionDescription]) --- | 'wrapTest' allows you to modify the behavoiur of the tests, e.g. by+-- | 'wrapTest' allows you to modify the behaviour of the tests, e.g. by -- modifying the result or not running the test at all. It is used to implement -- 'expectFail' and 'ignoreTest'. wrapTest :: (IO Result -> IO Result) -> TestTree -> TestTree@@ -42,28 +44,54 @@ -- accidentially), the test suite will remind you to remove the 'expectFail' -- marker. expectFail :: TestTree -> TestTree-expectFail = wrapTest (fmap change)+expectFail = expectFail' Nothing++-- | Like 'expectFail' but with additional comment+expectFailBecause :: String -> TestTree -> TestTree+expectFailBecause reason = expectFail' (Just reason)++expectFail' :: Maybe String -> TestTree -> TestTree+expectFail' reason = wrapTest (fmap change)   where     change r         | resultSuccessful r         = r { resultOutcome = Failure TestFailed-            , resultDescription = resultDescription r `append` "(unexpected success)"-            , resultShortDescription = "PASS (unexpected)"+            , resultDescription = resultDescription r <> "(unexpected success" <> comment <> ")"+            , resultShortDescription = "PASS (unexpected" <> comment <> ")"             }         | otherwise         = r { resultOutcome = Success-            , resultDescription = resultDescription r `append` "(expected failure)"-            , resultShortDescription = "FAIL (expected)"+            , resultDescription = resultDescription r <> "(expected failure)"+            , resultShortDescription = "FAIL (expected" <> comment <> ")"             }     "" `append` s = s     t  `append` s | last t == '\n' = t ++ s ++ "\n"                   | otherwise      = t ++ "\n" ++ s-+    comment = maybe "" (mappend ": ") reason --- | Prevents the tests from running and reports them as succeeding. This maybe--- be desireable as an alternative comment the tests out, as they are still--- typechecked, and the test report lists them, as a reminder that there are--- ignored test.+-- | Prevents the tests from running and reports them as succeeding.+--+-- This may be be desireable as an alternative to commenting out the tests. This+-- way, they are still typechecked (preventing bitrot), and the test report+-- lists them, which serves as a reminder that there are ignored tests.+--+-- Note that any setup/teardown actions executed by 'Test.Tasty.withResource'+-- are still executed. You can bypass this manually as in the following example:+--+-- @+-- askOption $ \\(MyFlag b) -> if b+--                            then withResource mytest+--                            else ignoreTest . mytest $ return junkvalue+-- @ ignoreTest :: TestTree -> TestTree-ignoreTest = wrapTest $ const $ return $-    (testPassed "") { resultShortDescription = "IGNORED" }+ignoreTest = ignoreTest' Nothing++-- | Like 'ignoreTest' but with additional comment+ignoreTestBecause :: String -> TestTree -> TestTree+ignoreTestBecause reason = ignoreTest' (Just reason)++ignoreTest' :: Maybe String -> TestTree -> TestTree+ignoreTest' reason = wrapTest $ const $ return $+    (testPassed "") {+      resultShortDescription = "IGNORED" <> maybe "" (mappend ": ") reason+    }
tasty-expected-failure.cabal view
@@ -1,5 +1,5 @@ name:                tasty-expected-failure-version:             0.11.0.4+version:             0.11.1 synopsis:            Mark tasty tests as failure expected description:  With the function 'Test.Tasty.ExpectedFailure.expectFail' in the provided module@@ -33,7 +33,7 @@   exposed-modules:     Test.Tasty.ExpectedFailure   build-depends:-    base >= 4.5 && <4.10,+    base >= 4.5 && <4.11,     tagged >= 0.7 && < 0.9,     tasty >= 0.11   default-language:    Haskell2010