Description
Describe the bug
We have a main streamly
package and a separate packages for tests streamly-tests
. They are in the same repository and built using a cabal.project
file. But with this, coverage with --enable-coverage
fails.
Verbose option shows that hpc is called with --hpcdir
corresponding to streamly-tests
package but streamly
library is not being used in --hpcdir
arguments:
/nix/store/1nbxcb9g5ys0q0y8sfvsvd4gjb0jml81-ghc-8.8.3-with-packages/bin/hpc markup /home/harendra/composewell/streamly1/.packcheck/streamly-0.7.2/dist-newstyle/build/x86_64-linux/ghc-8.8.3/streamly-tests-0.0.0/hpc/vanilla/tix/Data.Array/Data.Array.tix '--destdir=/home/harendra/composewell/streamly1/.packcheck/streamly-0.7.2/dist-newstyle/build/x86_64-linux/ghc-8.8.3/streamly-tests-0.0.0/hpc/vanilla/html/Data.Array' '--hpcdir=/home/harendra/composewell/streamly1/.packcheck/streamly-0.7.2/dist-newstyle/build/x86_64-linux/ghc-8.8.3/streamly-tests-0.0.0/hpc/vanilla/mix/Data.Array' '--hpcdir=/home/harendra/composewell/streamly1/.packcheck/streamly-0.7.2/dist-newstyle/build/x86_64-linux/ghc-8.8.3/streamly-tests-0.0.0/hpc/vanilla/mix/streamly-tests-0.0.0' '--exclude=Main'
hpc: can not find streamly-0.7.2-inplace/Streamly.Internal.Data.Either.Strict in ./.hpc, /home/harendra/composewell/streamly1/.packcheck/streamly-0.7.2/dist-newstyle/build/x86_64-linux/ghc-8.8.3/streamly-tests-0.0.0/hpc/vanilla/mix/streamly-tests-0.0.0, /home/harendra/composewell/streamly1/.packcheck/streamly-0.7.2/dist-newstyle/build/x86_64-linux/ghc-8.8.3/streamly-tests-0.0.0/hpc/vanilla/mix/Data.Array
CallStack (from HasCallStack):
error, called at libraries/hpc/Trace/Hpc/Mix.hs:122:15 in hpc-0.6.0.3:Trace.Hpc.Mix
CallStack (from HasCallStack):
die', called at ./Distribution/Client/ProjectOrchestration.hs:1041:55 in main:Distribution.Client.ProjectOrchestration
cabal: Tests failed for streamly-tests-0.0.0-inplace.
We had to separate the tests because cabal does not allow an internal test library when the build type is configure
. We need an internal test library because we have a lot of common code which would have to be built for each test-suite without a library, increasing build times enormously.
To Reproduce
Use a library package (./lib-package.cabal
) and a test package (./test/test-package.cabal
) in the same project, add them to cabal.project
and:
$ cabal v2-test -v --enable-tests --enable-coverage all
Expected behavior
We should be able to use --enable-coverage when tests are separated from the main library.
System information
- Linux
- cabal --version
cabal-install version 3.2.0.0
compiled using version 3.2.0.0 of the Cabal library - ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.8.3