packages feed

tasty-golden 2.3.3.2 → 2.3.3.3

raw patch · 5 files changed

+55/−5 lines, 5 filesdep +unix-compatdep ~tasty

Dependencies added: unix-compat

Dependency ranges changed: tasty

Files

CHANGELOG.md view
@@ -1,6 +1,11 @@ Changes ======= +Version 2.3.3.3+---------------++* Fix a bug where `goldenVsFileDiff` would not create a missing golden file+ Version 2.3.3.2 --------------- 
Test/Tasty/Golden.hs view
@@ -72,6 +72,7 @@ import System.Exit import System.FilePath import System.Directory+import System.PosixCompat.Files import Control.Exception import Control.Monad import qualified Data.Set as Set@@ -138,7 +139,11 @@   askOption $ \sizeCutoff ->   goldenTest     name-    (return ())+    (getFileStatus ref >> return ())+        -- Use getFileStatus to check if the golden file exists. If the file+        -- doesn't exist, getFileStatus will throw an isDoesNotExistError that+        -- runGolden will handle by creating the golden file before proceeding.+        -- See #32.     act     (cmp sizeCutoff)     upd
Test/Tasty/Golden/Internal.hs view
@@ -56,9 +56,10 @@   deriving (Eq, Ord, Typeable, Num, Real, Enum, Integral) instance IsOption SizeCutoff where   defaultValue = 1000+  showDefaultValue = Just . show . getSizeCutoff   parseValue = fmap SizeCutoff . safeRead . filter (/= '_')   optionName = return "size-cutoff"-  optionHelp = return "hide golden test output if it's larger than n bytes (default: 1000)"+  optionHelp = return "hide golden test output if it's larger than n bytes"   optionCLParser = mkOptionCLParser $ metavar "n"  instance IsTest Golden where
tasty-golden.cabal view
@@ -1,5 +1,5 @@ name:                tasty-golden-version:             2.3.3.2+version:             2.3.3.3 synopsis:            Golden tests support for tasty description:   This package provides support for «golden testing».@@ -52,7 +52,7 @@    build-depends:     base >= 4.7,-    tasty >= 1.0.1,+    tasty >= 1.3,     bytestring >= 0.9.2.1,     process,     mtl,@@ -64,7 +64,8 @@     containers,     directory,     async,-    text+    text,+    unix-compat  Test-suite test   Default-language:
tests/test.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE OverloadedStrings #-} import Test.Tasty import Test.Tasty.HUnit import Test.Tasty.Golden@@ -11,6 +12,14 @@ touch f = writeFile f "" diff ref new = ["diff", "-u", ref, new] +-- Remove a .golden file that a golden test created due to the .golden file not+-- existing prior to the start of the test.+postCleanup :: String -> (FilePath -> TestTree) -> TestTree+postCleanup fileName f =+  withResource (return ()) (\_ -> removeFile filePath) (\_ -> f filePath)+  where+    filePath = "tests/golden" </> fileName <.> "golden"+ main = defaultMain $ testGroup "Tests"   [ testCase "findByExtension" $     withSystemTempDirectory "golden-test" $ \basedir -> do@@ -28,6 +37,35 @@       files <- findByExtension [".c", ".h"] basedir       sort files @?= (sort . map (basedir </>))         ["d1/d2/h1.c","d1/g1.c","f1.c","f2.h"]+  , testGroup "Missing golden files"+    -- Make sure that each entrypoint to tasty-golden can properly create+    -- golden files if they are not provided. This serves as a regression test+    -- for #32.+    [ postCleanup "goldenVsFile" $ \golden ->+      goldenVsFile+        "goldenVsFile without golden file"+        golden+        "tests/golden/goldenVsFile.actual"+        (touch "tests/golden/goldenVsFile.actual")+    , postCleanup "goldenVsFileDiff" $ \golden ->+      goldenVsFileDiff+        "goldenVsFileDiff without golden file"+        diff+        golden+        "tests/golden/goldenVsFileDiff.actual"+         (touch "tests/golden/goldenVsFileDiff.actual")+    , postCleanup "goldenVsString" $ \golden ->+      goldenVsString+        "goldenVsString without golden file"+        golden+        (return "")+    , postCleanup "goldenVsStringDiff" $ \golden ->+      goldenVsStringDiff+        "goldenVsStringDiff without golden file"+        diff+        golden+        (return "")+    ] #ifdef BUILD_EXAMPLE   , withResource     (do