tasty-golden 2.3.2 → 2.3.2.1
raw patch · 4 files changed
+43/−14 lines, 4 filesdep ~basedep ~bytestringPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base, bytestring
API changes (from Hackage documentation)
- Test.Tasty.Golden.Advanced: goldenTest :: TestName -> (IO a) -> (IO a) -> (a -> a -> IO (Maybe String)) -> (a -> IO ()) -> TestTree
+ Test.Tasty.Golden.Advanced: goldenTest :: TestName -> IO a -> IO a -> (a -> a -> IO (Maybe String)) -> (a -> IO ()) -> TestTree
Files
- CHANGELOG.md +5/−0
- Test/Tasty/Golden.hs +30/−9
- Test/Tasty/Golden/Internal.hs +0/−3
- tasty-golden.cabal +8/−2
CHANGELOG.md view
@@ -1,6 +1,11 @@ Changes ======= +Version 2.3.2.1+---------------++Create missing directories when writing golden files+ Version 2.3.2 -------------
Test/Tasty/Golden.hs view
@@ -45,6 +45,7 @@ as binary does the job. -} +{-# LANGUAGE CPP #-} module Test.Tasty.Golden ( goldenVsFile , goldenVsString@@ -68,11 +69,11 @@ import System.Directory import Control.Exception import Control.Monad-import Control.Applicative import Control.DeepSeq import qualified Data.Set as Set --- | Compare a given file contents against the golden file contents+-- | Compare the output file's contents against the golden file's contents+-- after the given action has created the output file. goldenVsFile :: TestName -- ^ test name -> FilePath -- ^ path to the «golden» file (the file that contains correct output)@@ -88,9 +89,9 @@ upd where cmp = simpleCmp $ printf "Files '%s' and '%s' differ" ref new- upd = BS.writeFile ref+ upd = createDirectoriesAndWriteFile ref --- | Compare a given string against the golden file contents+-- | Compare a given string against the golden file's contents. goldenVsString :: TestName -- ^ test name -> FilePath -- ^ path to the «golden» file (the file that contains correct output)@@ -100,15 +101,22 @@ goldenTest name (BS.readFile ref)- (LBS.toStrict <$> act)+ (toStrict <$> act) cmp upd where cmp x y = simpleCmp msg x y where msg = printf "Test output was different from '%s'. It was: %s" ref (show y)- upd = BS.writeFile ref+ upd = createDirectoriesAndWriteFile ref +toStrict :: LBS.ByteString -> BS.ByteString+#if MIN_VERSION_bytestring(0,10,0)+toStrict = LBS.toStrict+#else+toStrict = BS.concat . LBS.toChunks+#endif+ simpleCmp :: Eq a => String -> a -> a -> IO (Maybe String) simpleCmp e x y = return $ if x == y then Nothing else Just e@@ -148,7 +156,7 @@ ExitSuccess -> Nothing _ -> Just out - upd _ = BS.readFile new >>= BS.writeFile ref+ upd _ = BS.readFile new >>= createDirectoriesAndWriteFile ref -- | Same as 'goldenVsString', but invokes an external diff command. goldenVsStringDiff@@ -167,7 +175,7 @@ goldenTest name (BS.readFile ref)- (LBS.toStrict <$> act)+ (toStrict <$> act) cmp upd where@@ -193,7 +201,7 @@ upd = BS.writeFile ref --- | Like 'writeFile', but uses binary mode+-- | Like 'writeFile', but uses binary mode. writeBinaryFile :: FilePath -> String -> IO () writeBinaryFile f txt = withBinaryFile f WriteMode (\hdl -> hPutStr hdl txt) @@ -237,3 +245,16 @@ if takeExtension path `Set.member` exts then [path] else []++-- | Like 'BS.writeFile', but also create parent directories if they are+-- missing.+createDirectoriesAndWriteFile+ :: FilePath+ -> BS.ByteString+ -> IO ()+createDirectoriesAndWriteFile path bs = do+ let dir = takeDirectory path+ createDirectoryIfMissing+ True -- create parents too+ dir+ BS.writeFile path bs
Test/Tasty/Golden/Internal.hs view
@@ -5,9 +5,6 @@ import Control.DeepSeq import Control.Exception import Data.Typeable (Typeable)-import Options.Applicative-import Data.Monoid-import Data.Tagged import Data.Proxy import System.IO.Error (isDoesNotExistError) import Test.Tasty.Providers
tasty-golden.cabal view
@@ -1,5 +1,5 @@ name: tasty-golden-version: 2.3.2+version: 2.3.2.1 synopsis: Golden tests support for tasty description: This package provides support for «golden testing».@@ -22,6 +22,12 @@ build-type: Simple cabal-version: >=1.14 extra-source-files: CHANGELOG.md+Tested-With:+ GHC ==8.0.2 ||+ ==8.2.2 ||+ ==8.4.4 ||+ ==8.6.5 ||+ ==8.8.2 Source-repository head type: git@@ -41,7 +47,7 @@ build-depends: base ==4.*, tasty >= 1.0.1,- bytestring >= 0.10,+ bytestring >= 0.9.2.1, process, mtl, optparse-applicative,