diff --git a/Options.hs b/Options.hs index 6f33bce15..3c207f8cb 100644 --- a/Options.hs +++ b/Options.hs @@ -38,6 +38,7 @@ options = [ Option ['n'] ["collapse"] (NoArg Collapse) "balance report: no grand total", Option ['s'] ["subtotal"] (NoArg SubTotal) "balance report: show subaccounts", Option ['h'] ["help"] (NoArg Help) "show this help", + Option ['v'] ["verbose"] (NoArg Verbose) "verbose test output", Option ['V'] ["version"] (NoArg Version) "show version" ] @@ -54,6 +55,7 @@ data Opt = Collapse | SubTotal | Help | + Verbose | Version deriving (Show,Eq) diff --git a/Tests.hs b/Tests.hs index b5f74a53e..7bd28d6cb 100644 --- a/Tests.hs +++ b/Tests.hs @@ -11,8 +11,11 @@ import PrintCommand import RegisterCommand -runtests args = do - putStrLn $ printf "Running %d tests%s ..\n" n s +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 @@ -20,7 +23,7 @@ runtests args = do matchname = matchpats args . tname n = length ts where (TestList ts) = flattests s | null args = "" - | otherwise = printf " matching %s" + | otherwise = printf " matching %s " (intercalate ", " $ map (printf "\"%s\"") args) ------------------------------------------------------------------------------ diff --git a/hledger.hs b/hledger.hs index 561538fac..796d698a0 100644 --- a/hledger.hs +++ b/hledger.hs @@ -62,7 +62,7 @@ main = do | cmd `isPrefixOf` "balance" = parseLedgerAndDo opts args balance | cmd `isPrefixOf` "print" = parseLedgerAndDo opts args print' | cmd `isPrefixOf` "register" = parseLedgerAndDo opts args register - | cmd `isPrefixOf` "test" = runtests args >> return () + | cmd `isPrefixOf` "test" = runtests opts args >> return () | otherwise = putStr usage -- | parse the user's specified ledger file and do some action with it