questions about adding support for coverage in scala rules and where to write coverage data to

125 views
Skip to first unread message

Doug Tangren

unread,
May 24, 2017, 11:51:36 PM5/24/17
to bazel-discuss
I'm currently working on adding support for coverage for the rules_scala repo as a pre-req for my company to fully switch over to bazel from sbt. 

A current blocker for me is figuring out where exactly to resolve the location for coverage reports and how to programmatically access that. It was brought up on their issue tracker ( https://github.com/bazelbuild/rules_scala/issues/184#issuecomment-303878290 ) that I may want to check in here for help.

I'm leveraging the existing work of https://github.com/scoverage/scalac-scoverage-plugin to instrument scala code, record measurements, then finally generate reports.

I'm currently using ctx.configuration.coverage_enabled which seems to only enabled with you swap `test` for `coverage`, to add the scalac plugin. It requires that I pass it a directory to write data to. I thought that I may declare an output and use that but its a little awkward because the output would be empty for regular test runs.

I'm looking for more patterns for what others are doing and more specifically if there is already a standard location to write coverage to for languages using skylark rules. Many thanks!

Damien Martin-Guillerez

unread,
May 24, 2017, 11:56:21 PM5/24/17
to Doug Tangren, bazel-discuss, Stephen Twigg
+twigg FYI

Unfortunately most of the team will be on holiday tomorrow and especially the people working on code coverage for java. Stephen in copy has expressed interest in adding that support too :)

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/47fe30ec-3366-464a-9cdb-63d875875c7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Doug Tangren

unread,
May 25, 2017, 12:00:49 AM5/25/17
to bazel-discuss, d.ta...@gmail.com, tw...@google.com

Doug Tangren

unread,
May 30, 2017, 2:17:52 PM5/30/17
to bazel-discuss, d.ta...@gmail.com, tw...@google.com


On Thursday, May 25, 2017 at 12:00:49 AM UTC-4, Doug Tangren wrote:


I'm trying to follow along with changes that were brought into 5.0 that may help me get code coverage working for scala. 

My current blocker is knowing where to write coverage data to. 

If I'm reading this right, https://github.com/bazelbuild/bazel/blob/1fd27bc4d97533031401c54aa05eb75b13c6874b/src/main/java/com/google/devtools/build/lib/rules/test/TestRunnerAction.java#L427-L435 should be the block of code that exposes set of COVERAGE_* environment variables to test runs. I can see that coverage is enabled by inspected ctx.configuration.coverage_enabled when I run bazel coverage and I believe that I'm setting the right `instrumented_files` field in the struct scala_library returns, but it's not immediately clear why coverage data may be null ( https://github.com/bazelbuild/bazel/blob/1fd27bc4d97533031401c54aa05eb75b13c6874b/src/main/java/com/google/devtools/build/lib/rules/test/TestRunnerAction.java#L559-L561 ) which may be why I'm not seeing those env variables with I run bazel coverage -s

If anyone here has time to take a quick look at what I have so far, below is our diff of rules_scala
Reply all
Reply to author
Forward
0 new messages