Tests in Cabal

Adrian Hey ahey at iee.org
Wed Jan 9 05:27:16 EST 2008


I've been playing about with the option to add tests to packages
and have modified the Setup.hs as follows..

import Distribution.Simple
import MyPackage

main :: IO ()
main = defaultMainWithHooks (simpleUserHooks {runTests = myTests})

myTests :: Args -> Bool -> PackageDescription -> LocalBuildInfo -> IO ()
myTests _ _ _ _ = <whatever>

Which I think is the right thing to do if I understand the docs. The
first problem I come up against is that in order to do this practically
all the modules from the package need compiling by runghc (even during
the configure stage presumably). As I guess most people will be using
runHaskell/runghc to do this it seems like this will all take quite a
bit of time.

In my case the process fails completely because the package library
files need CPPing and is seems runghc doesn't do this (by default at

Is this really the way tests are supposed to be included?

It doesn't seem workable to me. I wonder if it would be better to just
build the lib first (without tests) and then separately build one or
more test executables?

What does everyone else do about this?

Adrian Hey

More information about the Libraries mailing list