tweak doctest output, and compile it

This commit is contained in:
Simon Michael 2009-03-15 08:47:23 +00:00
parent abf86f31fa
commit f1ab2fcdbb
2 changed files with 8 additions and 5 deletions

View File

@ -45,8 +45,11 @@ unittest:
./hledger.hs test
# run doc tests
doctest:
tools/doctest.hs Tests.hs
doctest: tools/doctest
tools/doctest Tests.hs
tools/doctest: tools/doctest.hs
ghc --make tools/doctest.hs
# build profiling-enabled hledgerp and archive and show a cleaned-up profile
# you may need to rebuild some libs: sudo cabal install --reinstall -p ...

View File

@ -39,13 +39,13 @@ main = do
f <- head `fmap` getArgs
s <- readFile f
let tests = doctests s
putStrLn $ printf "running %d doctests from %s" (length tests) f
putStrLn $ printf "Running %d doctests from %s" (length tests) f
mapM_ runShellDocTest $ doctests s
runShellDocTest :: String -> IO Bool
runShellDocTest s = do
let (cmd, expected) = splitDocTest s
putStr $ printf "testing: %s .. " cmd
putStr $ printf "Testing: %s .. " cmd
(_, out, _, h) <- runInteractiveCommand cmd
exit <- waitForProcess h
output <- hGetContents out
@ -56,7 +56,7 @@ runShellDocTest s = do
putStrLn "ok"
return True
else do
putStr $ printf "FAILED\nexpected:\n%sgot:\n%s" expected output
putStr $ printf "FAILED\nExpected:\n%sGot:\n%s" expected output
return False
else do
putStrLn $ printf "ERROR: %s" (show exit)