Cabal and testing

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Sat Aug 4 13:18:23 EDT 2007


On Sat, 2007-08-04 at 17:54 +0100, Neil Mitchell wrote:
> Hi
> 
> I'm just about to hook up Cabal for doing some testing, so I started
> with the obvious template:
> 
> import Distribution.Simple
> main = defaultMainWithHooks defaultUserHooks{runTests=test}
> 
> test :: Args -> Bool -> PackageDescription -> LocalBuildInfo -> IO ExitCode
> test args bool pd lbi = return ExitSuccess
> 
> A few questions about this interface:
> 
> 1) What on earth is "bool"? Perhaps either a haddock comment, or a
> type alias would make it more clear.

No idea :-)

Cabal currently passes False if that helps you at all :-)

> 2) If the tests fail to run, ExitFailure would be appropriate. If the
> tests run and pass then ExitSuccess seems sensible. If the tests run,
> but fail, what should be returned?

In the current Cabal version all the hooks that used to return IO
ExitCode now return just IO (). So the behaviour you want to use going
forward is to just throw an exception / IOError.

> 3) On failure should I "print" something, or just "error" out?

Both. You can use something like:
Distribution.Simple.Utils.die "tests failed blah blah blah"

Duncan



More information about the cabal-devel mailing list