add a --verbose/-v flag, use it to show more test-running detail

This commit is contained in:
Simon Michael 2008-11-22 04:49:00 +00:00
parent f3f74cb64f
commit 565feb594e
3 changed files with 9 additions and 4 deletions

View File

@ -38,6 +38,7 @@ options = [
Option ['n'] ["collapse"] (NoArg Collapse) "balance report: no grand total", Option ['n'] ["collapse"] (NoArg Collapse) "balance report: no grand total",
Option ['s'] ["subtotal"] (NoArg SubTotal) "balance report: show subaccounts", Option ['s'] ["subtotal"] (NoArg SubTotal) "balance report: show subaccounts",
Option ['h'] ["help"] (NoArg Help) "show this help", Option ['h'] ["help"] (NoArg Help) "show this help",
Option ['v'] ["verbose"] (NoArg Verbose) "verbose test output",
Option ['V'] ["version"] (NoArg Version) "show version" Option ['V'] ["version"] (NoArg Version) "show version"
] ]
@ -54,6 +55,7 @@ data Opt =
Collapse | Collapse |
SubTotal | SubTotal |
Help | Help |
Verbose |
Version Version
deriving (Show,Eq) deriving (Show,Eq)

View File

@ -11,8 +11,11 @@ import PrintCommand
import RegisterCommand import RegisterCommand
runtests args = do runtests opts args = do
putStrLn $ printf "Running %d tests%s ..\n" n s when (Verbose `elem` opts)
(do
putStrLn $ printf "Running %d tests%s:" n s
sequence $ map (putStrLn . tname) $ tflatten flattests; putStrLn "Results:")
runTestTT flattests runTestTT flattests
where where
deeptests = tfilter matchname $ TestList tests deeptests = tfilter matchname $ TestList tests
@ -20,7 +23,7 @@ runtests args = do
matchname = matchpats args . tname matchname = matchpats args . tname
n = length ts where (TestList ts) = flattests n = length ts where (TestList ts) = flattests
s | null args = "" s | null args = ""
| otherwise = printf " matching %s" | otherwise = printf " matching %s "
(intercalate ", " $ map (printf "\"%s\"") args) (intercalate ", " $ map (printf "\"%s\"") args)
------------------------------------------------------------------------------ ------------------------------------------------------------------------------

View File

@ -62,7 +62,7 @@ main = do
| cmd `isPrefixOf` "balance" = parseLedgerAndDo opts args balance | cmd `isPrefixOf` "balance" = parseLedgerAndDo opts args balance
| cmd `isPrefixOf` "print" = parseLedgerAndDo opts args print' | cmd `isPrefixOf` "print" = parseLedgerAndDo opts args print'
| cmd `isPrefixOf` "register" = parseLedgerAndDo opts args register | cmd `isPrefixOf` "register" = parseLedgerAndDo opts args register
| cmd `isPrefixOf` "test" = runtests args >> return () | cmd `isPrefixOf` "test" = runtests opts args >> return ()
| otherwise = putStr usage | otherwise = putStr usage
-- | parse the user's specified ledger file and do some action with it -- | parse the user's specified ledger file and do some action with it