[Haskell-cafe] The State of Testing?
Thomas Tuegel
ttuegel at gmail.com
Wed Feb 8 04:03:16 CET 2012
On Tue, Feb 7, 2012 at 3:23 PM, Austin Seipp <mad.one at gmail.com> wrote:
> If you're writing a library, you need to compile the library with
> `-fhpc`, i.e. put it in the library stanza, not the testsuite stanza,
> and then you can compile the test program using your library - the
> resulting 'tix' file will contain the library coverage reports. You
> can link a HPC-built library into an executable not compiled with HPC
> just fine.
>
> Normally I only compile the library under HPC mode, link it in a test,
> and distribute the results from that. That way your coverage reports
> don't include the test module (which may or may not be relevant.)
>
> I normally add a cabal flag called 'hpc' which optionally enables
> coverage reports for my library, e.g.
>
> flag hpc
> default: False
>
> library
> ...
> ...
> if flag(hpc)
> ghc-options: -fhpc
>
> Then when you want coverage reports, just say 'cabal install -fhpc
> --enable-tests' and the resulting properties executable will spit out
> the results when run.
First, as author of the test suite code, let me apologize for the
terrible documentation.
This is absolutely NOT how coverage reports are supposed to work. If
you configure with '--enable-tests --enable-library-coverage', Cabal
will take care of _everything_ else for you, including excluding the
test module from the coverage report. You should not have to put any
flag gymnastics in your .cabal file.
If this doesn't work for you, please let me know, because it's a bug.
Thanks!
--
Thomas Tuegel
More information about the Libraries
mailing list