From 185168905e5f6e568a83825122149ef8b6994d4d Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 27 Feb 2009 03:31:47 +0000 Subject: [PATCH] require testpack; give better --verbose test output --- Tests.hs | 24 +++++++++++------------- hledger.cabal | 2 +- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Tests.hs b/Tests.hs index b50076c68..f19c95b5d 100644 --- a/Tests.hs +++ b/Tests.hs @@ -7,6 +7,7 @@ where import qualified Data.Map as Map import Text.ParserCombinators.Parsec import Test.HUnit +import Test.HUnit.Tools (assertRaises, runVerboseTests) import Ledger import Utils import Options @@ -15,19 +16,16 @@ import PrintCommand import RegisterCommand -runtests opts args = do - when (Verbose `elem` opts) - (do - putStrLn $ printf "Running %d tests%s:" n s - sequence $ map (putStrLn . tname) $ tflatten flattests; putStrLn "Results:") - runTestTT flattests - where - deeptests = tfilter matchname $ TestList tests - flattests = TestList $ filter matchname $ concatMap tflatten tests - matchname = matchpats args . tname - n = length ts where (TestList ts) = flattests - s | null args = "" - | otherwise = printf " matching %s " +runtests opts args = runner flattests + where + runner | (Verbose `elem` opts) = runVerboseTests + | otherwise = \t -> runTestTT t >>= return . (flip (,) 0) + deeptests = tfilter matchname $ TestList tests + flattests = TestList $ filter matchname $ concatMap tflatten tests + matchname = matchpats args . tname + n = length ts where (TestList ts) = flattests + s | null args = "" + | otherwise = printf " matching %s " (intercalate ", " $ map (printf "\"%s\"") args) -- test utils diff --git a/hledger.cabal b/hledger.cabal index e265611ae..6ef00fc74 100644 --- a/hledger.cabal +++ b/hledger.cabal @@ -33,7 +33,7 @@ Executable hledger Build-Depends: base, containers, haskell98, directory, parsec, regex-compat, regexpr>=0.5.1, old-locale, time, - HUnit, mtl, bytestring, filepath, process + HUnit, mtl, bytestring, filepath, process, testpack Other-Modules: BalanceCommand Options