commercialhaskell / commercialhaskell/stack

Support for coverage overlays

Open
#5,019 1 comment 1 reaction 0 assignees View on GitHub
component: coverage type: enhancement
Dominant language
Haskell
Stars
4.1k
Forks
850
Avg merge
10h 37m
Merged PRs (30d)
4

Description

[`hpc` overlays](https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/profiling.html#hpc-overlay-and-hpc-draft) are a means to adjust code coverage reports produced by the `hpc` tool. Overlays can be used (for example) to prevent derived instances of `Eq` or `Ord` from being marked as un-tested.

Currently, using `stack` with coverage overlays is quite cumbersome due to the additional package hash that `stack` appends. The problems are described in some detail in [this StackOverflow question](https://stackoverflow.com/questions/46481633/how-can-i-generate-a-coverage-overlay-with-hpc-and-stack).

To work-around these issues, I have used a very hacky build script which looks up the hash that `stack` appends to a package:
https://github.com/lancelet/raindrop/blob/f8597c4cb446095f5420f3d5f974b9773e751343/raindrop/coverage-build.sh#L15-L16
It then uses that hash to modify template coverage files so that they will work with `hpc`:
https://github.com/lancelet/raindrop/blob/f8597c4cb446095f5420f3d5f974b9773e751343/raindrop/coverage-overlay.txt
(Note the `{{PACKAGE_HASH}}`, which is substituted by the script.)

Needless to say, this is quite nasty, and has me questioning my use of both `hpc` and overlays in the first place. It would be great if Stack could maybe do one of the following:
- Provide an easy way to get the hash appended to a package from the CLI tool. Maybe this already exists and I just haven't come across it yet?
- Provide some form of in-built support for overlay files (both for `hpc draft` and `hpc overlay`). This strikes me as a lot more difficult, but extremely useful.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.