HUnit-Plus 0.3.3 → 0.3.4
raw patch · 4 files changed
+49/−23 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Test.HUnitPlus.Base: logSyserr :: String -> IO ()
+ Test.HUnitPlus.Base: logSysout :: String -> IO ()
+ Test.HUnitPlus.Reporting: showQualName :: State -> String
Files
- HUnit-Plus.cabal +2/−2
- src/Test/HUnitPlus/Base.hs +15/−1
- src/Test/HUnitPlus/Reporting.hs +15/−0
- src/Test/HUnitPlus/Text.hs +17/−20
HUnit-Plus.cabal view
@@ -1,6 +1,6 @@ Name: HUnit-Plus Category: Testing, Test-Version: 0.3.3+Version: 0.3.4 License: BSD3 License-File: LICENSE Author: Eric McCorkle@@ -24,7 +24,7 @@ Lastly, HUnit-Plus provides a wrapper which generates standalone test-execution programs from a set of test suites. .- This is the fourth release candidate for 1.0+ This is the fifth release candidate for 1.0. Build-type: Simple Cabal-version: >= 1.16
src/Test/HUnitPlus/Base.hs view
@@ -68,6 +68,8 @@ -- * Low-level Test Functions executeTest,+ logSyserr,+ logSysout, logAssert, logFailure, logError,@@ -128,7 +130,7 @@ {-# NOINLINE testinfo #-} testinfo :: IORef TestInfo-testinfo = unsafePerformIO $ newIORef undefined+testinfo = unsafePerformIO $! newIORef undefined -- | Does the actual work of executing a test. This maintains the -- necessary bookkeeping recording assertions and failures, It also@@ -270,6 +272,18 @@ writeIORef testinfo t { tiPrefix = prefix ++ oldprefix } c modifyIORef testinfo (\t' -> t' { tiPrefix = oldprefix })++-- | Record sysout output.+logSysout :: String -> IO ()+logSysout msg =+ modifyIORef testinfo (\t -> t { tiEvents = (sysOutCode, tiPrefix t ++ msg) :+ tiEvents t })++-- | Record sysout output.+logSyserr :: String -> IO ()+logSyserr msg =+ modifyIORef testinfo (\t -> t { tiEvents = (sysErrCode, tiPrefix t ++ msg) :+ tiEvents t }) -- | Record that one assertion has been checked. logAssert :: IO ()
src/Test/HUnitPlus/Reporting.hs view
@@ -18,6 +18,7 @@ Path, zeroCounts, showPath,+ showQualName, defaultReporter, combinedReporter ) where@@ -197,6 +198,20 @@ safe s ss = if '.' `elem` s || "\"" ++ s ++ "\"" /= ss then ss else s in intercalate "." (reverse (map showNode nodes))++-- | Gewerate a string showing the entire qualified name from the+-- reporting state.+showQualName :: State -> String+showQualName st =+ case stPath st of+ [] -> stName st+ nodes ->+ let+ showNode (Label label) = safe label (show label)+ safe s ss = if '.' `elem` s || "\"" ++ s ++ "\"" /= ss then ss else s+ in+ intercalate "." (reverse (map showNode nodes)) ++ "." ++ stName st+ -- | Combines two 'Reporter's into a single reporter that calls both. combinedReporter :: Reporter us1 -> Reporter us2 -> Reporter (us1, us2)
src/Test/HUnitPlus/Text.hs view
@@ -72,19 +72,17 @@ -> Reporter us textReporter (PutText put initUs) verbose = let- reportProblem p0 p1 msg ss us =+ reportProblem prefix msg ss us = let- kind = if null path then p0 else p1- path = showPath (stPath ss)- line = "### " ++ kind ++ path ++ ": " ++ msg ++ "\n"+ path = showQualName ss+ line = "### " ++ prefix ++ path ++ ": " ++ msg ++ "\n" in put line us - reportOutput p0 p1 msg ss us =+ reportOutput prefix msg ss us = let- kind = if null path then p0 else p1- path = showPath (stPath ss)- line = "### " ++ kind ++ path ++ ": " ++ msg ++ "\n"+ path = showQualName ss+ line = "### " ++ prefix ++ path ++ ": " ++ msg ++ "\n" in if verbose then put line us else return us @@ -104,7 +102,7 @@ reportStartCase ss us = let- path = showPath (stPath ss)+ path = showQualName ss line = if null path then "Test case starting\n" else "Test case " ++ path ++ " starting\n" in@@ -112,7 +110,7 @@ reportEndCase time ss us = let- path = showPath (stPath ss)+ path = showQualName ss timestr = printf "%.6f" time line = if null path then "Test completed in " ++ timestr ++ " sec\n" else "Test " ++ path ++ " completed in " ++ timestr ++ " sec\n"@@ -139,10 +137,10 @@ reporterEndSuite = reportEndSuite, reporterStartCase = reportStartCase, reporterEndCase = reportEndCase,- reporterSystemOut = reportOutput "STDOUT " "STDOUT from ",- reporterSystemErr = reportOutput "STDERR" "STDERR from ",- reporterError = reportProblem "Error " "Error in ",- reporterFailure = reportProblem "Failure" "Failure in "+ reporterSystemOut = reportOutput "STDOUT from ",+ reporterSystemErr = reportOutput "STDERR from ",+ reporterError = reportProblem "Error in ",+ reporterFailure = reportProblem "Failure in " } -- | Execute a test, processing text output according to the given@@ -251,11 +249,10 @@ terminalReporter :: Reporter Int terminalReporter = let- reportProblem p0 p1 msg ss us =+ reportProblem prefix msg ss us = let- line = "### " ++ kind ++ path ++ '\n' : msg- path = showPath (stPath ss)- kind = if null path then p0 else p1+ line = "### " ++ prefix ++ path ++ '\n' : msg+ path = showQualName ss in termPut line True us in@@ -264,8 +261,8 @@ reporterEnd = (\_ _ _ -> do hPutStr stderr "\n"; return 0), reporterEndCase = (\_ ss us -> termPut (showCounts (stCounts ss)) False us),- reporterError = reportProblem "Error:" "Error in: ",- reporterFailure = reportProblem "Failure:" "Failure in: "+ reporterError = reportProblem "Error in: ",+ reporterFailure = reportProblem "Failure in: " } -- | Execute a test, processing text output according to the given