[HUnit-users] PyUnit-style progress output
Status: Beta
Brought to you by:
dherington
|
From: Dean H. <her...@cs...> - 2002-08-05 17:51:23
|
Shae,
You had requested test progress output in the style of PyUnit. I've
attached below some code to do that. As I'm not very familiar with
PyUnit, I may not have gotten it just the way you like it, but I'm sure
you can "season to taste".
Sorry for the delay in providing this code. I just returned from a
relatively long vacation.
Dean
module RunTestDots where
import HUnit
import Monad
import IO
-- Runs an HUnit test. Progress is indicated by writing to standard
-- error a single character for each test case: '.', 'E', or 'F' as
-- the result is "ok", "error", or "failure", respectively. At the
-- completion of all test cases, the final counts (bracketed by single
-- newlines) are written with `showCounts`.
runTestDots :: Test -> IO Counts
runTestDots t = do
(counts, final) <- performTest ok (bad 'E') (bad 'F') True t
ok undefined final
hPutStrLn stderr ('\n' : showCounts counts)
return counts
where
ok _ first = do unless first (put '.'); return False
bad ch _ _ _ = do put ch; return False
put ch = do hPutChar stderr '.'; hFlush stderr
|