packages feed

tasty-silver 3.0.2.2 → 3.1

raw patch · 7 files changed

+81/−16 lines, 7 filesdep +transformersdep ~ansi-terminaldep ~bytestringdep ~processPVP ok

version bump matches the API change (PVP)

Dependencies added: transformers

Dependency ranges changed: ansi-terminal, bytestring, process, process-extras, stm, text

API changes (from Hackage documentation)

+ Test.Tasty.Silver.Internal: AcceptTests :: Bool -> AcceptTests
+ Test.Tasty.Silver.Internal: DiffText :: (Maybe String) -> Text -> Text -> GDiff
+ Test.Tasty.Silver.Internal: Equal :: GDiff
+ Test.Tasty.Silver.Internal: GRDifferent :: (a) -> (a) -> (GDiff) -> (a -> IO ()) -> GoldenResult' m
+ Test.Tasty.Silver.Internal: GREqual :: GoldenResult' m
+ Test.Tasty.Silver.Internal: GRNoGolden :: (m a) -> (a -> IO GShow) -> (a -> IO ()) -> GoldenResult' m
+ Test.Tasty.Silver.Internal: Golden :: (IO (Maybe a)) -> (IO a) -> (a -> a -> IO GDiff) -> (a -> IO GShow) -> (a -> IO ()) -> Golden
+ Test.Tasty.Silver.Internal: ShowDiffed :: (Maybe String) -> Text -> GDiff
+ Test.Tasty.Silver.Internal: ShowText :: Text -> GShow
+ Test.Tasty.Silver.Internal: data GDiff
+ Test.Tasty.Silver.Internal: data GShow
+ Test.Tasty.Silver.Internal: data Golden
+ Test.Tasty.Silver.Internal: data GoldenResult' m
+ Test.Tasty.Silver.Internal: forceGoldenResult :: GoldenResult -> IO GoldenResultI
+ Test.Tasty.Silver.Internal: gActual :: GDiff -> Text
+ Test.Tasty.Silver.Internal: gDiff :: GDiff -> Text
+ Test.Tasty.Silver.Internal: gExpected :: GDiff -> Text
+ Test.Tasty.Silver.Internal: gReason :: GDiff -> (Maybe String)
+ Test.Tasty.Silver.Internal: instance Eq AcceptTests
+ Test.Tasty.Silver.Internal: instance IsOption AcceptTests
+ Test.Tasty.Silver.Internal: instance IsTest Golden
+ Test.Tasty.Silver.Internal: instance Ord AcceptTests
+ Test.Tasty.Silver.Internal: instance Typeable AcceptTests
+ Test.Tasty.Silver.Internal: instance Typeable Golden
+ Test.Tasty.Silver.Internal: newtype AcceptTests
+ Test.Tasty.Silver.Internal: readFileMaybe :: FilePath -> IO (Maybe ByteString)
+ Test.Tasty.Silver.Internal: runGolden :: Golden -> IO (Result, GoldenResult)
+ Test.Tasty.Silver.Internal: type GoldenResult = GoldenResult' IO
+ Test.Tasty.Silver.Internal: type GoldenResultI = GoldenResult' Identity

Files

CHANGELOG.md view
@@ -1,6 +1,20 @@ Changes ======= +Version 3.1+-----------++* Fixed & tested support for GHC 7.4.2 - 7.10.1+* Added missing lower bound for bytestring+* Removed upper bounds for most dependencies+* Enable travis CI builds++Version 3.0 - 3.0.2.2+-----------++* Refactored API+* Add interactive mode+ Version 2.2.2.4 --------------- 
Test/Tasty/Silver.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE TypeSynonymInstances, FlexibleInstances, OverloadedStrings #-}+{-# LANGUAGE CPP #-} {- | This module provides a simplified interface. If you want more, see "Test.Tasty.Golden.Advanced". @@ -58,7 +59,9 @@ import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString as BS import System.Exit+#if __GLASGOW_HASKELL__ < 710 import Control.Applicative+#endif import qualified Data.Text as T import System.Process.Text as PT import System.Directory@@ -116,8 +119,13 @@     (toTxt <$> act)     textLikeDiff     textLikeShow-    (upd . BL.fromStrict . encodeUtf8)+    (upd . fromStrict . encodeUtf8)   where upd = BL.writeFile ref+#if __GLASGOW_HASKELL__ < 706+        fromStrict x = BL.fromChunks [x]+#else+        fromStrict = BL.fromStrict+#endif  textLikeShow :: T.Text -> GShow textLikeShow = ShowText
Test/Tasty/Silver/Advanced.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE RankNTypes, OverloadedStrings #-}+{-# LANGUAGE CPP #-} module Test.Tasty.Silver.Advanced   ( -- * The main function     goldenTest1,@@ -16,7 +17,9 @@  import Test.Tasty.Providers import Test.Tasty.Silver.Internal+#if __GLASGOW_HASKELL__ < 710 import Control.Applicative+#endif import qualified Data.Text as T  -- | A very general testing function. Use 'goldenTest1' instead if you can.
Test/Tasty/Silver/Interactive.hs view
@@ -3,6 +3,7 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE ImplicitParams #-} {-# LANGUAGE BangPatterns #-}+{-# LANGUAGE CPP #-} -- | Golden test management, interactive mode. Runs the tests, and asks -- the user how to proceed in case of failure or missing golden standard. module Test.Tasty.Silver.Interactive@@ -29,9 +30,14 @@ import Data.Tagged import Data.Maybe import Data.Monoid+#if __GLASGOW_HASKELL__ < 710 import Data.Foldable (foldMap)+#endif import Data.Char import qualified Data.IntMap as IntMap+#if __GLASGOW_HASKELL__ < 708+import Data.Proxy+#endif import Control.Monad.State hiding (fail) import Control.Monad.STM import Control.Monad.Reader hiding (fail)@@ -42,9 +48,8 @@ import qualified Data.Text as T import Data.Text.Encoding import Options.Applicative-import System.Process.ByteString.Lazy as PL+import System.Process.ByteString as PS import System.Process-import qualified Data.ByteString.Lazy as B import qualified Data.ByteString as BS import System.IO import System.IO.Temp@@ -168,9 +173,9 @@ showInLess :: String -> T.Text -> IO () showInLess _ t = do   -- TODO error handling...-  _ <- PL.readProcessWithExitCode "sh" ["-c", "less > /dev/tty"] inp+  _ <- PS.readProcessWithExitCode "sh" ["-c", "less > /dev/tty"] inp   return ()-  where inp = B.fromStrict $ encodeUtf8 t+  where inp = encodeUtf8 t  tryAccept :: String -> TestName -> (a -> IO ()) -> a -> IO Bool tryAccept pref nm upd new = do
Test/Tasty/Silver/Internal.hs view
@@ -1,8 +1,11 @@ {-# LANGUAGE RankNTypes, ExistentialQuantification, DeriveDataTypeable,     MultiParamTypeClasses, GeneralizedNewtypeDeriving #-}+{-# LANGUAGE CPP #-} module Test.Tasty.Silver.Internal where +#if __GLASGOW_HASKELL__ < 710 import Control.Applicative+#endif import Control.Exception import Control.Monad.Identity import Data.Typeable (Typeable)
tasty-silver.cabal view
@@ -1,5 +1,5 @@ name:                tasty-silver-version:             3.0.2.2+version:             3.1 synopsis:            Golden tests support for tasty. Fork of tasty-golden. description:   This package provides support for «golden testing».@@ -31,29 +31,29 @@                        Test.Tasty.Silver.Advanced                        Test.Tasty.Silver.Interactive                        Test.Tasty.Silver.Interactive.Run-  other-modules:                        Test.Tasty.Silver.Internal -  ghc-options: -Wall+  if impl(ghc >= 7.6)+    ghc-options: -Wall    build-depends:-    ansi-terminal >= 0.6.2.1 && < 0.7,+    ansi-terminal >= 0.6.2.1,     async,     base ==4.*,-    bytestring,+    bytestring >= 0.9.2.1,     containers,     directory,     deepseq,     filepath,     mtl,     optparse-applicative,-    process >= 1.2 && < 1.3,-    process-extras >= 0.2 && < 0.4,-    stm >= 2.4.2 && < 2.5,+    process >= 1.2,+    process-extras >= 0.2,+    stm >= 2.4.2,     tagged,     tasty >= 0.8,     temporary-rc,-    text >= 0.11.0.0 && < 1.3+    text >= 0.11.0.0  Test-suite test   Default-language:@@ -73,3 +73,4 @@     , directory     , process     , temporary-rc+    , transformers >= 0.3
tests/test.hs view
@@ -1,15 +1,28 @@ import Test.Tasty import Test.Tasty.HUnit import Test.Tasty.Silver+import Test.Tasty.Silver.Interactive hiding (defaultMain)+import Test.Tasty.Runners+import Test.Tasty.Silver.Advanced+import Test.Tasty.Silver.Internal+import Test.Tasty.Options++import Data.Monoid import System.IO.Temp import System.FilePath import System.Directory import Data.List (sort)+import Control.Concurrent.MVar+import Control.Monad.IO.Class  touch f = writeFile f "" -main = defaultMain $-  testCase "findByExtension" $+main = defaultMain $ testGroup "tests" [testFindByExt, testWithResource]++++testFindByExt :: TestTree+testFindByExt = testCase "findByExtension" $     withSystemTempDirectory "golden-test" $ \basedir -> do        setCurrentDirectory basedir@@ -27,3 +40,21 @@       files <- findByExtension [".c", ".h"] "."       sort files @?= sort         ["./d1/d2/h1.c","./d1/g1.c","./f1.c","./f2.h"]++testWithResource :: TestTree+testWithResource = testCase "withResource" $ do+    -- check if resources are properly initialized+    testRes <- newMVar False+    let acq = newMVar True+        free v = swapMVar v False >> return ()+        test = \v -> goldenTest1 "check res" (return Nothing) (liftIO $ testAction v) (\_ _ -> Equal) (\_ -> ShowText mempty) upd+        upd x = assertBool "Incorrect result" x >> return ()+        testAction = \v -> v >>= readMVar >>= assertBool "Resource not initialized." >> return True+        tree = withResource acq free test++    let r = tryIngredients [consoleTestReporter] (singleOption $ AcceptTests True) tree+    case r of+      Just r' -> do+        success <- r'+        assertBool "Test should succeed." success+      Nothing -> assertFailure "Test broken"