packages feed

tasty-golden 2.3.1.3 → 2.3.2

raw patch · 3 files changed

+35/−9 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,10 +1,15 @@ Changes ======= +Version 2.3.2+-------------++Add a `--no-create` flag+ Version 2.3.1.3 --------------- -* Make the environment variable `TASTY_ACCEPT=True` work, and make the value+Make the environment variable `TASTY_ACCEPT=True` work, and make the value     case-insensitive (so `TASTY_ACCEPT=true` works, too)  Version 2.3.1.2
Test/Tasty/Golden/Internal.hs view
@@ -34,12 +34,27 @@   optionHelp = return "Accept current results of golden tests"   optionCLParser = flagCLParser Nothing (AcceptTests True) +-- | This option, when set to 'True', specifies to error when a file does+-- not exist, instead of creating a new file.+newtype NoCreateFile = NoCreateFile Bool+  deriving (Eq, Ord, Typeable)+instance IsOption NoCreateFile where+  defaultValue = NoCreateFile False+  parseValue = fmap NoCreateFile . safeReadBool+  optionName = return "no-create"+  optionHelp = return "Error when golden file does not exist"+  optionCLParser = flagCLParser Nothing (NoCreateFile True)+ instance IsTest Golden where-  run opts golden _ = runGolden golden (lookupOption opts)-  testOptions = return [Option (Proxy :: Proxy AcceptTests)]+  run opts golden _ = runGolden golden opts+  testOptions =+    return+      [ Option (Proxy :: Proxy AcceptTests)+      , Option (Proxy :: Proxy NoCreateFile)+      ] -runGolden :: Golden -> AcceptTests -> IO Result-runGolden (Golden getGolden getTested cmp update) (AcceptTests accept) = do+runGolden :: Golden -> OptionSet -> IO Result+runGolden (Golden getGolden getTested cmp update) opts = do   do     mbNew <- try getTested @@ -51,9 +66,12 @@         mbRef <- try getGolden          case mbRef of-          Left e | isDoesNotExistError e -> do-            update new-            return $ testPassed "Golden file did not exist; created"+          Left e | isDoesNotExistError e ->+            if noCreate+              then return $ testFailed "Golden file does not exist; --no-create flag specified"+              else do+                update new+                return $ testPassed "Golden file did not exist; created"              | otherwise -> throwIO e @@ -75,3 +93,6 @@                Nothing ->                 return $ testPassed ""+  where+    AcceptTests accept = lookupOption opts+    NoCreateFile noCreate = lookupOption opts
tasty-golden.cabal view
@@ -1,5 +1,5 @@ name:                tasty-golden-version:             2.3.1.3+version:             2.3.2 synopsis:            Golden tests support for tasty description:   This package provides support for «golden testing».