tweak doctest output, and compile it
This commit is contained in:
parent
abf86f31fa
commit
f1ab2fcdbb
7
Makefile
7
Makefile
@ -45,8 +45,11 @@ unittest:
|
|||||||
./hledger.hs test
|
./hledger.hs test
|
||||||
|
|
||||||
# run doc tests
|
# run doc tests
|
||||||
doctest:
|
doctest: tools/doctest
|
||||||
tools/doctest.hs Tests.hs
|
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
|
# build profiling-enabled hledgerp and archive and show a cleaned-up profile
|
||||||
# you may need to rebuild some libs: sudo cabal install --reinstall -p ...
|
# you may need to rebuild some libs: sudo cabal install --reinstall -p ...
|
||||||
|
|||||||
@ -39,13 +39,13 @@ main = do
|
|||||||
f <- head `fmap` getArgs
|
f <- head `fmap` getArgs
|
||||||
s <- readFile f
|
s <- readFile f
|
||||||
let tests = doctests s
|
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
|
mapM_ runShellDocTest $ doctests s
|
||||||
|
|
||||||
runShellDocTest :: String -> IO Bool
|
runShellDocTest :: String -> IO Bool
|
||||||
runShellDocTest s = do
|
runShellDocTest s = do
|
||||||
let (cmd, expected) = splitDocTest s
|
let (cmd, expected) = splitDocTest s
|
||||||
putStr $ printf "testing: %s .. " cmd
|
putStr $ printf "Testing: %s .. " cmd
|
||||||
(_, out, _, h) <- runInteractiveCommand cmd
|
(_, out, _, h) <- runInteractiveCommand cmd
|
||||||
exit <- waitForProcess h
|
exit <- waitForProcess h
|
||||||
output <- hGetContents out
|
output <- hGetContents out
|
||||||
@ -56,7 +56,7 @@ runShellDocTest s = do
|
|||||||
putStrLn "ok"
|
putStrLn "ok"
|
||||||
return True
|
return True
|
||||||
else do
|
else do
|
||||||
putStr $ printf "FAILED\nexpected:\n%sgot:\n%s" expected output
|
putStr $ printf "FAILED\nExpected:\n%sGot:\n%s" expected output
|
||||||
return False
|
return False
|
||||||
else do
|
else do
|
||||||
putStrLn $ printf "ERROR: %s" (show exit)
|
putStrLn $ printf "ERROR: %s" (show exit)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user