[Haskell-cafe] Automated tests with cabal
Bas van Dijk
v.dijk.bas at gmail.com
Thu Mar 10 10:06:49 CET 2011
On 10 March 2011 08:12, Hauschild, Klaus (EXT)
<klaus.hauschild.ext at siemens.com> wrote:
> Hi Haskellers,
> I read about the cabal features for running test code from Setup.hs with
> "defaultMainWithHooks". I'm looking for more generic code that allows me to
> place any haskell in a subdirectory "test" or so and "cabal test" will run
> this test without any modification of my Setup.hs.
> Is there a possibility?
There is. The just released Cabal- 184.108.40.206 and cabal-install-0.10.2
have support for test-suites.
The documentation is not online yet so here's an example from my
Make sure you specify: cabal-version: >= 1.9.2
A test-suite looks a lot like a normal executable section but it has
to specify the test-suite type. Currently only "exitcode-stdio-1.0" is
To run the test-suite you first need to configure it:
$ cabal configure --enable-tests
then build it:
$ cabal build
then run it:
$ cabal test
Running 1 test suites...
Test suite test-threads: RUNNING...
Test suite test-threads: PASS
Test suite logged to: dist/test/threads-0.4-test-threads.log
1 of 1 test suites (1 of 1 test cases) passed.
More information about the Haskell-Cafe