Pass only the top-level artifacts to `ExecutorLifecycleListener` and make the computation more efficient.
Delete the now unused `ArtifactsToOwnerLabels`.
PiperOrigin-RevId: 372152937
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/ArtifactsToOwnerLabelsTest.java b/src/test/java/com/google/devtools/build/lib/analysis/ArtifactsToOwnerLabelsTest.java
deleted file mode 100644
index 6f3bebc..0000000
--- a/src/test/java/com/google/devtools/build/lib/analysis/ArtifactsToOwnerLabelsTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-// 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.devtools.build.lib.actions.Artifact;
-import com.google.devtools.build.lib.cmdline.Label;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-import org.mockito.Mockito;
-
-/** Tests for {@link ArtifactsToOwnerLabels}. */
-@RunWith(JUnit4.class)
-public class ArtifactsToOwnerLabelsTest {
- @Test
- public void smoke() {
- Artifact label1Artifact = Mockito.mock(Artifact.class);
- Label label1 = Label.parseAbsoluteUnchecked("//label:one");
- Mockito.when(label1Artifact.getOwnerLabel()).thenReturn(label1);
- ArtifactsToOwnerLabels underTest =
- new ArtifactsToOwnerLabels.Builder().addArtifact(label1Artifact).build();
- assertThat(underTest.getOwners(label1Artifact)).containsExactly(label1);
- underTest = new ArtifactsToOwnerLabels.Builder().addArtifact(label1Artifact, label1).build();
- assertThat(underTest.getOwners(label1Artifact)).containsExactly(label1);
- underTest =
- new ArtifactsToOwnerLabels.Builder()
- .addArtifact(label1Artifact)
- .addArtifact(label1Artifact, label1)
- .build();
- assertThat(underTest.getOwners(label1Artifact)).containsExactly(label1);
- underTest =
- new ArtifactsToOwnerLabels.Builder()
- .addArtifact(label1Artifact, label1)
- .addArtifact(label1Artifact)
- .build();
- assertThat(underTest.getOwners(label1Artifact)).containsExactly(label1);
- Label label2 = Label.parseAbsoluteUnchecked("//label:two");
- underTest =
- new ArtifactsToOwnerLabels.Builder()
- .addArtifact(label1Artifact, label2)
- .addArtifact(label1Artifact)
- .build();
- assertThat(underTest.getOwners(label1Artifact)).containsExactly(label1, label2);
- underTest =
- new ArtifactsToOwnerLabels.Builder()
- .addArtifact(label1Artifact)
- .addArtifact(label1Artifact, label2)
- .build();
- assertThat(underTest.getOwners(label1Artifact)).containsExactly(label1, label2);
- }
-}
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/AspectTest.java b/src/test/java/com/google/devtools/build/lib/analysis/AspectTest.java
index deaf363..a1f9d2a 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/AspectTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/AspectTest.java
@@ -64,7 +64,7 @@
public class AspectTest extends AnalysisTestCase {
private void pkg(String name, String... contents) throws Exception {
- scratch.file("" + name + "/BUILD", contents);
+ scratch.file(name + "/BUILD", contents);
}
@Test
@@ -628,7 +628,7 @@
// Get owners of all extra-action artifacts.
List<Label> extraArtifactOwners = new ArrayList<>();
- for (Artifact artifact : analysisResult.getTopLevelArtifactsToOwnerLabels().getArtifacts()) {
+ for (Artifact artifact : analysisResult.getArtifactsToBuild()) {
if (artifact.getRootRelativePathString().endsWith(".xa")) {
extraArtifactOwners.add(artifact.getOwnerLabel());
}
@@ -642,7 +642,7 @@
// Get owners of all extra-action artifacts.
List<Label> extraArtifactOwners = new ArrayList<>();
- for (Artifact artifact : analysisResult.getTopLevelArtifactsToOwnerLabels().getArtifacts()) {
+ for (Artifact artifact : analysisResult.getArtifactsToBuild()) {
if (artifact.getRootRelativePathString().endsWith(".xa")) {
extraArtifactOwners.add(artifact.getOwnerLabel());
}
@@ -841,9 +841,7 @@
@Test
public void aspectApplyingToFiles() throws Exception {
AspectApplyingToFiles aspectApplyingToFiles = new AspectApplyingToFiles();
- setRulesAndAspectsAvailableInTests(
- ImmutableList.<NativeAspectClass>of(aspectApplyingToFiles),
- ImmutableList.<RuleDefinition>of());
+ setRulesAndAspectsAvailableInTests(ImmutableList.of(aspectApplyingToFiles), ImmutableList.of());
pkg(
"a",
"java_binary(name = 'x', main_class = 'x.FooBar', srcs = ['x.java'])"
@@ -861,9 +859,7 @@
@Test
public void aspectApplyingToSourceFilesIgnored() throws Exception {
AspectApplyingToFiles aspectApplyingToFiles = new AspectApplyingToFiles();
- setRulesAndAspectsAvailableInTests(
- ImmutableList.<NativeAspectClass>of(aspectApplyingToFiles),
- ImmutableList.<RuleDefinition>of());
+ setRulesAndAspectsAvailableInTests(ImmutableList.of(aspectApplyingToFiles), ImmutableList.of());
pkg(
"a",
"java_binary(name = 'x', main_class = 'x.FooBar', srcs = ['x.java'])"
@@ -879,9 +875,7 @@
@Test
public void duplicateAspectsDeduped() throws Exception {
AspectApplyingToFiles aspectApplyingToFiles = new AspectApplyingToFiles();
- setRulesAndAspectsAvailableInTests(
- ImmutableList.<NativeAspectClass>of(aspectApplyingToFiles),
- ImmutableList.<RuleDefinition>of());
+ setRulesAndAspectsAvailableInTests(ImmutableList.of(aspectApplyingToFiles), ImmutableList.of());
pkg("a", "java_binary(name = 'x', main_class = 'x.FooBar', srcs = ['x.java'])");
AnalysisResult analysisResult =
update(
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/BUILD b/src/test/java/com/google/devtools/build/lib/analysis/BUILD
index b287c02..1bfe049 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/BUILD
+++ b/src/test/java/com/google/devtools/build/lib/analysis/BUILD
@@ -55,7 +55,6 @@
"//src/main/java/com/google/devtools/build/lib/analysis:actions/template",
"//src/main/java/com/google/devtools/build/lib/analysis:actions/template_expansion_action",
"//src/main/java/com/google/devtools/build/lib/analysis:analysis_cluster",
- "//src/main/java/com/google/devtools/build/lib/analysis:artifacts_to_owner_labels",
"//src/main/java/com/google/devtools/build/lib/analysis:aspect_aware_attribute_mapper",
"//src/main/java/com/google/devtools/build/lib/analysis:aspect_collection",
"//src/main/java/com/google/devtools/build/lib/analysis:blaze_directories",
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java b/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java
index 77bd10bd..3692817 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java
@@ -1300,7 +1300,7 @@
AnalysisResult analysisResult = update("//x:a");
List<String> owners = new ArrayList<>();
- for (Artifact artifact : analysisResult.getTopLevelArtifactsToOwnerLabels().getArtifacts()) {
+ for (Artifact artifact : analysisResult.getArtifactsToBuild()) {
if ("xa".equals(artifact.getExtension())) {
owners.add(artifact.getOwnerLabel().toString());
}