mirror of
https://github.com/simonmichael/hledger.git
synced 2024-09-18 17:57:11 +03:00
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
|
||||
|
||||
# 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 ...
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user