Re: [HUnit-users] PyUnit-style progress output
Status: Beta
Brought to you by:
dherington
|
From: Dean H. <her...@cs...> - 2002-08-05 20:59:49
|
Shae Matijs Erisson wrote:
> Dean Herington <her...@cs...> writes:
>
> > 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".
>
> This is great! Thanks much! It works just like I wished for.
Be careful what you wish for! In fact, the version I posted always reports success
(dots), even in the presence of errors and/or failures. Moreover, each error and
failure shows as an additional success dot.
A corrected version--well-tested this time, I think--appears below. Give it a try
while I scrape the egg off my face ...
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 rep (bad 'E') (bad 'F') ' ' t
rep undefined final
hPutStrLn stderr ('\n' : showCounts counts)
return counts
where
bad c _ _ _ = return c
rep _ c = do unless (c == ' ') (do hPutChar stderr c; hFlush stderr)
return '.'
|