diff --git a/src/test/shell/bazel/bazel_coverage_java_test.sh b/src/test/shell/bazel/bazel_coverage_java_test.sh index 735b943271b3d2..31821708fd9e9c 100755 --- a/src/test/shell/bazel/bazel_coverage_java_test.sh +++ b/src/test/shell/bazel/bazel_coverage_java_test.sh @@ -118,6 +118,8 @@ function get_coverage_file_path_from_test_log() { function test_java_test_coverage() { cat < BUILD +load("@bazel_tools//tools/jdk:default_java_toolchain.bzl", "default_java_toolchain") + java_test( name = "test", srcs = glob(["src/test/**/*.java"]), @@ -129,6 +131,10 @@ java_library( name = "collatz-lib", srcs = glob(["src/main/**/*.java"]), ) + +default_java_toolchain( + name = "custom_toolchain" +) EOF mkdir -p src/main/com/example @@ -198,7 +204,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() {