tasty 0.4 → 0.4.0.1
raw patch · 2 files changed
+24/−2 lines, 2 filesdep +deepseq
Dependencies added: deepseq
Files
- Test/Tasty/Ingredients/ConsoleReporter.hs +21/−0
- tasty.cabal +3/−2
Test/Tasty/Ingredients/ConsoleReporter.hs view
@@ -6,6 +6,8 @@ import Control.Monad.State hiding (fail) import Control.Concurrent.STM import Control.Exception+import Control.DeepSeq+import Control.Applicative import Test.Tasty.Core import Test.Tasty.Run import Test.Tasty.Ingredients@@ -124,6 +126,8 @@ Exception e -> return (False, "Exception: " ++ show e) _ -> retry + rDesc <- liftIO $ formatMessage rDesc+ liftIO $ if rOk then ok "OK\n"@@ -169,6 +173,23 @@ fs -> do fail $ printf "%d out of %d tests failed\n" fs (ix st) return False+++-- | Printing exceptions or other messages is tricky — in the process we+-- can get new exceptions!+--+-- See e.g. https://github.com/feuerbach/tasty/issues/25+formatMessage :: String -> IO String+formatMessage msg = go 3 msg+ where+ -- to avoid infinite recursion, we introduce the recursion limit+ go :: Int -> String -> IO String+ go 0 _ = return "exceptions keep throwing other exceptions!"+ go recLimit msg = do+ mbStr <- try $ evaluate $ force msg+ case mbStr of+ Right str -> return str+ Left e' -> printf "message threw an exception: %s" <$> go (recLimit-1) (show (e' :: SomeException)) -- (Potentially) colorful output ok, fail, infoOk, infoFail :: (?colors :: Bool) => String -> IO ()
tasty.cabal view
@@ -2,7 +2,7 @@ -- see http://haskell.org/cabal/users-guide/ name: tasty-version: 0.4+version: 0.4.0.1 synopsis: Modern and extensible testing framework description: See <http://documentup.com/feuerbach/tasty> license: MIT@@ -46,7 +46,8 @@ mtl, tagged >= 0.5, regex-posix,- optparse-applicative >= 0.6+ optparse-applicative >= 0.6,+ deepseq >= 1.3 if flag(colors) build-depends: ansi-terminal