elm-format icon indicating copy to clipboard operation
elm-format copied to clipboard

Generating a coverage report with hpc.

Open emmabastas opened this issue 2 years ago • 2 comments

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.

emmabastas avatar Jul 20 '21 01:07 emmabastas

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

razzeee avatar Jul 20 '21 06:07 razzeee

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

emmabastas avatar Jul 20 '21 19:07 emmabastas

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.

avh4 avatar Mar 15 '23 04:03 avh4