Skip to content

Coverage doesn't work if the test suite doesn't depend on the library #3682

@mightybyte

Description

@mightybyte

To reproduce this, first clone this repo:

git clone https://github.com/mightybyte/map-syntax.git

Then the following inside the map-syntax repo generates nice HPC test coverage reports:

git checkout hpc-works
cabal install --enable-tests
cabal test
hpc markup --destdir=hpc testsuite

This appears to generate HPC test coverage reports, but they are actually empty:

git checkout hpc-broken
cabal install --enable-tests --enable-coverage
cabal test

In this case, cabal test is supposed to generate the coverage reports for you, so the last hpc line from the other example should not be needed. The only difference between the two branches is a ghc-options: -fhpc line in the cabal file.

The biggest problem here is that I actually can't use the hpc-works approach because cabal sdist says that I should not use the -fhpc option inside my .cabal file and that hackage will reject my package.

One other thing that would be good to keep in mind here is that hpc allows you to tweak things with a variety of command line flags like --exclude, --include, etc. Whatever solution cabal gives us should still make it possible to specify your own flags. Maybe this is as simple as putting the coverage data in a predictable place so you can run hpc manually. But it is still probably something that we need to think about if we're going to continue outlawing -fhpc in .cabal files.

This is with cabal-install-1.25.0.0. I think built from commit a92bfc8

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions