aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java
diff options
context:
space:
mode:
authorGravatar elenairina <elenairina@google.com>2017-08-08 09:31:25 +0200
committerGravatar Marcel Hlopko <hlopko@google.com>2017-08-08 13:03:32 +0200
commit8adcf839c5c42defaa2fabedfb0208e4ce97ac95 (patch)
tree5ff5ef4e90aaf20917b1777d53ffdccb257c4c9b /src/test/java
parentf3e91b2d140011bcf53e44528b59f559766a20e4 (diff)
Change logic of Blaze Java coverage.
Change is needed due to the fact that java_import or other custom rules (genrules or Skylark) do not propagate coverage information. The lack of coverage data is caused by the fact that it is retrieved from compilation information and it is passed around through providers as Artifact(s) (also known as instrumentation metadata). The problem with the current implementation is that there is no way of retrieving instrumentation metadata from arbitrary jars provided by java_import or other custom rules. The instrumentation metadata in the current implementation is a separate jar that contains uninstrumented classes for offline Jacoco instrumentation. This change addresses that problem by having just one jar instead of 2 (the build jar and the instrumentation jar), adding the uninstrumented classes in the build jar and completely removing any other instrumentation metadata. Implementation details: * For each build jar there is a .txt file created that contains the relative path of each Java file. This file will also be included in the final build jar. It is used for recreating the correct path for each covered file when included in the coverage report. * java_binary/java_test will set 2 environment variables: 1) JACOCO_METADATA_JARS - replaces the previous JACOCO_METADATA_JAR that was a jar that merged all the uninstrumented classes on the classpath in one jar. The new environment variable holds the paths of the runtime classpath jars - only some of them contain uninstrumented classes, letting the Jacoco coverage runner to filter and analyze them. 2) JACOCO_MAIN_CLASS - The main class to be called for the current coverage run. Previously this information was embedded in the JACOCO_METADATA_JAR's manifest. PiperOrigin-RevId: 164562533
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/java/JavaSkylarkApiTest.java4
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/java/proto/SkylarkJavaLiteProtoLibraryTest.java1
2 files changed, 0 insertions, 5 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/java/JavaSkylarkApiTest.java b/src/test/java/com/google/devtools/build/lib/rules/java/JavaSkylarkApiTest.java
index d8387a182b..ce01943d9d 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/java/JavaSkylarkApiTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/java/JavaSkylarkApiTest.java
@@ -841,10 +841,6 @@ public class JavaSkylarkApiTest extends BuildViewTestCase {
args.getCompileTimeJars(), otherArgs.getCompileTimeJars())) {
return false;
}
- if (!nestedSetsOfArtifactHaveTheSameParent(
- args.getInstrumentationMetadata(), otherArgs.getInstrumentationMetadata())) {
- return false;
- }
if (!nestedSetsOfArtifactHaveTheSameParent(args.getRuntimeJars(), otherArgs.getRuntimeJars())) {
return false;
}
diff --git a/src/test/java/com/google/devtools/build/lib/rules/java/proto/SkylarkJavaLiteProtoLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/java/proto/SkylarkJavaLiteProtoLibraryTest.java
index be78678e13..ce347d5d0a 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/java/proto/SkylarkJavaLiteProtoLibraryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/java/proto/SkylarkJavaLiteProtoLibraryTest.java
@@ -297,7 +297,6 @@ public class SkylarkJavaLiteProtoLibraryTest extends BuildViewTestCase {
" srcs = ['input1.proto', 'input2.proto'])");
JavaCompilationArgs compilationArgs =
getProvider(JavaCompilationArgsProvider.class, rule).getJavaCompilationArgs();
- assertThat(compilationArgs.getInstrumentationMetadata()).isEmpty();
JavaSourceJarsProvider sourceJarsProvider = getProvider(JavaSourceJarsProvider.class, rule);
assertThat(sourceJarsProvider).isNotNull();