
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? Thanks Klaus

On 10 March 2011 08:12, Hauschild, Klaus (EXT)
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- 1.10.1.0 and cabal-install-0.10.2 have support for test-suites. The documentation is not online yet so here's an example from my threads package: http://code.haskell.org/~basvandijk/code/threads/threads.cabal 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 supported: test-suite test-threads type: exitcode-stdio-1.0 main-is: test.hs build-depends: ... 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. Good luck, Bas

On Thu, Mar 10, 2011 at 10:06 AM, Bas van Dijk
On 10 March 2011 08:12, Hauschild, Klaus (EXT)
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- 1.10.1.0 and cabal-install-0.10.2 have support for test-suites.
The documentation is not online yet so here's an example from my threads package:
You can find the docs here: http://www.haskell.org/cabal/release/cabal-1.10.1.0/doc/users-guide/#test-su... These are not yet the default docs (i.e. the docs linked from the Cabal home page) but will likely be soon. Johan
participants (3)
-
Bas van Dijk
-
Hauschild, Klaus (EXT)
-
Johan Tibell