You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Coverage does not work for packages that use internal libraries or library components #6440
Describe the bug
Coverage does not work for packages that use internal libraries or library components. This is true even if package is only a build dependency, making it very easy encounter this issue on any reasonably sized project.
To Reproduce
Steps to reproduce the behavior:
$ git clone [email protected]:haskell-works/hw-ip.git
$ cd hw-ip
$ cabal v2-test --enable-coverage
Error:
Internal libraries only supported with per-component builds.
Per-component builds were disabled because program coverage is enabled
In the package 'hw-ip-2.4.0.1'
Please use version-prefixed commands (e.g. v2-build or v1-build) to avoid ambiguity.
Expected behavior
I expect coverage to just work for any typical package that has been published to hackage.
System information
$ cabal --version
cabal-install version 3.0.0.0
compiled using version 3.0.0.0 of the Cabal library
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.6.5
$ uname -a
Darwin INTLKyMac.local 18.7.0 Darwin Kernel Version 18.7.0: Sat Oct 12 00:02:19 PDT 2019; root:xnu-4903.278.12~1/RELEASE_X86_64 x86_64
Additional context
None
Reacted by Emily Pillmore, Bradley Saul, Francesco Gazzetta, İlkecan Bozdoğan, Peter Becich, Rodrigo Mesquita, Adrian Sieber and Chris D'Aloisio
I believe this may be the reason behind copilot-core's tests being reported as broken on hackage.
I ran the build in a docker image using:
cabal test all --enable-coverage --disable-optimization copilot**/
and was met with:
Resolving dependencies...
Error:
Internal libraries only supported with per-component builds.
Per-component builds were disabled because program coverage is enabled
In the package 'attoparsec-0.14.4'
% cabal test --enable-coverage
Resolving dependencies...
Error:
Internal libraries only supported with per-component builds.
Per-component builds were disabled because program coverage is enabled
In the package 'attoparsec-0.14.4'
The workaround #6440 (comment) does not appear to have an effect:
If I add that and run cabal test (without specifying the --enable-coverage) flag, then I'm able to observe .mix and .tix files after running the pandoc test suite.
In fact, I don't think the workaround even requires disabling coverage for packages with internal libraries. I was also able to get coverage working using cabal test and this simpler configuration:
--enable-coverage would override the options set in the config files for local packages, being equivalent to top level, out of any package stanza, coverage: true
in theory of course
Activity
symbiont-sam-halliday commentedon Mar 23, 2020
I also observe this with cabal-install 3.0.0.0 and ghc-8.3.3.
It is unfortunate, because the equivalent command works in stack on the same project.
If I do
--enable-coverage --disable-library-coverageI don't see any files after runningcabal test.symbiont-sam-halliday commentedon Mar 26, 2020
Workaround: #5213 (comment)
tl;dr specifically disable coverage for libraries that use internal libraries, e.g.
(note that this doesn't work if we don't use
package *)ivanperez-keera commentedon May 7, 2022
I believe this may be the reason behind copilot-core's tests being reported as broken on hackage.
I ran the build in a docker image using:
and was met with:
peterbecich commentedon May 15, 2022
I see this with Cabal 3.6.2.0 and Pandoc:
After cloning https://github.com/jgm/pandoc.git,
The workaround #6440 (comment) does not appear to have an effect:
I've tried a couple variations on this
cabal.projectI have also installed the latest version of Cabal (3.7.0.0) from this repository and tried that.
This does succeed:
However, there are no
.mixor.tixfiles created.RyanGlScott commentedon May 16, 2022
I think you're missing a key part of the workaround in #6440 (comment), which is the
package *stanza:If I add that and run
cabal test(without specifying the--enable-coverage) flag, then I'm able to observe.mixand.tixfiles after running thepandoctest suite.RyanGlScott commentedon May 16, 2022
In fact, I don't think the workaround even requires disabling coverage for packages with internal libraries. I was also able to get coverage working using
cabal testand this simpler configuration:Mikolaj commentedon May 16, 2022
Probably
--enable-coverageprobably overrides anything in the project file, which would explain the observations.jneira commentedon May 16, 2022
--enable-coveragewould override the options set in the config files for local packages, being equivalent to top level, out of any package stanza,coverage: truein theory of course
peterbecich commentedon May 21, 2022
#6440 (comment) @RyanGlScott you are correct, it works with Cabal 3.6.2.0 and
and
cabal test.I see the
.mixand.tixfilesThanks all
Allow per-component builds with coverage enabled
43 remaining items
HPC artifacts are written and read from pkg-db
HPC artifacts are written and read from pkg-db
Per-component multi-package builds with coverage enabled
HPC artifacts are written and read from pkg-db
Per-component multi-package builds with coverage enabled
HPC artifacts are written and read from pkg-db
HPC artifacts are written and read from pkg-db
peterbecich commentedon Feb 18, 2024
Can this issue be re-opened? I believe this work-around is still necessary: #6440 (comment)
dpwiz commentedon Feb 27, 2024
Yep, it is. Came here right after hitting the
attoparsecerror.Per-component multi-package builds with coverage enabled
HPC artifacts are written and read from pkg-db
ivanperez-keera commentedon Sep 16, 2024
The
attoparsecerror is the reason whycopilot-languageis not running the tests on hackage, by the way: https://hackage.haskell.org/package/copilot-language-4.0/reports/1/testgbaz commentedon Jul 13, 2025
This would be good to fix. It looks like threre's some draft work by @erikd and @alt-romes linked above? What's the status on that?