Opened 2 years ago

Closed 2 years ago

#10502 closed bug (invalid)

Bad interaction of sandboxes and coverage

Reported by: qnikst Owned by:
Priority: normal Milestone:
Component: Code Coverage Version: 7.10.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

It seems that when using sandboxes with project and coverage (--enable-coverage) cabal fails to generate and find .mix files for dependencies.

Steps to reproduce:

  1. create shared sandbox (not sure that shared sandbox plays it's role here):

cabal sandbox init --sandbox=../.shared

  1. install all dependencies with enable-coverage

cabal install --dependencies-only --enable-coverage --enable-tests

  1. install library

cabal install --enable-coverage --run-tests

Expected results:

  1. Library will be built, coverage output will be generated.

Actual results: hpc fails to find .mix files:

hpc: can not find netwo_Bdsn6Y1VKLa3MCczwSV70J/Network.Socket.ByteString.MsgHdr
in ["./.hpc"
   ,"./dist/dist-sandbox-f7da581b/hpc/vanilla/mix/network-transport-tcp-0.4.1"
   ,"./dist/dist-sandbox-f7da581b/hpc/vanilla/mix/TestTCP"]

Tested on ghc-7.10.1 in clear official docker container on network-transport-tcp package.

Side node: during tests on bigger project I have seen similar failures even on step 2 (e.g. network package fails with similar error message), but I was not able to reproduce it in minimal example.

Possibly related report: #10259

Change History (1)

comment:1 Changed 2 years ago by rwbarton

Resolution: invalid
Status: newclosed

This is a Cabal issue, not a GHC issue. Cabal does not really support installing packages built with --enable-coverage. The installation will succeed, and the libraries themselves work, but Cabal does not install the .mix files anywhere, so running hpc on a program that uses the libraries will fail, as you found.

You can just omit --enable-coverage from the install --dependencies-only command to get a coverage report that includes the modules from the library you are testing (here network-transport-tcp). If you really want to get a report of how the network-transport-tcp tests cover the modules in its dependencies, then you need support for this to be added to Cabal.

Note: See TracTickets for help on using tickets.