Open newhoggy opened 4 years ago
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-coverage
I don't see any files after running cabal test
.
Workaround: https://github.com/haskell/cabal/issues/5213#issuecomment-586517129
tl;dr specifically disable coverage for libraries that use internal libraries, e.g.
package *
coverage: True
library-coverage: True
package dns
coverage: False
library-coverage: False
(note that this doesn't work if we don't use package *
)
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'
I see this with Cabal 3.6.2.0 and Pandoc:
After cloning https://github.com/jgm/pandoc.git,
% 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 https://github.com/haskell/cabal/issues/6440#issuecomment-604409595 does not appear to have an effect:
packages: *
tests: True
flags: +embed_data_files
constraints: aeson >= 2.0.1.0
-- coverage: True
-- library-coverage: False
package attoparsec
coverage: False
library-coverage: False
I've tried a couple variations on this cabal.project
I have also installed the latest version of Cabal (3.7.0.0) from this repository and tried that.
This does succeed:
cabal test --enable-coverage --disable-library-coverage
However, there are no .mix
or .tix
files created.
I think you're missing a key part of the workaround in https://github.com/haskell/cabal/issues/6440#issuecomment-604409595, which is the package *
stanza:
package *
coverage: True
library-coverage: True
package attoparsec
coverage: False
library-coverage: False
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:
package *
coverage: True
library-coverage: True
Probably --enable-coverage
probably overrides anything in the project file, which would explain the observations.
--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
https://github.com/haskell/cabal/issues/6440#issuecomment-1127513329 @RyanGlScott you are correct, it works with Cabal 3.6.2.0 and
package *
coverage: True
library-coverage: True
and cabal test
.
I see the .mix
and .tix
files
Thanks all
Can this issue be re-opened? I believe this work-around is still necessary: https://github.com/haskell/cabal/issues/6440#issuecomment-1133542171
Yep, it is. Came here right after hitting the attoparsec
error.
The attoparsec
error is the reason why copilot-language
is not running the tests on hackage, by the way: https://hackage.haskell.org/package/copilot-language-4.0/reports/1/test
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:
Please use version-prefixed commands (e.g.
v2-build
orv1-build
) to avoid ambiguity.Expected behavior I expect coverage to just work for any typical package that has been published to hackage.
System information
Additional context None