[Haskell-cafe] HUnit/cabal integration

Richard Cobbe cobbe at ccs.neu.edu
Fri Jul 6 04:05:10 CEST 2012

On Thu, Jul 05, 2012 at 04:17:33PM +0200, Simon Hengel wrote:
> > First: the web page I cite above describes the interface that the test
> > binary must support to work with cabal, specifically w.r.t. the binary's
> > exit code.  "Your test suites likely already fit this model.  However, if
> > you are using an old version of QuickCheck or HUnit, your executable may
> > not be returning the correct error code."
> >
> > This seems to me to suggest that recent versions of HUnit automatically
> > take care of generating the exit code, but I've found that I have to
> > examine HUnit's results and synthesize the exit code manually, as in the
> > driver program below.  (I'm running HUnit, but the interface for
> > doesn't appear to differ on this point.)  Am I misinterpreting the
> > wiki page, or am I missing something in HUnit's API that generates the exit
> > code automatically?
> AFAIK, you have to do it explicitly.  But you can shorten it to
> something like this:
>     when (errors c /= 0 || failures c /= 0)
>       exitFailure

Ah, good suggestion.  Thanks!

> > Second: Am I specifying the Build-Depends correctly for the Test-Suite?
> > Specifically: do I need to state a dependency on the library defined in the
> > same package, or does it pick that up automatically?  Further, foo-tests
> > doesn't use parsec directly.  Is the transitive dependency automatically
> > provided for me, or do I need to list it explicitly as below?


> Let's look at an example.

Many thanks for your advice -- and I particularly appreciate the examples!
I haven't had a chance to try them out yet, but I hope to be able to soon.

Thanks a bunch for your help,


More information about the Haskell-Cafe mailing list