bazel-contrib / bazel-contrib/rules_scala

How to run code coverage only for Scala targets

Open
#910 7 comments 1 reaction 0 assignees View on GitHub
coverage
Dominant language
Starlark
Stars
384
Forks
292
Avg merge
3d 3m
Merged PRs (30d)
42

Description

I have a project with three targets (among others):

java_library(...)

scala_library(...)

scala_test(...)

Where the scala_library depends on the java_library and the scala_test depends on scala_library. If I run code coverage with this setup, if will execute that only for the java_library and scala code coverage won't be executed.

If I remove the java_library target, then everything works ok.

There is one solution I found: add "--instrumentation_filter=//*:scala_library" as a parameter when running coverage.
Is there any better way to fix this problem?

Contributor guide

Open the contributing guide

Research direction

Start with the reported three-target setup and the coverage invocation, including --instrumentation_filter=//*:scala_library. Check how coverage selects instrumentation when scala_library depends on java_library; done means Scala coverage runs while the Java target remains present, without relying on removing it.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
build-system, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.