commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
3.99k stars 845 forks source link

Pass options to HPC (like --xml-output) #4307

Open sir4ur0n opened 6 years ago

sir4ur0n commented 6 years ago

I could not find a way to pass options to HPC (as documented in https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/profiling.html#hpc-report).

The one I am particularly interested in is --xml-output to be able to parse coverage (and hopefully convert it into SonarQube-compatible code coverage later). I could not find an equivalent in stack, stack hpc or stack hpc report documentation/help.

mattaudesse commented 6 years ago

Hey @Sir4ur0n - thanks for reporting this. It seems like a reasonable feature request to me, and probably not terribly difficult to implement. Would you be interested in making a PR?

In the meantime I think you could probably adapt this to your needs:

stack exec -- hpc report --xml-output $(find $(stack path --local-hpc-root) -name \*.tix)
sir4ur0n commented 6 years ago

Thank you @mattaudesse for the tip, I still have struggle to make it work but I think it's more my lack of understanding of GHC code coverage. At least stack exec -- hpc report correctly offers all the HPC options, so I'm no longer blocked.

Keeping this issue open for when somebody (could be me 😄 ) is motivated to add this feature.

m4lvin commented 10 months ago

Another use case for this would be to enable the --decl-list option from https://downloads.haskell.org/ghc/latest/docs/users_guide/profiling.html#hpc-report

Also, I always get 0/0 100% when using the stack exec -- hpc report ... workaround from above :thinking: