packages feed

tasty-golden 2.2.2.3 → 2.2.2.4

raw patch · 3 files changed

+27/−10 lines, 3 filesdep +asyncPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies added: async

API changes (from Hackage documentation)

- Test.Tasty.Golden.Manage: acceptGoldenTests :: OptionSet -> TestTree -> IO ()
+ Test.Tasty.Golden.Manage: acceptGoldenTests :: OptionSet -> TestTree -> IO Bool

Files

CHANGELOG.md view
@@ -1,6 +1,12 @@ Changes ======= +Version 2.2.2.4+---------------++* Warn when some tests threw exceptions during `--accept`+* Properly handle exceptions; don't swallow Ctrl-C+ Version 2.2.2.3 --------------- 
Test/Tasty/Golden/Manage.hs view
@@ -23,7 +23,9 @@ import Data.Proxy import Data.Maybe import Control.Monad.Cont+import Control.Monad.State import Control.Exception+import Control.Concurrent.Async import Text.Printf import Options.Applicative @@ -53,9 +55,8 @@   \opts tree ->     case lookupOption opts of       AcceptTests False -> Nothing-      AcceptTests True -> Just $ do+      AcceptTests True -> Just $         acceptGoldenTests opts tree-        return True  -- | Get the list of all golden tests in a given test tree getGoldenTests :: OptionSet -> TestTree -> [(TestName, Golden)]@@ -70,12 +71,21 @@   vgRun $ liftIO . update =<< getTested  -- | Accept all golden tests in the test tree-acceptGoldenTests :: OptionSet -> TestTree -> IO ()+acceptGoldenTests :: OptionSet -> TestTree -> IO Bool acceptGoldenTests opts tests = do   let gs = getGoldenTests opts tests-  forM_ gs $ \(n,g) -> do-    mbExn <- try $ acceptGoldenTest g+  numExns <- flip execStateT (0 :: Int) $ forM_ gs $ \(n,g) -> do+    mbExn <- liftIO $ withAsync (acceptGoldenTest g) waitCatch     case mbExn of-      Right {} -> printf "Accepted %s\n" n-      -- yeah, this is not async-exception-safe/correct-      Left e -> printf "Error when trying to accept %s: %s\n" n (show (e :: SomeException))+      Right {} -> liftIO $ printf "Accepted %s\n" n+      Left e -> do+        liftIO $ printf "Error when trying to accept %s: %s\n" n (show (e :: SomeException))+        ne <- get+        put $! ne+1++  -- warn when there were problems+  when (numExns > 0) $+    printf "NOTE: %d tests threw exceptions!\n" numExns++  -- is everything ok?+  return (numExns == 0)
tasty-golden.cabal view
@@ -1,5 +1,5 @@ name:                tasty-golden-version:             2.2.2.3+version:             2.2.2.4 synopsis:            Golden tests support for tasty description:   This package provides support for «golden testing».@@ -47,7 +47,8 @@     tagged,     deepseq,     containers,-    directory+    directory,+    async  Test-suite test   Default-language: