Replicating coverage report on user side
I'm trying to replicate the coverage report we are getting on this package: https://hackage.haskell.org/package/copilot-core
When I run what I believe are the same instructions locally, I'm met with:
# cabal v2-test --enable-coverage --test-log=testFile --test-show-details=never --disable-optimization
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 reported this on cabal's repo a while back (https://github.com/haskell/cabal/issues/6440#issuecomment-1120314764) and a fix was pushed 2 weeks ago; however, hackage is somehow still obtaining some coverage metrics, so there's gotta be a way to get that same coverage result without needed a new version of cabal.
I tried reviewing the build and test logs but they do not include the commands being executed (it'd be nice if they did).
What commands is hackage running on our package to produce that coverage result?
here's the relevant function in the hackage builder: https://github.com/haskell/hackage-server/blob/master/exes/BuildClient.hs#L652
Not sure why the results would be different on hackage vs locally.
oh -- i see! in the working setup, cabal is ensuring that program coverage is only enabled for the current library being built. (because it builds the other code first, i believe). somehow, i suspect that the --enable-coverage flag set on the command line with that version of cabal is instead being scoped over dependencies -- hence causing the problem not with copilot itself, but rather with attoparsec.
i'm not sure the story with scoping of such flags in the latest version of cabal, but i hope its improved.