Skip to content

Commit

Permalink
toolchain which turns on coverage is part of API (#1020)
Browse files Browse the repository at this point in the history
  • Loading branch information
ittaiz authored Mar 7, 2020
1 parent 775b00a commit 0bb4bcb
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ to your command line, or to enable by default for building/testing add it to you
rules_scala supports coverage, but it's disabled by default. You need to enable it with an extra toolchain:

```
bazel coverage --extra_toolchains="@io_bazel_rules_scala//test/coverage:enable_code_coverage_aspect" //...
bazel coverage --extra_toolchains="@io_bazel_rules_scala//scala:code_coverage_toolchain" //...
```

It will produce several .dat files with results for your targets.
Expand All @@ -97,7 +97,7 @@ You can also add more options to receive a combined coverage report:

```
bazel coverage \
--extra_toolchains="@io_bazel_rules_scala//test/coverage:enable_code_coverage_aspect" \
--extra_toolchains="@io_bazel_rules_scala//scala:code_coverage_toolchain" \
--combined_report=lcov \
--coverage_report_generator="@bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Main" \
//...
Expand Down
4 changes: 2 additions & 2 deletions docs/coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
rules_scala supports coverage, but it's disabled by default. You need to enable it with an extra toolchain:

```
bazel coverage --extra_toolchains="@io_bazel_rules_scala//test/coverage:enable_code_coverage_aspect" //...
bazel coverage --extra_toolchains="@io_bazel_rules_scala//scala:code_coverage_toolchain" //...
```

It will produce several .dat files with results for your targets.
Expand All @@ -14,7 +14,7 @@ You can also add more options to receive a combined coverage report:

```
bazel coverage \
--extra_toolchains="@io_bazel_rules_scala//test/coverage:enable_code_coverage_aspect" \
--extra_toolchains="@io_bazel_rules_scala//scala:code_coverage_toolchain" \
--combined_report=lcov \
--coverage_report_generator="@bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Main" \
//...
Expand Down
13 changes: 13 additions & 0 deletions scala/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ toolchain(
visibility = ["//visibility:public"],
)

scala_toolchain(
name = "code_coverage_toolchain_impl",
enable_code_coverage_aspect = "on",
visibility = ["//visibility:public"],
)

toolchain(
name = "code_coverage_toolchain",
toolchain = "code_coverage_toolchain_impl",
toolchain_type = "@io_bazel_rules_scala//scala:toolchain_type",
visibility = ["//visibility:public"],
)

java_import(
name = "bazel_test_runner_deploy",
jars = ["@bazel_tools//tools/jdk:TestRunner_deploy.jar"],
Expand Down
13 changes: 0 additions & 13 deletions test/coverage/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,6 @@ load("@rules_java//java:defs.bzl", "java_library", "java_test")
load("//scala:scala.bzl", "scala_library", "scala_test")
load("//scala:scala_toolchain.bzl", "scala_toolchain")

scala_toolchain(
name = "enable_code_coverage_aspect_impl",
enable_code_coverage_aspect = "on",
visibility = ["//visibility:public"],
)

toolchain(
name = "enable_code_coverage_aspect",
toolchain = "enable_code_coverage_aspect_impl",
toolchain_type = "@io_bazel_rules_scala//scala:toolchain_type",
visibility = ["//visibility:public"],
)

scala_test(
name = "test-all",
srcs = [
Expand Down
2 changes: 1 addition & 1 deletion test/shell/test_misc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ test_override_javabin() {

test_coverage_on() {
bazel coverage \
--extra_toolchains="//test/coverage:enable_code_coverage_aspect" \
--extra_toolchains="//scala:code_coverage_toolchain" \
//test/coverage/...
diff test/coverage/expected-coverage.dat $(bazel info bazel-testlogs)/test/coverage/test-all/coverage.dat
}
Expand Down

0 comments on commit 0bb4bcb

Please sign in to comment.