packages feed

test-lib 0.2.2 → 0.3

raw patch · 3 files changed

+42/−5 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ TestLib: [optVersion] :: Options -> Bool
- TestLib: Options :: String -> [String] -> Bool -> FilePath -> [FilePath] -> Maybe String -> Bool -> [String] -> [String] -> Maybe Config -> Options
+ TestLib: Options :: String -> [String] -> Bool -> Bool -> FilePath -> [FilePath] -> Maybe String -> Bool -> [String] -> [String] -> Maybe Config -> Options

Files

CHANGELOG.md view
@@ -1,5 +1,19 @@ # Revision history for test-lib +## 0.3++* Add --version flag to report current version+* Add OS specific gold files.  If there is a file named TEST.stdout.OS+  where OS matches the current OS, then this file will be used instead of+  the TEST.stdout.   The names of the OS are:+    darwin            (for Mac)+    freebsd+    linux+    linux-android+    mingw32           (for Windows)+    netbsd+    openbsd+ ## 0.2.1 -- 2018-01-21  * Only changes to versions of package dependencies.
src/TestLib.hs view
@@ -3,8 +3,10 @@ import SimpleGetOpt import Control.Monad (foldM,when) import System.Directory ( getDirectoryContents,doesDirectoryExist+                        , doesFileExist                         , createDirectoryIfMissing,canonicalizePath ) import System.Environment (withArgs)+import System.Info(os) import System.FilePath((</>),(<.>),splitFileName,splitDirectories,takeFileName                       , isRelative, pathSeparator, takeExtension ) import System.Process ( createProcess,CreateProcess(..), StdStream(..)@@ -12,6 +14,8 @@                        ) import System.IO(IOMode(..),withFile,Handle,hSetBuffering,BufferMode(..)) import System.Exit(exitSuccess)+import Paths_test_lib (version)+import Data.Version (showVersion) import Test.Framework (defaultMain,Test,testGroup) import Test.Framework.Providers.HUnit (testCase) import Test.HUnit (assertFailure)@@ -55,6 +59,10 @@         do dumpUsage options            exitSuccess +     when (optVersion opts) $+        do putStrLn (showVersion version)+           exitSuccess+      -- Normalize paths      bin' <- if pathSeparator `elem` optBinary opts                      && isRelative (optBinary opts)@@ -77,6 +85,7 @@   { optBinary         :: String   , optOther          :: [String]   , optHelp           :: Bool+  , optVersion        :: Bool   , optResultDir      :: FilePath   , optTests          :: [FilePath]   , optDiffTool       :: Maybe String@@ -93,6 +102,7 @@   { progDefaults = Options { optBinary         = ""                            , optOther          = []                            , optHelp           = False+                           , optVersion        = False                            , optResultDir      = "output"                            , optTests          = []                            , optDiffTool       = Nothing@@ -135,6 +145,9 @@                       _ -> '.' : s             in Right o { optTestFileExts = e : optTestFileExts o } +      , Option "" ["version"]+        "display current version"+        $ NoArg $ \o -> Right o { optVersion = True }        , Option "h" ["help"]         "display this message"@@ -168,10 +181,18 @@   where   -- file locations:   resultDir        = optResultDir opts </> dir        -- test output goes here-  goldFile         = dir </> file <.> "stdout"        -- what we expect to see+  goldFiles        = [ dir </> file <.> "stdout" <.> os -- what we expect to see+                     , dir </> file <.> "stdout"        -- what we expect to see+                     ]   knownFailureFile = dir </> file <.> "fails"         -- expected failur   resultOut        = resultDir </> file <.> "stdout"  -- outputfile +  getGoldFile gfs =+    case gfs of+      [] -> error ("Missing gold file for " ++ show (dir </> file))+      f : fs -> do yes <- doesFileExist f+                   if yes then pure f else getGoldFile fs+   runTest =     do createDirectoryIfMissing True resultDir        withFile resultOut WriteMode $ \ hout ->@@ -179,11 +200,12 @@             runBinary opts hout dir file         out      <- readFile resultOut-       expected <- readFile goldFile+       gf       <- getGoldFile goldFiles+       expected <- readFile gf        mbKnown  <- X.try (readFile knownFailureFile)-       checkOutput mbKnown expected out+       checkOutput gf mbKnown expected out -  checkOutput mbKnown expected out+  checkOutput goldFile mbKnown expected out     | expected == out =       case mbKnown of         Left _  -> return ()
test-lib.cabal view
@@ -1,5 +1,5 @@ name:                test-lib-version:             0.2.2+version:             0.3 synopsis:            A library to make a quick test-runner script. description:         This library makes it easy to define an executable,                      which can find and run a bunch of tests for a binary.@@ -15,6 +15,7 @@ library   hs-source-dirs:      src   exposed-modules:     TestLib+  other-modules:       Paths_test_lib   build-depends:       base                  >=4.9 && <4.15,                        directory             >=1.3 && <1.4,                        filepath              >=1.4 && <1.5,