aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar ulfjack <ulfjack@google.com>2018-07-23 01:19:20 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-07-23 01:20:29 -0700
commitf000996d0c12c1e239cce200c2792f226adcb89b (patch)
tree22f55535a9ad659ef48f6e8bedb1d2680a21b989 /src/test/java/com/google/devtools/build
parent17b217c0110e9bbc2145de563ab0d599c6339890 (diff)
Fix TargetCompleteEvent.referencedLocalFiles
It was missing the baseline coverage files, if any. This is safe even if unknown commit is rolled back. PiperOrigin-RevId: 205626149
Diffstat (limited to 'src/test/java/com/google/devtools/build')
-rw-r--r--src/test/java/com/google/devtools/build/lib/BUILD1
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/TargetCompleteEventTest.java62
2 files changed, 63 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/BUILD b/src/test/java/com/google/devtools/build/lib/BUILD
index b1571ea6dd..e782ac7ae7 100644
--- a/src/test/java/com/google/devtools/build/lib/BUILD
+++ b/src/test/java/com/google/devtools/build/lib/BUILD
@@ -802,6 +802,7 @@ java_test(
"//src/main/java/com/google/devtools/build/lib:skylarkinterface",
"//src/main/java/com/google/devtools/build/lib:util",
"//src/main/java/com/google/devtools/build/lib/actions",
+ "//src/main/java/com/google/devtools/build/lib/buildeventstream",
"//src/main/java/com/google/devtools/build/lib/buildeventstream/proto:build_event_stream_java_proto",
"//src/main/java/com/google/devtools/build/lib/causes",
"//src/main/java/com/google/devtools/build/lib/collect",
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/TargetCompleteEventTest.java b/src/test/java/com/google/devtools/build/lib/analysis/TargetCompleteEventTest.java
new file mode 100644
index 0000000000..4d164143d2
--- /dev/null
+++ b/src/test/java/com/google/devtools/build/lib/analysis/TargetCompleteEventTest.java
@@ -0,0 +1,62 @@
+// Copyright 2018 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.devtools.build.lib.analysis;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import com.google.common.collect.Iterables;
+import com.google.devtools.build.lib.analysis.TopLevelArtifactHelper.ArtifactsToBuild;
+import com.google.devtools.build.lib.analysis.util.AnalysisTestCase;
+import com.google.devtools.build.lib.buildeventstream.BuildEvent;
+import com.google.devtools.build.lib.buildeventstream.BuildEvent.LocalFile.LocalFileType;
+import com.google.devtools.build.lib.cmdline.RepositoryName;
+import com.google.devtools.build.lib.skyframe.ConfiguredTargetAndData;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/** Tests for {@link TargetCompleteEvent}. */
+@RunWith(JUnit4.class)
+public class TargetCompleteEventTest extends AnalysisTestCase {
+ /** Regression test for b/111653523. */
+ @Test
+ public void testReferencedLocalFilesIncludesBaselineCoverage() throws Exception {
+ scratch.file("java/a/BUILD",
+ "java_test(name = 'Example', srcs = ['Example.java'])");
+ useConfiguration("--collect_code_coverage");
+ AnalysisResult result = update("//java/a:Example");
+ ConfiguredTarget ct = Iterables.getOnlyElement(result.getTargetsToBuild());
+ TargetAndConfiguration tac = Iterables.getOnlyElement(result.getTopLevelTargetsWithConfigs());
+ ConfiguredTargetAndData ctAndData =
+ new ConfiguredTargetAndData(ct, tac.getTarget(), tac.getConfiguration());
+ TopLevelArtifactContext context =
+ new TopLevelArtifactContext(false, OutputGroupInfo.DEFAULT_GROUPS);
+ ArtifactsToBuild artifactsToBuild =
+ TopLevelArtifactHelper.getAllArtifactsToBuild(ct, context);
+ TargetCompleteEvent event =
+ TargetCompleteEvent.successfulBuild(
+ ctAndData, artifactsToBuild.getAllArtifactsByOutputGroup());
+ assertThat(event.referencedLocalFiles())
+ .contains(
+ new BuildEvent.LocalFile(
+ tac
+ .getConfiguration()
+ .getTestLogsDirectory(RepositoryName.DEFAULT)
+ .getRoot()
+ .asPath()
+ .getRelative("java/a/Example/baseline_coverage.dat"),
+ LocalFileType.OUTPUT));
+ }
+}