Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix coverage support when using default_java_toolchain. #12801

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/test/shell/bazel/bazel_coverage_java_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ function get_coverage_file_path_from_test_log() {

function test_java_test_coverage() {
cat <<EOF > BUILD
load("//tools/jdk:default_java_toolchain.bzl", "default_java_toolchain")
java_test(
name = "test",
srcs = glob(["src/test/**/*.java"]),
Expand All @@ -110,6 +112,10 @@ java_library(
name = "collatz-lib",
srcs = glob(["src/main/**/*.java"]),
)
default_java_toolchain(
name = "custom_toolchain"
)
EOF

mkdir -p src/main/com/example
Expand Down Expand Up @@ -179,7 +185,10 @@ LH:5
LF:6
end_of_record"

assert_coverage_result "$expected_result" "$coverage_file_path"
assert_coverage_result "$expected_result" "$coverage_file_path"

bazel coverage --test_output=all --java_toolchain=//:custom_toolchain //:test &>$TEST_log || fail "Coverage with default_java_toolchain for //:test failed"
assert_coverage_result "$expected_result" "$coverage_file_path"
}

function test_java_test_coverage_combined_report() {
Expand Down
2 changes: 1 addition & 1 deletion tools/jdk/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ remote_java_tools_java_import(
target = ":java_tools/JacocoCoverage_jarjar_deploy.jar",
)

remote_java_tools_java_import(
remote_java_tools_filegroup(
name = "JacocoCoverage",
target = ":java_tools/JacocoCoverage_jarjar_deploy.jar",
)
Expand Down
1 change: 1 addition & 0 deletions tools/jdk/default_java_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ DEFAULT_TOOLCHAIN_CONFIGURATION = {
"header_compiler_direct": ["@bazel_tools//tools/jdk:turbine_direct"],
"ijar": ["@bazel_tools//tools/jdk:ijar"],
"javabuilder": ["@bazel_tools//tools/jdk:javabuilder"],
"jacocorunner": "@bazel_tools//tools/jdk:JacocoCoverage",
"tools": [
"@bazel_tools//tools/jdk:javac_jar",
"@bazel_tools//tools/jdk:java_compiler_jar",
Expand Down