I find hpc really confusing, even after reading several explanations and playing around quite a bit.
I have a library HML
, and two test suites fileio-test
and types-test
, using HTF
(I plan on moving to tasty
). I'd like to run the two tests and then see the combined coverage from the two over the library.
At the moment I build the library using
cabal configure --enable-coverage
cabal build
And run the tests using
cabal configure --enable-coverage --enable-tests
cabal build
cabal test
hpc report --hpc-dir dist/hpc/vanilla/mix/fileio-test dist/hpc/vanilla/tix/fileio-test/fileio-test.tix
This shows me some coverage, but not the correct one. What I think is that it shows coverage, but only from one of the tests, and also includes coverage of the tests themselves.
I tried using
--hpc-dir dist/hpc/vanilla/mix/HML-0.1.0.0
But then hpc complains it can't find the module files it needs. I also tried combining coverage from the two tests with no luck.
Any pointers?
I am also attempting to call HPC directly and have a similar error.
Cabal 3.6 should be able to generate your HPC report for you without needing to call HPC like you describe. It can bypass that error. There is one caveat: https://github.com/haskell/cabal/issues/6440#issuecomment-1133542171
Add to
cabal.project
:then
cabal test
. The report should be somewhere indist-newstyle
.Reading the verbose log from
cabal test
with the options above has shown the correct arguments to HPC. It solves the module error. Here is an example for Mustache: https://github.com/JustusAdam/mustacheAdd to
cabal.project
:then
cabal test -v all > foo.log
.In
foo.log
there should be a call to HPC such as:Take that, replace
markup
withreport
, and remove--destdir
, which gives something like:Pasting that into the terminal in the root of the Mustache project yields: