Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage with --enable-coverage fails when tests are kept in a separate package #7200

Closed
harendra-kumar opened this issue Dec 17, 2020 · 4 comments

Comments

@harendra-kumar
Copy link

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
@ag-eitilt
Copy link
Collaborator

This is very likely the same issue as #5433 -- not an issue with test packages specifically, but instead with any package depending on another in the same project.

@Mikolaj
Copy link
Member

Mikolaj commented Jun 30, 2021

@harendra-kumar: it's quite likely this got fixed in #7250 and/or #7358, which are both merged. Could you perhaps check, e.g., using a dev releast that can be obtained as in #7458 (comment)

@harendra-kumar
Copy link
Author

@Mikolaj Yes, I verified. it is working. Thanks to all devs!

It's good to see cabal bugs being fixed and closed.

@Mikolaj
Copy link
Member

Mikolaj commented Jun 30, 2021

\o/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants