hackage-server icon indicating copy to clipboard operation
hackage-server copied to clipboard

Replicating coverage report on user side

Open ivanperez-keera opened this issue 2 years ago • 2 comments

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?

ivanperez-keera avatar Dec 28 '23 08:12 ivanperez-keera

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.

gbaz avatar Jan 06 '24 19:01 gbaz

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.

gbaz avatar Jan 06 '24 19:01 gbaz