# coverage-reports
An executable which reads Bazel `test.xml` test results generated by
`bazel coverage` for Rules_Haskell's `haskell_test` rule. These rules must have
`coverage_report_format` set to `"html"` to be compatible with this tool.
## Example Usage
If we have a target defined by the Rules_Haskell `haskell_test` rule, such as:
```
haskell_test(
name = "two-libs",
srcs = [
...
],
coverage_report_format = "html", # this must be set to "html" (not "text")
expected_covered_expressions_percentage = ...,
expected_uncovered_expression_count = ...,
deps = [
...
],
)
```
If we run `bazel coverage //path/to/package:two-libs`, the HTML report files
will be appended to the test log (visible with `--test_output=all` set, or by
looking in the `bazel-testlogs` directory at the relevant `test.xml` file).
Bazel test rules cannot generate output files, hence why we append the HTML
reports directly into the testlog.
Next, to extract the HTML reports and make them viewable in a browser, we use
this tool, the `bazel-coverage-report-renderer`. It's as simple as running:
```
bazel-coverage-report-renderer \
--testlog=<path/to/bazel-testlogs>/<path/to/package>two-libs/test.xml \
--destdir=path/to/destination/directory>
```
The tool will tell you where you can find the resulting files. The
`hpc_index.html` file is the homepage for your coverage results.