Coverage doesn't work if the test suite doesn't depend on the library
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
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 a92bfc8dfa806e998d49bc661a65020bfb335694
Contributor guide
Assessment
This issue has not been assessed yet.