avh4 / elm-format

elm-format formats Elm source code according to a standard set of rules based on the official Elm Style Guide
BSD 3-Clause "New" or "Revised" License
1.31k stars 148 forks source link

Generating a coverage report with hpc. #745

Closed emmabastas closed 1 year ago

emmabastas commented 3 years ago

This issue is intended as a place to describe how I generate coverage reports for elm-format using hpc, for future reference.

Code commits in emmabastas/elm-format:coverage-report

The gist of it

ghc is instructed to compile with coverage tracking using the -fhpc compiler flag. This flag is appended to ghc-options in all five of the <package-name>.cabal files.

A new script, coverage-report.sh is run to generate a report in html. The script basically wraps a call to hpc markup with some additional options.

Other approaches

Cabal has support for adding coverage tracking via a config option. To add coverage tracking at the cabal level instead of compiler level might appear more natural for elm-format, but after failed attempts and reading haskell/cabal#3902 I came to the conclusion that elm-format's setup with multiple local cabal packages and integration tests probably falls outside the scope of cabals support for hpc.

razzeee commented 3 years ago

The issue link is broken should probably be https://github.com/haskell/cabal/issues/3902?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc

emmabastas commented 3 years ago

Coverage report for 57f77ee: https://emmabastas.github.io/elm-format/57f77ee/hpc_index.html

avh4 commented 1 year ago

Thanks! I followed your approach and added some build scripts in https://github.com/avh4/elm-format/pull/808. Now dev/build.sh serve:coverage will show the coverage report for the integration tests.