I have a small / medium sized Haskell database for which I would like to create a coverage report. By default, the coverage report provided by HPC is filled with false negatives (for example, I use lenses to access most of my recording fields, and not automatically generated ones, which HPC then reports that they are not covered).
A typical solution for this is to create some kind of overlay, as indicated here: https://wiki.haskell.org/Haskell_program_coverage#Hpc_toolkit
When I try to do this with Stack, I run into a problem.
$ stack new --resolver=lts-9.5 hpcTest
If we edit src/Lib.hs
as follows:
module Lib
( someFunc, otherFunc
) where
someFunc :: IO ()
someFunc = putStrLn "someFunc"
otherFunc :: IO ()
otherFunc = putStrLn "otherFunc"
and test/spec.hs
:
import Lib
main :: IO ()
main = someFunc
and run stack test --coverage
, 100%, , wiki, : stack exec hpc -- draft --hpcdir=.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/hpc/ --srcdir=. .stack-work/install/x86_64-linux/lts-9.5/8.0.2/hpc/hpcTest/hpcTest-test/hpcTest-test.tix > myDraft.txt
, myDraft.txt
:
module "hpcTest-0.1.0.0-HnYRxRg1qoiyMKwsCMtby:Lib" {
tick function "otherFunc" on line 9;
}
stack exec hpc -- overlay --hpcdir=.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/hpc/ --srcdir=. myDraft.txt
, , :
hpc: can not find hpcTest-0.1.0.0-HnYRxRg1qoiyMKwsCMtby:Lib in ./.hpc, ./.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/hpc/
CallStack (from HasCallStack):
error, called at libraries/hpc/Trace/Hpc/Mix.hs:122:15 in hpc-0.6.0.3:Trace.Hpc.Mix
?