Commit fc4a8575 authored by Ben Joyce's avatar Ben Joyce Committed by Commit Bot

Run jacoco on host jar files.

Jacoco is not generating .exec files for junit targets. I traced the
root of the issue to the out/Debug/lib.java/base/base_java.jar
(and other host jars) not being run through jacoco.

Less redundant code would be to set the _previous_output_jar to the
results of the host_filter jar, but then that'd get run through
desugar, which was the reason for the changes in the first place (see
https://chromium-review.googlesource.com/c/chromium/src/+/2241865)

We were running on-the-fly code coverage with a javaagent sent as an
arg to the jvm, but that did not generate the desired coverage data
so we're going to use all offline.

Bug: 1097815
Change-Id: I0d9b4a48f921b743ee5179345fd6a81fa9437cc6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2291835
Commit-Queue: benjamin joyce <bjoyce@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789673}
parent 5664e5c1
......@@ -863,7 +863,6 @@ template("test_runner_script") {
executable_args += [
"--coverage-dir",
"@WrappedPath(${_rebased_coverage_dir})",
"--coverage-on-the-fly",
]
}
} else if (_test_type == "linker") {
......@@ -1840,7 +1839,14 @@ if (enable_java_templates) {
# Create the .jar in lib.java for use by java_binary.
if (defined(invoker.host_jar_path)) {
filter_jar("${target_name}_host") {
if (defined(invoker.jacoco_instrument) && invoker.jacoco_instrument) {
_filter_jar_target_name = "${target_name}_host__filter_jar"
_filter_jar_output_jar = "$target_out_dir/$target_name.host_filter.jar"
} else {
_filter_jar_target_name = "${target_name}_host"
_filter_jar_output_jar = invoker.host_jar_path
}
filter_jar(_filter_jar_target_name) {
forward_variables_from(invoker,
[
"jar_excluded_patterns",
......@@ -1849,7 +1855,7 @@ if (enable_java_templates) {
])
deps = _deps
input_jar = _previous_output_jar
output_jar = invoker.host_jar_path
output_jar = _filter_jar_output_jar
inputs = []
if (defined(strip_resource_classes) && strip_resource_classes) {
inputs += [ invoker.build_config ]
......@@ -1861,6 +1867,26 @@ if (enable_java_templates) {
deps += invoker.input_deps
}
}
if (defined(invoker.jacoco_instrument) && invoker.jacoco_instrument) {
# Jacoco must run after desugar (or else desugar sometimes fails).
# It must run after filtering to avoid the same (filtered) class mapping
# to multiple .jar files.
# We run offline code coverage processing here rather than with a
# javaagent as the desired coverage data was not being generated.
# See crbug.com/1097815.
jacoco_instr("${target_name}_host") {
deps = [ ":$_filter_jar_target_name" ] + invoker.jar_deps
forward_variables_from(invoker,
[
"java_files",
"java_sources_file",
])
input_jar_path = _filter_jar_output_jar
output_jar_path = invoker.host_jar_path
}
}
}
if (defined(invoker.device_jar_path)) {
......@@ -1904,7 +1930,8 @@ if (enable_java_templates) {
if (invoker.jacoco_instrument) {
_filter_jar_target_name = "${target_name}_device__filter_jar"
_filter_jar_output_jar = "$target_out_dir/$target_name.filter.jar"
_filter_jar_output_jar =
"$target_out_dir/$target_name.device_filter.jar"
} else {
_filter_jar_target_name = "${target_name}_device"
_filter_jar_output_jar = invoker.device_jar_path
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment