Update tests to work with NestedSet not Iterable (part 1)
PiperOrigin-RevId: 289613917
diff --git a/src/main/java/com/google/devtools/build/lib/actions/Artifact.java b/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
index 064a4df..a455087 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
@@ -31,6 +31,7 @@
import com.google.devtools.build.lib.actions.ArtifactResolver.ArtifactResolverSupplier;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.LabelConstants;
+import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.concurrent.BlazeInterners;
import com.google.devtools.build.lib.concurrent.ThreadSafety;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
@@ -963,6 +964,14 @@
* Lazily converts artifacts into root-relative path strings. Middleman artifacts are ignored by
* this method.
*/
+ public static Iterable<String> toRootRelativePaths(NestedSet<Artifact> artifacts) {
+ return toRootRelativePaths(artifacts.toList());
+ }
+
+ /**
+ * Lazily converts artifacts into root-relative path strings. Middleman artifacts are ignored by
+ * this method.
+ */
public static Iterable<String> toRootRelativePaths(Iterable<Artifact> artifacts) {
return Iterables.transform(
Iterables.filter(artifacts, MIDDLEMAN_FILTER),
@@ -978,6 +987,17 @@
}
/**
+ * Converts a collection of artifacts into execution-time path strings, and returns those as an
+ * immutable list. Middleman artifacts are ignored by this method.
+ *
+ * <p>Avoid this method in production code - it flattens the given nested set unconditionally.
+ */
+ @VisibleForTesting
+ public static List<String> asExecPaths(NestedSet<Artifact> artifacts) {
+ return asExecPaths(artifacts.toList());
+ }
+
+ /**
* Converts a collection of artifacts into execution-time path strings, and
* returns those as an immutable list. Middleman artifacts are ignored by this method.
*/
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/LibraryToLink.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/LibraryToLink.java
index 12929ab..790ba5b 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/LibraryToLink.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/LibraryToLink.java
@@ -21,6 +21,7 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.actions.Artifact;
+import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.skylarkbuildapi.cpp.LibraryToLinkApi;
import com.google.devtools.build.lib.syntax.Printer;
@@ -268,9 +269,9 @@
return dynamicLibrariesForRuntimeBuilder.build();
}
- public static List<Artifact> getDynamicLibrariesForLinking(Iterable<LibraryToLink> libraries) {
+ public static List<Artifact> getDynamicLibrariesForLinking(NestedSet<LibraryToLink> libraries) {
ImmutableList.Builder<Artifact> dynamicLibrariesForLinkingBuilder = ImmutableList.builder();
- for (LibraryToLink libraryToLink : libraries) {
+ for (LibraryToLink libraryToLink : libraries.toList()) {
if (libraryToLink.getInterfaceLibrary() != null) {
dynamicLibrariesForLinkingBuilder.add(libraryToLink.getInterfaceLibrary());
} else if (libraryToLink.getDynamicLibrary() != null) {
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaBinary.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaBinary.java
index 7272551..eb97004 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaBinary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaBinary.java
@@ -585,7 +585,7 @@
Iterable<? extends TransitiveInfoCollection> deps) {
NestedSet<LibraryToLink> linkerInputs =
new NativeLibraryNestedSetBuilder().addJavaTargets(deps).build();
- return LibraryToLink.getDynamicLibrariesForLinking(linkerInputs.toList());
+ return LibraryToLink.getDynamicLibrariesForLinking(linkerInputs);
}
private static boolean isJavaTestRule(RuleContext ruleContext) {
diff --git a/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java b/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java
index f209e37..e6bcea2 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java
@@ -64,6 +64,7 @@
import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.RepositoryName;
+import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.collect.nestedset.Order;
import com.google.devtools.build.lib.events.EventHandler;
@@ -412,6 +413,14 @@
}
/**
+ * For a bunch of actions, gets the basenames of the paths and accumulates them in a space
+ * separated string, like <code>foo.o bar.o baz.a</code>.
+ */
+ public static String baseNamesOf(NestedSet<Artifact> artifacts) {
+ return baseNamesOf(artifacts.toList());
+ }
+
+ /**
* For a bunch of actions, gets the basenames of the paths and accumulates
* them in a space separated string, like <code>foo.o bar.o baz.a</code>.
*/
@@ -421,6 +430,14 @@
}
/**
+ * For a bunch of actions, gets the basenames of the paths, sorts them in alphabetical order and
+ * accumulates them in a space separated string, for example <code>bar.o baz.a foo.o</code>.
+ */
+ public static String sortedBaseNamesOf(NestedSet<Artifact> artifacts) {
+ return sortedBaseNamesOf(artifacts.toList());
+ }
+
+ /**
* For a bunch of actions, gets the basenames of the paths, sorts them in alphabetical
* order and accumulates them in a space separated string, for example
* <code>bar.o baz.a foo.o</code>.
@@ -431,18 +448,22 @@
return Joiner.on(' ').join(baseNames);
}
- /**
- * For a bunch of artifacts, gets the basenames and accumulates them in a
- * List.
- */
+ /** For a bunch of artifacts, gets the basenames and accumulates them in a List. */
+ public static List<String> baseArtifactNames(NestedSet<Artifact> artifacts) {
+ return transform(artifacts.toList(), artifact -> artifact.getExecPath().getBaseName());
+ }
+
+ /** For a bunch of artifacts, gets the basenames and accumulates them in a List. */
public static List<String> baseArtifactNames(Iterable<Artifact> artifacts) {
return transform(artifacts, artifact -> artifact.getExecPath().getBaseName());
}
- /**
- * For a bunch of artifacts, gets the exec paths and accumulates them in a
- * List.
- */
+ /** For a bunch of artifacts, gets the exec paths and accumulates them in a List. */
+ public static List<String> execPaths(NestedSet<Artifact> artifacts) {
+ return execPaths(artifacts.toList());
+ }
+
+ /** For a bunch of artifacts, gets the exec paths and accumulates them in a List. */
public static List<String> execPaths(Iterable<Artifact> artifacts) {
return transform(artifacts, Artifact::getExecPathString);
}
@@ -451,6 +472,14 @@
* For a bunch of artifacts, gets the pretty printed names and accumulates them in a List. Note
* that this returns the root-relative paths, not the exec paths.
*/
+ public static List<String> prettyArtifactNames(NestedSet<Artifact> artifacts) {
+ return prettyArtifactNames(artifacts.toList());
+ }
+
+ /**
+ * For a bunch of artifacts, gets the pretty printed names and accumulates them in a List. Note
+ * that this returns the root-relative paths, not the exec paths.
+ */
public static List<String> prettyArtifactNames(Iterable<Artifact> artifacts) {
return transform(artifacts, Artifact::prettyPrint);
}
@@ -474,6 +503,14 @@
* Returns the closure of the predecessors of any of the given types, joining the basenames of the
* artifacts into a space-separated string like "libfoo.a libbar.a libbaz.a".
*/
+ public String predecessorClosureOf(NestedSet<Artifact> artifacts, FileType... types) {
+ return predecessorClosureOf(artifacts.toList(), types);
+ }
+
+ /**
+ * Returns the closure of the predecessors of any of the given types, joining the basenames of the
+ * artifacts into a space-separated string like "libfoo.a libbar.a libbaz.a".
+ */
public String predecessorClosureOf(Iterable<Artifact> artifacts, FileType... types) {
Set<Artifact> visited = artifactClosureOf(artifacts);
return baseNamesOf(FileType.filter(visited, types));
@@ -486,6 +523,12 @@
/** Returns the closure of the predecessors of any of the given types. */
public Collection<String> predecessorClosureAsCollection(
+ NestedSet<Artifact> artifacts, FileType... types) {
+ return predecessorClosureAsCollection(artifacts.toList(), types);
+ }
+
+ /** Returns the closure of the predecessors of any of the given types. */
+ public Collection<String> predecessorClosureAsCollection(
Iterable<Artifact> artifacts, FileType... types) {
return baseArtifactNames(FileType.filter(artifactClosureOf(artifacts), types));
}
@@ -504,7 +547,7 @@
* Returns the closure over the input files of an action.
*/
public Set<Artifact> inputClosureOf(ActionAnalysisMetadata action) {
- return artifactClosureOf(action.getInputs());
+ return artifactClosureOf(action.getInputs().toList());
}
/** Returns the closure over the input files of an artifact. */
@@ -513,6 +556,11 @@
}
/** Returns the closure over the input files of a set of artifacts. */
+ public Set<Artifact> artifactClosureOf(NestedSet<Artifact> artifacts) {
+ return artifactClosureOf(artifacts.toList());
+ }
+
+ /** Returns the closure over the input files of a set of artifacts. */
public Set<Artifact> artifactClosureOf(Iterable<Artifact> artifacts) {
Set<Artifact> visited = new LinkedHashSet<>();
List<Artifact> toVisit = Lists.newArrayList(artifacts);
@@ -523,7 +571,7 @@
}
ActionAnalysisMetadata generatingAction = actionGraph.getGeneratingAction(current);
if (generatingAction != null) {
- Iterables.addAll(toVisit, generatingAction.getInputs());
+ toVisit.addAll(generatingAction.getInputs().toList());
}
}
return visited;
@@ -569,7 +617,8 @@
}
ActionAnalysisMetadata generatingAction = actionGraph.getGeneratingAction(current);
if (generatingAction != null) {
- Iterables.addAll(toVisit, Iterables.filter(generatingAction.getInputs(), allowedArtifacts));
+ Iterables.addAll(
+ toVisit, Iterables.filter(generatingAction.getInputs().toList(), allowedArtifacts));
if (actionClass.isInstance(generatingAction)) {
actions.add(actionClass.cast(generatingAction));
}
@@ -587,8 +636,15 @@
* Looks in the given artifacts Iterable for the first Artifact whose path ends with the given
* suffix and returns its generating Action.
*/
- public Action getActionForArtifactEndingWith(
- Iterable<Artifact> artifacts, String suffix) {
+ public Action getActionForArtifactEndingWith(NestedSet<Artifact> artifacts, String suffix) {
+ return getActionForArtifactEndingWith(artifacts.toList(), suffix);
+ }
+
+ /**
+ * Looks in the given artifacts Iterable for the first Artifact whose path ends with the given
+ * suffix and returns its generating Action.
+ */
+ public Action getActionForArtifactEndingWith(Iterable<Artifact> artifacts, String suffix) {
Artifact a = getFirstArtifactEndingWith(artifacts, suffix);
if (a == null) {
@@ -612,6 +668,15 @@
* suffix and returns the Artifact.
*/
public static Artifact getFirstArtifactEndingWith(
+ NestedSet<? extends Artifact> artifacts, String suffix) {
+ return getFirstArtifactEndingWith(artifacts.toList(), suffix);
+ }
+
+ /**
+ * Looks in the given artifacts Iterable for the first Artifact whose path ends with the given
+ * suffix and returns the Artifact.
+ */
+ public static Artifact getFirstArtifactEndingWith(
Iterable<? extends Artifact> artifacts, String suffix) {
for (Artifact a : artifacts) {
if (a.getExecPath().getPathString().endsWith(suffix)) {
@@ -641,7 +706,7 @@
* specified basename. An assertion error is raised if none is found.
*/
public static Artifact getInput(ActionAnalysisMetadata action, String basename) {
- for (Artifact artifact : action.getInputs()) {
+ for (Artifact artifact : action.getInputs().toList()) {
if (artifact.getExecPath().getBaseName().equals(basename)) {
return artifact;
}
diff --git a/src/test/java/com/google/devtools/build/lib/actions/util/TestAction.java b/src/test/java/com/google/devtools/build/lib/actions/util/TestAction.java
index 8b8f9be..afaeeb3 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/util/TestAction.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/util/TestAction.java
@@ -54,12 +54,13 @@
return artifact.getExecPath().getBaseName().endsWith(".optional");
}
- private static NestedSet<Artifact> mandatoryArtifacts(Iterable<Artifact> inputs) {
- return NestedSetBuilder.wrap(Order.STABLE_ORDER, Iterables.filter(inputs, a -> !isOptional(a)));
+ private static NestedSet<Artifact> mandatoryArtifacts(NestedSet<Artifact> inputs) {
+ return NestedSetBuilder.wrap(
+ Order.STABLE_ORDER, Iterables.filter(inputs.toList(), a -> !isOptional(a)));
}
- private static ImmutableList<Artifact> optionalArtifacts(Iterable<Artifact> inputs) {
- return ImmutableList.copyOf(Iterables.filter(inputs, a -> isOptional(a)));
+ private static ImmutableList<Artifact> optionalArtifacts(NestedSet<Artifact> inputs) {
+ return ImmutableList.copyOf(Iterables.filter(inputs.toList(), a -> isOptional(a)));
}
protected final Callable<Void> effect;
@@ -78,7 +79,7 @@
public TestAction(
Callable<Void> effect, NestedSet<Artifact> inputs, ImmutableSet<Artifact> outputs) {
super(NULL_ACTION_OWNER, mandatoryArtifacts(inputs), outputs);
- this.mandatoryInputs = (NestedSet<Artifact>) getInputs();
+ this.mandatoryInputs = getInputs();
this.optionalInputs = optionalArtifacts(inputs);
this.effect = effect;
}
@@ -110,7 +111,7 @@
@Override
public ActionResult execute(ActionExecutionContext actionExecutionContext)
throws ActionExecutionException {
- for (Artifact artifact : getInputs()) {
+ for (Artifact artifact : getInputs().toList()) {
// Do not check *.optional artifacts - artifacts with such extension are
// used by tests to specify artifacts that may or may not be missing.
// This is used, e.g., to test Blaze behavior when action has missing
@@ -144,7 +145,7 @@
@Override
protected void computeKey(ActionKeyContext actionKeyContext, Fingerprint fp) {
fp.addPaths(Artifact.asSortedPathFragments(getOutputs()));
- fp.addPaths(Artifact.asSortedPathFragments(getMandatoryInputs()));
+ fp.addPaths(Artifact.asSortedPathFragments(getMandatoryInputs().toList()));
}
@Override
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/AnalysisFailureReportingTest.java b/src/test/java/com/google/devtools/build/lib/analysis/AnalysisFailureReportingTest.java
index 0a55791..b6d0242 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/AnalysisFailureReportingTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/AnalysisFailureReportingTest.java
@@ -203,7 +203,7 @@
@Subscribe
public void failureEvent(AnalysisFailureEvent event) {
- events.putAll(event.getFailedTarget().getLabel(), event.getRootCauses());
+ events.putAll(event.getFailedTarget().getLabel(), event.getRootCauses().toList());
}
}
}
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 7f2cea6..c220b33 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
@@ -77,7 +77,7 @@
"alias(name='b', actual=select({'//conditions:default': ':c'}))",
"base(name='c')");
ConfiguredTarget a = getConfiguredTarget("//a:a");
- assertThat(a.getProvider(RuleInfo.class).getData())
+ assertThat(a.getProvider(RuleInfo.class).getData().toList())
.containsExactly("aspect //a:c", "rule //a:a");
}
@@ -92,7 +92,7 @@
"base(name='e')");
ConfiguredTarget a = getConfiguredTarget("//a:a");
- assertThat(a.getProvider(RuleInfo.class).getData())
+ assertThat(a.getProvider(RuleInfo.class).getData().toList())
.containsExactly("aspect //a:e", "rule //a:a");
}
@@ -105,7 +105,7 @@
"alias(name='c', actual=select({'//conditions:default': ':d'}))",
"base(name='d')");
ConfiguredTarget a = getConfiguredTarget("//a:a");
- assertThat(a.getProvider(RuleInfo.class).getData())
+ assertThat(a.getProvider(RuleInfo.class).getData().toList())
.containsExactly("aspect //a:d", "rule //a:a");
}
@@ -117,7 +117,7 @@
"aspect(name='b', foo=[])");
ConfiguredTarget a = getConfiguredTarget("//a:a");
- assertThat(a.getProvider(RuleInfo.class).getData())
+ assertThat(a.getProvider(RuleInfo.class).getData().toList())
.containsExactly("aspect //a:b", "rule //a:a");
}
@@ -131,7 +131,7 @@
"liar(name='b', foo=[])");
ConfiguredTarget a = getConfiguredTarget("//a:a");
- assertThat(a.getProvider(RuleInfo.class).getData()).containsExactly("rule //a:a");
+ assertThat(a.getProvider(RuleInfo.class).getData().toList()).containsExactly("rule //a:a");
}
@Test
@@ -145,7 +145,7 @@
"liar(name='b', foo=[])");
ConfiguredTarget a = getConfiguredTarget("//a:a");
- assertThat(a.getProvider(RuleInfo.class).getData()).containsExactly("rule //a:a");
+ assertThat(a.getProvider(RuleInfo.class).getData().toList()).containsExactly("rule //a:a");
}
@Test
@@ -161,7 +161,7 @@
);
ConfiguredTarget a = getConfiguredTarget("//a:a");
- assertThat(a.getProvider(RuleInfo.class).getData()).containsExactly("rule //a:a");
+ assertThat(a.getProvider(RuleInfo.class).getData().toList()).containsExactly("rule //a:a");
}
@Test
@@ -175,8 +175,8 @@
"honest(name='b', foo=[])");
ConfiguredTarget a = getConfiguredTarget("//a:a");
- assertThat(a.getProvider(RuleInfo.class).getData()).containsExactly(
- "rule //a:a", "aspect //a:b");
+ assertThat(a.getProvider(RuleInfo.class).getData().toList())
+ .containsExactly("rule //a:a", "aspect //a:b");
}
@Test
@@ -192,8 +192,8 @@
);
ConfiguredTarget a = getConfiguredTarget("//a:a");
- assertThat(a.getProvider(RuleInfo.class).getData()).containsExactly(
- "rule //a:a", "aspect //a:b", "aspect //a:c");
+ assertThat(a.getProvider(RuleInfo.class).getData().toList())
+ .containsExactly("rule //a:a", "aspect //a:b", "aspect //a:c");
}
@@ -222,7 +222,7 @@
reporter, ModifiedFileSet.EVERYTHING_MODIFIED, Root.fromPath(rootDirectory));
ConfiguredTarget a = getConfiguredTarget("//a:a");
- assertThat(a.getProvider(RuleInfo.class).getData())
+ assertThat(a.getProvider(RuleInfo.class).getData().toList())
.containsExactly("rule //a:a", "aspect //a:b");
}
@@ -237,7 +237,7 @@
"honest(name='b', foo=[])");
ConfiguredTarget a = getConfiguredTarget("//a:a");
- assertThat(a.getProvider(RuleInfo.class).getData())
+ assertThat(a.getProvider(RuleInfo.class).getData().toList())
.containsExactly("rule //a:a", "aspect //a:b");
}
@@ -252,7 +252,7 @@
"honest2(name='c', foo=[])");
ConfiguredTarget a = getConfiguredTarget("//a:a");
- assertThat(a.getProvider(RuleInfo.class).getData())
+ assertThat(a.getProvider(RuleInfo.class).getData().toList())
.containsExactly("rule //a:a", "aspect //a:b", "aspect //a:c");
}
@@ -271,7 +271,7 @@
"honest(name='b', foo=[':c'])");
ConfiguredTarget a = getConfiguredTarget("//a:a");
- assertThat(a.getProvider(TestAspects.RuleInfo.class).getData())
+ assertThat(a.getProvider(TestAspects.RuleInfo.class).getData().toList())
.containsExactly(
"rule //a:a",
"aspect //a:b data //a:q $dep:[ //a:q]",
@@ -366,7 +366,7 @@
"aspect(name='b', foo=[])");
ConfiguredTarget a = getConfiguredTarget("//a:a");
- assertThat(a.getProvider(RuleInfo.class).getData())
+ assertThat(a.getProvider(RuleInfo.class).getData().toList())
.containsExactly("aspect //a:b", "rule //a:a");
}
@@ -379,7 +379,7 @@
"simple(name='b')");
ConfiguredTarget a = getConfiguredTarget("//a:a");
- assertThat(a.getProvider(RuleInfo.class).getData()).containsExactly("foo", "bar");
+ assertThat(a.getProvider(RuleInfo.class).getData().toList()).containsExactly("foo", "bar");
}
@Test
@@ -391,7 +391,7 @@
"honest(name='b', foo=[])");
ConfiguredTarget a = getConfiguredTarget("//a:a");
- assertThat(a.getProvider(RuleInfo.class).getData())
+ assertThat(a.getProvider(RuleInfo.class).getData().toList())
.containsExactly("rule //a:a", "aspect //a:b data hello");
}
@@ -462,7 +462,7 @@
"testrule(name='a', foo=[':b'])",
"testrule(name='b')");
ConfiguredTarget a = getConfiguredTarget("//a:a");
- assertThat(a.getProvider(RuleInfo.class).getData()).contains("empty");
+ assertThat(a.getProvider(RuleInfo.class).getData().toList()).contains("empty");
}
/**
@@ -538,7 +538,7 @@
ConfiguredTarget a = getConfiguredTarget("//a:a");
NestedSet<Artifact.DerivedArtifact> extraActionArtifacts =
a.getProvider(ExtraActionArtifactsProvider.class).getTransitiveExtraActionArtifacts();
- for (Artifact artifact : extraActionArtifacts) {
+ for (Artifact artifact : extraActionArtifacts.toList()) {
assertThat(artifact.getOwnerLabel()).isEqualTo(Label.create("@//a", "b"));
}
}
@@ -554,8 +554,8 @@
"all_attributes_aspect(name='x', foo=[':a'])");
ConfiguredTarget a = getConfiguredTarget("//a:x");
- assertThat(a.getProvider(RuleInfo.class).getData())
- .containsExactly("aspect //a:a", "aspect //a:b", "aspect //a:c", "rule //a:x");
+ assertThat(a.getProvider(RuleInfo.class).getData().toList())
+ .containsExactly("aspect //a:a", "aspect //a:b", "aspect //a:c", "rule //a:x");
}
/**
@@ -727,13 +727,9 @@
update();
ConfiguredTarget a = getConfiguredTarget("//a:x");
- assertThat(a.getProvider(RuleInfo.class).getData())
+ assertThat(a.getProvider(RuleInfo.class).getData().toList())
.containsExactly(
- "aspect //a:a",
- "aspect //a:b",
- "aspect //a:c",
- "aspect //extra:extra",
- "rule //a:x");
+ "aspect //a:a", "aspect //a:b", "aspect //a:c", "aspect //extra:extra", "rule //a:x");
}
@@ -755,13 +751,9 @@
update();
ConfiguredTarget a = getConfiguredTarget("//a:x");
- assertThat(a.getProvider(RuleInfo.class).getData())
+ assertThat(a.getProvider(RuleInfo.class).getData().toList())
.containsExactly(
- "aspect //a:a",
- "aspect //a:b",
- "aspect //a:c",
- "aspect //extra:extra",
- "rule //a:x");
+ "aspect //a:a", "aspect //a:b", "aspect //a:c", "aspect //extra:extra", "rule //a:x");
}
/**
@@ -779,7 +771,7 @@
"all_attributes_with_tool_aspect(name='x', foo=[':a'])");
ConfiguredTarget a = getConfiguredTarget("//a:x");
- assertThat(a.getProvider(RuleInfo.class).getData())
+ assertThat(a.getProvider(RuleInfo.class).getData().toList())
.containsExactly("aspect //a:a", "rule //a:x");
}
@@ -800,7 +792,7 @@
"all_attributes_with_tool_aspect(name='x', foo=[':a'])");
ConfiguredTarget a = getConfiguredTarget("//a:x");
- assertThat(a.getProvider(RuleInfo.class).getData())
+ assertThat(a.getProvider(RuleInfo.class).getData().toList())
.containsExactly(
"aspect //a:a", "aspect //a:b", "aspect //a:c", "aspect //a:tool", "rule //a:x");
}
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 95bea15..432115a 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
@@ -765,8 +765,7 @@
ConfiguredTarget target = Iterables.getOnlyElement(getAnalysisResult().getTargetsToBuild());
assertThat(target.getLabel().toString()).isEqualTo(aoutLabel);
- Artifact aout = Iterables.getOnlyElement(
- target.getProvider(FileProvider.class).getFilesToBuild());
+ Artifact aout = target.getProvider(FileProvider.class).getFilesToBuild().getSingleton();
Action action = getGeneratingAction(aout);
assertThat(action.getClass()).isSameInstanceAs(FailAction.class);
}
@@ -783,8 +782,7 @@
"cc_binary(name = 'foo', srcs = ['foo.cc'])");
ConfiguredTarget foo =
Iterables.getOnlyElement(update("//actions_not_registered:foo").getTargetsToBuild());
- Artifact fooOut =
- Iterables.getOnlyElement(foo.getProvider(FileProvider.class).getFilesToBuild());
+ Artifact fooOut = foo.getProvider(FileProvider.class).getFilesToBuild().getSingleton();
assertThat(getActionGraph().getGeneratingAction(fooOut)).isNotNull();
clearAnalysisResult();
@@ -828,8 +826,7 @@
ConfiguredTarget target = Iterables.getOnlyElement(getAnalysisResult().getTargetsToBuild());
assertThat(target.getLabel().toString()).isEqualTo(aoutLabel);
- Artifact aout = Iterables.getOnlyElement(
- target.getProvider(FileProvider.class).getFilesToBuild());
+ Artifact aout = target.getProvider(FileProvider.class).getFilesToBuild().getSingleton();
Action action = getGeneratingAction(aout);
assertThat(action.getClass()).isSameInstanceAs(FailAction.class);
}
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/LabelExpanderTest.java b/src/test/java/com/google/devtools/build/lib/analysis/LabelExpanderTest.java
index 590933a..97894ae 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/LabelExpanderTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/LabelExpanderTest.java
@@ -75,7 +75,7 @@
*/
private void collectArtifacts() {
ImmutableMap.Builder<String, Artifact> builder = ImmutableMap.builder();
- for (Artifact artifact : getFilesToBuild(dummyTarget)) {
+ for (Artifact artifact : getFilesToBuild(dummyTarget).toList()) {
builder.put(artifact.getRootRelativePath().toString(), artifact);
}
artifactsByName = builder.build();
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/RunfilesSupplierImplTest.java b/src/test/java/com/google/devtools/build/lib/analysis/RunfilesSupplierImplTest.java
index 06d43f0..85aab12 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/RunfilesSupplierImplTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/RunfilesSupplierImplTest.java
@@ -50,7 +50,7 @@
RunfilesSupplierImpl underTest =
new RunfilesSupplierImpl(PathFragment.create("notimportant"), mkRunfiles(artifacts));
- assertThat(underTest.getArtifacts()).containsExactlyElementsIn(artifacts);
+ assertThat(underTest.getArtifacts().toList()).containsExactlyElementsIn(artifacts);
}
@Test
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java b/src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java
index 70aacf6..92eec07 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java
@@ -432,8 +432,7 @@
Runfiles runfiles2 = new Runfiles.Builder("TESTING").addLegacyExtraMiddleman(mm2).build();
Runfiles runfilesMerged =
new Runfiles.Builder("TESTING").merge(runfiles1).merge(runfiles2).build();
- assertThat(runfilesMerged.getExtraMiddlemen())
- .containsExactlyElementsIn(ImmutableList.of(mm1, mm2));
+ assertThat(runfilesMerged.getExtraMiddlemen().toList()).containsExactly(mm1, mm2);
}
@Test
@@ -452,7 +451,7 @@
.map((f) -> f.replaceName(f.getBaseName() + "-empty"))
.collect(ImmutableList.toImmutableList()))
.build();
- assertThat(runfiles.getEmptyFilenames())
+ assertThat(runfiles.getEmptyFilenames().toList())
.containsExactly("my-artifact-empty", "my-symlink-empty");
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/TopLevelArtifactHelperTest.java b/src/test/java/com/google/devtools/build/lib/analysis/TopLevelArtifactHelperTest.java
index 832d049..aed1bc1 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/TopLevelArtifactHelperTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/TopLevelArtifactHelperTest.java
@@ -74,20 +74,20 @@
setup(asList(Pair.of("foo", 3), Pair.of("bar", 2)));
ArtifactsToBuild allArtifacts = getAllArtifactsToBuild(groupProvider, null, ctx);
- assertThat(allArtifacts.getAllArtifacts()).hasSize(5);
- assertThat(allArtifacts.getImportantArtifacts()).hasSize(5);
+ assertThat(allArtifacts.getAllArtifacts().toList()).hasSize(5);
+ assertThat(allArtifacts.getImportantArtifacts().toList()).hasSize(5);
NestedSet<ArtifactsInOutputGroup> artifactsByGroup =
allArtifacts.getAllArtifactsByOutputGroup();
// Two groups
- assertThat(artifactsByGroup).hasSize(2);
+ assertThat(artifactsByGroup.toList()).hasSize(2);
- for (ArtifactsInOutputGroup artifacts : artifactsByGroup) {
+ for (ArtifactsInOutputGroup artifacts : artifactsByGroup.toList()) {
String outputGroup = artifacts.getOutputGroup();
if ("foo".equals(outputGroup)) {
- assertThat(artifacts.getArtifacts()).hasSize(3);
+ assertThat(artifacts.getArtifacts().toList()).hasSize(3);
} else if ("bar".equals(outputGroup)) {
- assertThat(artifacts.getArtifacts()).hasSize(2);
+ assertThat(artifacts.getArtifacts().toList()).hasSize(2);
}
}
}
@@ -97,13 +97,13 @@
setup(asList(Pair.of("foo", 1), Pair.of("bar", 0)));
ArtifactsToBuild allArtifacts = getAllArtifactsToBuild(groupProvider, null, ctx);
- assertThat(allArtifacts.getAllArtifacts()).hasSize(1);
- assertThat(allArtifacts.getImportantArtifacts()).hasSize(1);
+ assertThat(allArtifacts.getAllArtifacts().toList()).hasSize(1);
+ assertThat(allArtifacts.getImportantArtifacts().toList()).hasSize(1);
NestedSet<ArtifactsInOutputGroup> artifactsByGroup =
allArtifacts.getAllArtifactsByOutputGroup();
// The bar list should not appear here, as it contains no artifacts.
- assertThat(artifactsByGroup).hasSize(1);
+ assertThat(artifactsByGroup.toList()).hasSize(1);
assertThat(artifactsByGroup.toList().get(0).getOutputGroup()).isEqualTo("foo");
}
@@ -112,8 +112,8 @@
setup(asList(Pair.of(HIDDEN_OUTPUT_GROUP_PREFIX + "notimportant", 1), Pair.of("important", 2)));
ArtifactsToBuild allArtifacts = getAllArtifactsToBuild(groupProvider, null, ctx);
- assertThat(allArtifacts.getAllArtifacts()).hasSize(3);
- assertThat(allArtifacts.getImportantArtifacts()).hasSize(2);
+ assertThat(allArtifacts.getAllArtifacts().toList()).hasSize(3);
+ assertThat(allArtifacts.getImportantArtifacts().toList()).hasSize(2);
}
private NestedSet<Artifact> newArtifacts(int num) {
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/actions/FileWriteActionTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/actions/FileWriteActionTestCase.java
index 5af3cc0..da0d408 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/actions/FileWriteActionTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/actions/FileWriteActionTestCase.java
@@ -80,7 +80,7 @@
}
protected void checkNoInputsByDefault() {
- assertThat(action.getInputs()).isEmpty();
+ assertThat(action.getInputs().toList()).isEmpty();
assertThat(action.getPrimaryInput()).isNull();
}
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/actions/ParamFileWriteActionTest.java b/src/test/java/com/google/devtools/build/lib/analysis/actions/ParamFileWriteActionTest.java
index aa9047b..098dafe 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/actions/ParamFileWriteActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/actions/ParamFileWriteActionTest.java
@@ -85,7 +85,7 @@
createParameterFileWriteAction(
NestedSetBuilder.create(Order.STABLE_ORDER, treeArtifact),
createTreeArtifactExpansionCommandLineDefault());
- assertThat(Artifact.toExecPaths(action.getInputs()))
+ assertThat(Artifact.asExecPaths(action.getInputs()))
.containsExactly("out/artifact/myTreeFileArtifact");
}
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTemplateTest.java b/src/test/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTemplateTest.java
index 56a0a10..71833d7 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTemplateTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTemplateTest.java
@@ -60,7 +60,7 @@
@Test
public void testInputAndOutputTreeArtifacts() {
SpawnActionTemplate actionTemplate = createSimpleSpawnActionTemplate();
- assertThat(actionTemplate.getInputs()).containsExactly(createInputTreeArtifact());
+ assertThat(actionTemplate.getInputs().toList()).containsExactly(createInputTreeArtifact());
assertThat(actionTemplate.getOutputs()).containsExactly(createOutputTreeArtifact());
}
@@ -84,8 +84,9 @@
.addCommonInputs(ImmutableList.of(commonInput))
.build(ActionsTestUtil.NULL_ACTION_OWNER);
- assertThat(actionTemplate.getTools()).containsAtLeast(commonTool, executable);
- assertThat(actionTemplate.getInputs()).containsAtLeast(commonInput, commonTool, executable);
+ assertThat(actionTemplate.getTools().toList()).containsAtLeast(commonTool, executable);
+ assertThat(actionTemplate.getInputs().toList())
+ .containsAtLeast(commonInput, commonTool, executable);
}
@Test
@@ -206,9 +207,10 @@
for (int i = 0; i < expandedActions.size(); ++i) {
String baseName = String.format("child%d", i);
- assertThat(expandedActions.get(i).getInputs()).containsExactly(
- ActionInputHelper.treeFileArtifact(
- inputTreeArtifact, PathFragment.create("children/" + baseName)));
+ assertThat(expandedActions.get(i).getInputs().toList())
+ .containsExactly(
+ ActionInputHelper.treeFileArtifact(
+ inputTreeArtifact, PathFragment.create("children/" + baseName)));
assertThat(expandedActions.get(i).getOutputs()).containsExactly(
ActionInputHelper.treeFileArtifact(
outputTreeArtifact, PathFragment.create("children/" + baseName)));
@@ -242,9 +244,10 @@
inputTreeFileArtifacts, ActionsTestUtil.NULL_ARTIFACT_OWNER));
for (int i = 0; i < expandedActions.size(); ++i) {
- assertThat(expandedActions.get(i).getInputs())
+ assertThat(expandedActions.get(i).getInputs().toList())
.containsAtLeast(commonInput, commonTool, executable);
- assertThat(expandedActions.get(i).getTools()).containsAtLeast(commonTool, executable);
+ assertThat(expandedActions.get(i).getTools().toList())
+ .containsAtLeast(commonTool, executable);
}
}
@@ -290,7 +293,8 @@
assertThat(expandedActions).hasSize(3);
for (int i = 0; i < expandedActions.size(); ++i) {
- assertThat(expandedActions.get(i).getIncompleteEnvironmentForTesting()).containsExactly("env", "value");
+ assertThat(expandedActions.get(i).getIncompleteEnvironmentForTesting())
+ .containsExactly("env", "value");
assertThat(expandedActions.get(i).getExecutionInfo()).containsExactly("local", "");
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/actions/SymlinkActionTest.java b/src/test/java/com/google/devtools/build/lib/analysis/actions/SymlinkActionTest.java
index f826c30..60655e2 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/actions/SymlinkActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/actions/SymlinkActionTest.java
@@ -68,7 +68,7 @@
@Test
public void testInputArtifactIsInput() {
- Iterable<Artifact> inputs = action.getInputs();
+ Iterable<Artifact> inputs = action.getInputs().toList();
assertThat(inputs).containsExactly(inputArtifact);
}
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/actions/TemplateExpansionActionTest.java b/src/test/java/com/google/devtools/build/lib/analysis/actions/TemplateExpansionActionTest.java
index 2e8e50e..6d3518c 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/actions/TemplateExpansionActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/actions/TemplateExpansionActionTest.java
@@ -101,7 +101,7 @@
@Test
public void testInputsIsEmpty() {
- assertThat(create().getInputs()).isEmpty();
+ assertThat(create().getInputs().toList()).isEmpty();
}
@Test
@@ -219,7 +219,7 @@
@Test
public void testArtifactTemplateHasInput() {
- assertThat(createWithArtifact().getInputs()).containsExactly(inputArtifact);
+ assertThat(createWithArtifact().getInputs().toList()).containsExactly(inputArtifact);
}
@Test
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
index f392669..e5960f5 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
@@ -20,7 +20,6 @@
import static org.junit.Assert.fail;
import com.google.common.base.Ascii;
-import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
@@ -710,7 +709,7 @@
ConfiguredTarget target, String attributeName) throws Exception {
Set<Artifact> result = new LinkedHashSet<>();
for (FileProvider provider : getPrerequisites(target, attributeName, FileProvider.class)) {
- Iterables.addAll(result, provider.getFilesToBuild());
+ result.addAll(provider.getFilesToBuild().toList());
}
return ImmutableList.copyOf(result);
}
@@ -778,7 +777,7 @@
@Nullable
private ParameterFileWriteAction paramFileWriteActionForAction(Action action) {
- for (Artifact input : action.getInputs()) {
+ for (Artifact input : action.getInputs().toList()) {
if (!(input instanceof SpecialArtifact)) {
Action generatingAction = getGeneratingAction(input);
if (generatingAction instanceof ParameterFileWriteAction) {
@@ -811,7 +810,7 @@
private Action getGeneratingAction(
String outputName, NestedSet<Artifact> filesToBuild, String providerName) {
- Artifact artifact = Iterables.find(filesToBuild, artifactNamed(outputName), null);
+ Artifact artifact = Iterables.find(filesToBuild.toList(), artifactNamed(outputName), null);
if (artifact == null) {
fail(
String.format(
@@ -849,7 +848,7 @@
protected SpawnAction getGeneratingSpawnAction(ConfiguredTarget target, String outputName) {
return getGeneratingSpawnAction(
- Iterables.find(getFilesToBuild(target), artifactNamed(outputName)));
+ Iterables.find(getFilesToBuild(target).toList(), artifactNamed(outputName)));
}
protected final List<String> getGeneratingSpawnActionArgs(Artifact artifact)
@@ -1149,6 +1148,16 @@
*
* <p>The returned set preserves the order of the input.
*/
+ protected Set<String> artifactsToStrings(NestedSet<? extends Artifact> artifacts) {
+ return artifactsToStrings(artifacts.toList());
+ }
+
+ /**
+ * Given a collection of Artifacts, returns a corresponding set of strings of the form "[root]
+ * [relpath]", such as "bin x/libx.a". Such strings make assertions easier to write.
+ *
+ * <p>The returned set preserves the order of the input.
+ */
protected Set<String> artifactsToStrings(Iterable<? extends Artifact> artifacts) {
return AnalysisTestUtil.artifactsToStrings(masterConfig, artifacts);
}
@@ -1267,7 +1276,7 @@
protected List<Artifact> getInputs(Action owner, Collection<String> execPaths) {
Set<String> expectedPaths = new HashSet<>(execPaths);
List<Artifact> result = new ArrayList<>();
- for (Artifact output : owner.getInputs()) {
+ for (Artifact output : owner.getInputs().toList()) {
if (expectedPaths.remove(output.getExecPathString())) {
result.add(output);
}
@@ -1579,14 +1588,10 @@
return ConfiguredTargetKey.of(makeLabel(label), getConfiguration(label));
}
- protected static List<String> actionInputsToPaths(Iterable<? extends ActionInput> actionInputs) {
+ protected static List<String> actionInputsToPaths(NestedSet<? extends ActionInput> actionInputs) {
return ImmutableList.copyOf(
- Iterables.transform(actionInputs, new Function<ActionInput, String>() {
- @Override
- public String apply(ActionInput actionInput) {
- return actionInput.getExecPathString();
- }
- }));
+ Iterables.transform(
+ actionInputs.toList(), (actionInput) -> actionInput.getExecPathString()));
}
/**
@@ -1624,7 +1629,7 @@
assertContainsEvent(label + " [self-edge]");
}
- protected Iterable<Artifact> collectRunfiles(ConfiguredTarget target) {
+ protected NestedSet<Artifact> collectRunfiles(ConfiguredTarget target) {
RunfilesProvider runfilesProvider = target.getProvider(RunfilesProvider.class);
if (runfilesProvider != null) {
return runfilesProvider.getDefaultRunfiles().getAllArtifacts();
@@ -1642,7 +1647,7 @@
*/
protected ImmutableList<Action> getExtraActionActions(ConfiguredTarget target) {
LinkedHashSet<Action> result = new LinkedHashSet<>();
- for (Artifact artifact : getExtraActionArtifacts(target)) {
+ for (Artifact artifact : getExtraActionArtifacts(target).toList()) {
result.add(getGeneratingAction(artifact));
}
return ImmutableList.copyOf(result);
@@ -1656,7 +1661,8 @@
for (Artifact artifact :
target
.getProvider(ExtraActionArtifactsProvider.class)
- .getTransitiveExtraActionArtifacts()) {
+ .getTransitiveExtraActionArtifacts()
+ .toList()) {
Action action = getGeneratingAction(artifact);
if (action instanceof ExtraAction) {
result.add((ExtraAction) action);
@@ -1667,7 +1673,7 @@
protected ImmutableList<Action> getFilesToBuildActions(ConfiguredTarget target) {
List<Action> result = new ArrayList<>();
- for (Artifact artifact : getFilesToBuild(target)) {
+ for (Artifact artifact : getFilesToBuild(target).toList()) {
Action action = getGeneratingAction(artifact);
if (action != null) {
result.add(action);
@@ -2064,7 +2070,10 @@
throws Exception {
ImmutableList.Builder<String> basenames = ImmutableList.builder();
for (Artifact baselineCoverage :
- target.get(InstrumentedFilesInfo.SKYLARK_CONSTRUCTOR).getBaselineCoverageArtifacts()) {
+ target
+ .get(InstrumentedFilesInfo.SKYLARK_CONSTRUCTOR)
+ .getBaselineCoverageArtifacts()
+ .toList()) {
BaselineCoverageAction baselineAction =
(BaselineCoverageAction) getGeneratingAction(baselineCoverage);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
@@ -2089,6 +2098,18 @@
* the first artifact in the inputs of its generating action that matches the second suffix etc.,
* and repeats this until the supplied suffixes run out.
*/
+ protected Artifact artifactByPath(NestedSet<Artifact> artifacts, String... suffixes) {
+ return artifactByPath(artifacts.toList(), suffixes);
+ }
+
+ /**
+ * Finds an artifact in the transitive closure of a set of other artifacts by following a path
+ * based on artifact name suffixes.
+ *
+ * <p>This selects the first artifact in the input set that matches the first suffix, then selects
+ * the first artifact in the inputs of its generating action that matches the second suffix etc.,
+ * and repeats this until the supplied suffixes run out.
+ */
protected Artifact artifactByPath(Iterable<Artifact> artifacts, String... suffixes) {
Artifact artifact = getFirstArtifactEndingWith(artifacts, suffixes[0]);
Action action = null;
@@ -2105,7 +2126,7 @@
}
action = getGeneratingAction(artifact);
- artifacts = action.getInputs();
+ artifacts = action.getInputs().toList();
artifact = getFirstArtifactEndingWith(artifacts, suffixes[i]);
}
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/CompileOnlyTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/CompileOnlyTestCase.java
index f44d402..a3c196d 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/util/CompileOnlyTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/util/CompileOnlyTestCase.java
@@ -23,7 +23,7 @@
public abstract class CompileOnlyTestCase extends BuildViewTestCase {
protected Artifact getArtifactByExecPathSuffix(ConfiguredTarget target, String path) {
- for (Artifact artifact : getOutputGroup(target, OutputGroupInfo.FILES_TO_COMPILE)) {
+ for (Artifact artifact : getOutputGroup(target, OutputGroupInfo.FILES_TO_COMPILE).toList()) {
if (artifact.getExecPathString().endsWith(path)) {
return artifact;
}
diff --git a/src/test/java/com/google/devtools/build/lib/bazel/rules/genrule/GenRuleCommandSubstitutionTest.java b/src/test/java/com/google/devtools/build/lib/bazel/rules/genrule/GenRuleCommandSubstitutionTest.java
index ec2275d..b36ed67 100644
--- a/src/test/java/com/google/devtools/build/lib/bazel/rules/genrule/GenRuleCommandSubstitutionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/bazel/rules/genrule/GenRuleCommandSubstitutionTest.java
@@ -40,7 +40,7 @@
private String getGenruleCommand(String genrule) throws Exception {
return ((SpawnAction)
- getGeneratingAction(getFilesToBuild(getConfiguredTarget(genrule)).iterator().next()))
+ getGeneratingAction(getFilesToBuild(getConfiguredTarget(genrule)).toList().get(0)))
.getArguments()
.get(2);
}
diff --git a/src/test/java/com/google/devtools/build/lib/bazel/rules/genrule/GenRuleConfiguredTargetTest.java b/src/test/java/com/google/devtools/build/lib/bazel/rules/genrule/GenRuleConfiguredTargetTest.java
index 60ce456..cd35fdf 100644
--- a/src/test/java/com/google/devtools/build/lib/bazel/rules/genrule/GenRuleConfiguredTargetTest.java
+++ b/src/test/java/com/google/devtools/build/lib/bazel/rules/genrule/GenRuleConfiguredTargetTest.java
@@ -14,13 +14,11 @@
package com.google.devtools.build.lib.bazel.rules.genrule;
-import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.truth.Truth.assertThat;
import static com.google.devtools.build.lib.testutil.TestConstants.GENRULE_SETUP;
import static com.google.devtools.build.lib.testutil.TestConstants.GENRULE_SETUP_PATH;
import static org.junit.Assert.fail;
-import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.actions.Action;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.util.ActionsTestUtil;
@@ -92,7 +90,7 @@
public void testD() throws Exception {
createFiles();
ConfiguredTarget z = getConfiguredTarget("//hello:z");
- Artifact y = getOnlyElement(getFilesToBuild(z));
+ Artifact y = getFilesToBuild(z).getSingleton();
assertThat(y.getRootRelativePath()).isEqualTo(PathFragment.create("hello/x/y"));
}
@@ -129,7 +127,7 @@
"outs = ['message.txt'],",
"cmd = 'echo \"Hello, world.\" >$(location message.txt)')");
Artifact messageArtifact = getFileConfiguredTarget("//genrule1:message.txt").getArtifact();
- assertThat(getFilesToBuild(getConfiguredTarget("//genrule1:hello_world")))
+ assertThat(getFilesToBuild(getConfiguredTarget("//genrule1:hello_world")).toList())
.containsExactly(messageArtifact);
}
@@ -149,7 +147,8 @@
Artifact genruleSetupArtifact = getFileConfiguredTarget(GENRULE_SETUP).getArtifact();
assertThat(shellAction).isNotNull();
- assertThat(shellAction.getInputs()).containsExactly(ignoreMeArtifact, genruleSetupArtifact);
+ assertThat(shellAction.getInputs().toList())
+ .containsExactly(ignoreMeArtifact, genruleSetupArtifact);
assertThat(shellAction.getOutputs()).containsExactly(messageArtifact);
String expected = "echo \"Hello, world.\" >" + messageArtifact.getExecPathString();
@@ -184,7 +183,7 @@
SpawnAction shellAction = (SpawnAction) getGeneratingAction(farewellArtifact);
// inputs = { "goodbye.txt", "//genrule1:message.txt" }
- assertThat(shellAction.getInputs())
+ assertThat(shellAction.getInputs().toList())
.containsExactly(goodbyeArtifact, messageArtifact, genruleSetupArtifact);
// outputs = { "farewell.txt" }
@@ -219,10 +218,10 @@
FileConfiguredTarget bazOutTarget = getFileConfiguredTarget("//foo:baz_out.txt");
Action bazAction = getGeneratingAction(bazOutTarget.getArtifact());
- Artifact barOut = bazAction.getInputs().iterator().next();
+ Artifact barOut = bazAction.getInputs().toList().get(0);
assertThat(barOut.getExecPath().endsWith(PathFragment.create("foo/bar_out.txt"))).isTrue();
Action barAction = getGeneratingAction(barOut);
- Artifact barIn = barAction.getInputs().iterator().next();
+ Artifact barIn = barAction.getInputs().toList().get(0);
assertThat(barIn.getExecPath().endsWith(PathFragment.create("foo/bar_in.txt"))).isTrue();
}
@@ -262,7 +261,7 @@
getConfiguredTarget("//foo:bar");
- Artifact barOut = bazAction.getInputs().iterator().next();
+ Artifact barOut = bazAction.getInputs().toList().get(0);
assertThat(barOut.getExecPath().endsWith(PathFragment.create("foo/bar/bar_out.txt"))).isTrue();
SpawnAction barAction = (SpawnAction) getGeneratingAction(barOut);
String barExpected = "touch " + barOut.getExecPath().getParentDirectory().getPathString();
@@ -298,7 +297,7 @@
// Returns the SpawnAction for the specified genrule.
private SpawnAction getSpawnAction(String label) throws Exception {
return (SpawnAction)
- getGeneratingAction(getFilesToBuild(getConfiguredTarget(label)).iterator().next());
+ getGeneratingAction(getFilesToBuild(getConfiguredTarget(label)).toList().get(0));
}
@Test
@@ -541,13 +540,13 @@
}
private void assertStamped(ConfiguredTarget target) throws Exception {
- Artifact out = Iterables.getFirst(getFilesToBuild(target), null);
+ Artifact out = getFilesToBuild(target).toList().get(0);
List<String> inputs = ActionsTestUtil.baseArtifactNames(getGeneratingAction(out).getInputs());
assertThat(inputs).containsAtLeast("build-info.txt", "build-changelist.txt");
}
private void assertNotStamped(ConfiguredTarget target) throws Exception {
- Artifact out = Iterables.getFirst(getFilesToBuild(target), null);
+ Artifact out = getFilesToBuild(target).toList().get(0);
List<String> inputs = ActionsTestUtil.baseArtifactNames(getGeneratingAction(out).getInputs());
assertThat(inputs).doesNotContain("build-info.txt");
assertThat(inputs).doesNotContain("build-changelist.txt");
@@ -628,9 +627,9 @@
ConfiguredTarget parentTarget = getConfiguredTarget("//config");
// Cannot use getDirectPrerequisites, as this re-configures that target incorrectly.
- Artifact out = Iterables.getFirst(getFilesToBuild(parentTarget), null);
- assertThat(getGeneratingAction(out).getTools()).hasSize(1);
- Artifact execTool = getOnlyElement(getGeneratingAction(out).getTools());
+ Artifact out = getFilesToBuild(parentTarget).toList().get(0);
+ assertThat(getGeneratingAction(out).getTools().toList()).hasSize(1);
+ Artifact execTool = getGeneratingAction(out).getTools().getSingleton();
// This is the output dir fragment for the execution transition.
assertThat(execTool.getExecPathString()).contains("-exec-");
}
diff --git a/src/test/java/com/google/devtools/build/lib/buildtool/util/BuildIntegrationTestCase.java b/src/test/java/com/google/devtools/build/lib/buildtool/util/BuildIntegrationTestCase.java
index 2a1f801..06debf4 100644
--- a/src/test/java/com/google/devtools/build/lib/buildtool/util/BuildIntegrationTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/buildtool/util/BuildIntegrationTestCase.java
@@ -443,7 +443,7 @@
protected Iterable<Artifact> getArtifacts(String target)
throws LabelSyntaxException, NoSuchPackageException, NoSuchTargetException,
InterruptedException, TransitionException, InvalidConfigurationException {
- return getFilesToBuild(getConfiguredTarget(target));
+ return getFilesToBuild(getConfiguredTarget(target)).toList();
}
/**
@@ -729,14 +729,13 @@
}
/**
- * Given a collection of Artifacts, returns a corresponding set of strings of
- * the form "<root> <relpath>", such as "bin x/libx.a". Such strings make
- * assertions easier to write.
+ * Given a collection of Artifacts, returns a corresponding set of strings of the form "<root>
+ * <relpath>", such as "bin x/libx.a". Such strings make assertions easier to write.
*
* <p>The returned set preserves the order of the input.
*/
- protected Set<String> artifactsToStrings(Iterable<Artifact> artifacts) {
- return AnalysisTestUtil.artifactsToStrings(getConfigurationCollection(), artifacts);
+ protected Set<String> artifactsToStrings(NestedSet<Artifact> artifacts) {
+ return AnalysisTestUtil.artifactsToStrings(getConfigurationCollection(), artifacts.toList());
}
protected ActionsTestUtil actionsTestUtil() {
diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBuildViewTestCase.java b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBuildViewTestCase.java
index 54ed8e1..392bb5f 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBuildViewTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBuildViewTestCase.java
@@ -13,7 +13,6 @@
// limitations under the License.
package com.google.devtools.build.lib.rules.android;
-import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.getFirstArtifactEndingWith;
@@ -37,6 +36,7 @@
import com.google.devtools.build.lib.analysis.configuredtargets.OutputFileConfiguredTarget;
import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
import com.google.devtools.build.lib.cmdline.Label;
+import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.rules.android.deployinfo.AndroidDeployInfoOuterClass.AndroidDeployInfo;
import com.google.devtools.build.lib.rules.java.JavaCompileAction;
import com.google.devtools.build.lib.rules.java.JavaCompileActionTestHelper;
@@ -58,7 +58,7 @@
protected Iterable<Artifact> getNativeLibrariesInApk(ConfiguredTarget target) {
return Iterables.filter(
- getGeneratingAction(getCompressedUnsignedApk(target)).getInputs(),
+ getGeneratingAction(getCompressedUnsignedApk(target)).getInputs().toList(),
a -> a.getFilename().endsWith(".so"));
}
@@ -135,8 +135,9 @@
Preconditions.checkNotNull(target);
final AndroidResourcesInfo info = target.get(AndroidResourcesInfo.PROVIDER);
assertWithMessage("No android resources exported from the target.").that(info).isNotNull();
- return getOnlyElement(
- transitive ? info.getTransitiveAndroidResources() : info.getDirectAndroidResources());
+ return transitive
+ ? info.getTransitiveAndroidResources().getSingleton()
+ : info.getDirectAndroidResources().getSingleton();
}
protected Artifact getResourceClassJar(final ConfiguredTargetAndData target) {
@@ -203,6 +204,10 @@
return actualPaths.build();
}
+ protected String execPathEndingWith(NestedSet<Artifact> inputs, String suffix) {
+ return getFirstArtifactEndingWith(inputs, suffix).getExecPathString();
+ }
+
protected String execPathEndingWith(Iterable<Artifact> inputs, String suffix) {
return getFirstArtifactEndingWith(inputs, suffix).getExecPathString();
}
@@ -231,7 +236,8 @@
// Returns an artifact that will be generated when a rule has resources.
protected static Artifact getResourceArtifact(ConfiguredTarget target) {
// the last provider is the provider from the target.
- return Iterables.getLast(target.get(AndroidResourcesInfo.PROVIDER).getDirectAndroidResources())
+ return Iterables.getLast(
+ target.get(AndroidResourcesInfo.PROVIDER).getDirectAndroidResources().toList())
.getJavaClassJar();
}
@@ -242,7 +248,7 @@
protected Map<String, String> getLocalTestMergeeManifests(ConfiguredTarget target)
throws Exception {
return getMergeeManifests(
- ImmutableList.copyOf(collectRunfiles(target)).stream()
+ collectRunfiles(target).toList().stream()
.filter(
(artifact) ->
artifact.getFilename().equals("AndroidManifest.xml")
@@ -260,7 +266,7 @@
SpawnAction processingAction = getGeneratingSpawnAction(processedManifest);
Artifact mergedManifest =
Iterables.find(
- processingAction.getInputs(),
+ processingAction.getInputs().toList(),
(artifact) -> artifact.getExecPath().toString().equals(mergedManifestExecPathString));
List<String> mergeArgs = getGeneratingSpawnActionArgs(mergedManifest);
assertThat(mergeArgs).contains("--mergeeManifests");
@@ -289,8 +295,7 @@
}
protected static Set<Artifact> getNonToolInputs(Action action) {
- return Sets.difference(
- ImmutableSet.copyOf(action.getInputs()), ImmutableSet.copyOf(action.getTools()));
+ return Sets.difference(action.getInputs().toSet(), action.getTools().toSet());
}
protected void checkDebugKey(String debugKeyFile, boolean hasDebugKeyTarget) throws Exception {
@@ -442,7 +447,7 @@
actionsTestUtil().getActionForArtifactEndingWith(getFilesToBuild(binary), "_proguard.jar");
actionsTestUtil();
assertWithMessage("Generated config not in inputs to proguard action")
- .that(proguardAction.getInputs())
+ .that(proguardAction.getInputs().toList())
.contains(
ActionsTestUtil.getFirstArtifactEndingWith(
generateProguardAction.getOutputs(), "_proguard.cfg"));
diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestTest.java
index 440da5c..d759819 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestTest.java
@@ -22,6 +22,7 @@
import com.google.devtools.build.lib.actions.util.ActionsTestUtil;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.analysis.FileProvider;
+import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.rules.java.JavaPrimaryClassProvider;
import com.google.devtools.build.lib.testutil.MoreAsserts;
import java.util.List;
@@ -75,7 +76,7 @@
" srcs = ['test.java'],",
" deps = extra_deps)");
ConfiguredTarget target = getConfiguredTarget("//java/test:dummyTest");
- Iterable<Artifact> runfilesArtifacts = collectRunfiles(target);
+ NestedSet<Artifact> runfilesArtifacts = collectRunfiles(target);
Artifact manifest =
ActionsTestUtil.getFirstArtifactEndingWith(
runfilesArtifacts, "dummyTest_processed_manifest/AndroidManifest.xml");
@@ -91,10 +92,10 @@
" srcs = ['test.java'],",
" deps = extra_deps)");
ConfiguredTarget target = getConfiguredTarget("//java/test:dummyTest");
- Iterable<Artifact> runfilesArtifacts = collectRunfiles(target);
+ NestedSet<Artifact> runfilesArtifacts = collectRunfiles(target);
Artifact resourceClassJar =
getImplicitOutputArtifact(target, AndroidRuleClasses.ANDROID_RESOURCES_CLASS_JAR);
- assertThat(runfilesArtifacts).contains(resourceClassJar);
+ assertThat(runfilesArtifacts.toList()).contains(resourceClassJar);
}
@Test
@@ -106,10 +107,10 @@
" srcs = ['test.java'],",
" deps = extra_deps)");
ConfiguredTarget target = getConfiguredTarget("//java/test:dummyTest");
- Iterable<Artifact> runfilesArtifacts = collectRunfiles(target);
+ NestedSet<Artifact> runfilesArtifacts = collectRunfiles(target);
Artifact resourcesZip =
getImplicitOutputArtifact(target, AndroidRuleClasses.ANDROID_RESOURCES_ZIP);
- assertThat(runfilesArtifacts).contains(resourcesZip);
+ assertThat(runfilesArtifacts.toList()).contains(resourcesZip);
}
@Test
@@ -170,7 +171,7 @@
" deps = extra_deps)");
useConfiguration("--experimental_android_local_test_binary_resources");
ConfiguredTarget target = getConfiguredTarget("//java/test:dummyTest");
- Iterable<Artifact> runfilesArtifacts = collectRunfiles(target);
+ NestedSet<Artifact> runfilesArtifacts = collectRunfiles(target);
Artifact resourceApk =
ActionsTestUtil.getFirstArtifactEndingWith(runfilesArtifacts, "dummyTest.ap_");
assertThat(resourceApk).isNotNull();
@@ -186,7 +187,7 @@
" srcs = ['test.java'],",
" deps = extra_deps)");
ConfiguredTarget target = getConfiguredTarget("//java/test:dummyTest");
- Iterable<Artifact> runfilesArtifacts = collectRunfiles(target);
+ NestedSet<Artifact> runfilesArtifacts = collectRunfiles(target);
Artifact resourceApk =
ActionsTestUtil.getFirstArtifactEndingWith(runfilesArtifacts, "dummyTest.ap_");
assertThat(resourceApk).isNull();
diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidMultidexBaseTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidMultidexBaseTest.java
index fd40aa6..87d7399 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidMultidexBaseTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidMultidexBaseTest.java
@@ -76,7 +76,7 @@
SpawnAction stripAction = getGeneratingSpawnAction(strippedJar);
assertThat(stripAction.getCommandFilename())
.isEqualTo(sdk.getProguard().getExecutable().getExecPathString());
- assertThat(stripAction.getInputs()).contains(mainDexProguardSpec);
+ assertThat(stripAction.getInputs().toList()).contains(mainDexProguardSpec);
// Second action: The dexer consumes the stripped jar to create the main dex class list.
assertThat(mainDexList).isNotNull();
diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/BUILD b/src/test/java/com/google/devtools/build/lib/rules/android/BUILD
index d29ff65..8570b56 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/android/BUILD
+++ b/src/test/java/com/google/devtools/build/lib/rules/android/BUILD
@@ -265,6 +265,7 @@
"//src/main/java/com/google/devtools/build/lib:build-base",
"//src/main/java/com/google/devtools/build/lib/actions",
"//src/main/java/com/google/devtools/build/lib/cmdline",
+ "//src/main/java/com/google/devtools/build/lib/collect/nestedset",
"//src/main/java/com/google/devtools/build/lib/rules/java:java-compilation",
"//src/main/protobuf:android_deploy_info_java_proto",
"//src/test/java/com/google/devtools/build/lib:actions_testutil",
@@ -373,6 +374,7 @@
"//src/main/java/com/google/devtools/build/lib:build-base",
"//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/collect/nestedset",
"//src/main/java/com/google/devtools/build/lib/rules/java:java-rules",
"//src/test/java/com/google/devtools/build/lib:actions_testutil",
"//src/test/java/com/google/devtools/build/lib:packages_testutil",
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/BUILD b/src/test/java/com/google/devtools/build/lib/rules/cpp/BUILD
index 523e824..397ec4c 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/BUILD
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/BUILD
@@ -103,6 +103,7 @@
":SkylarkCcCommonTestHelper",
"//src/main/java/com/google/devtools/build/lib:build-base",
"//src/main/java/com/google/devtools/build/lib/actions",
+ "//src/main/java/com/google/devtools/build/lib/collect/nestedset",
"//src/main/java/com/google/devtools/build/lib/rules/cpp",
"//src/test/java/com/google/devtools/build/lib:actions_testutil",
"//src/test/java/com/google/devtools/build/lib:analysis_testutil",
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java
index 48099692..f389acc 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java
@@ -13,7 +13,6 @@
// limitations under the License.
package com.google.devtools.build.lib.rules.cpp;
-import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.baseArtifactNames;
@@ -22,7 +21,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
import com.google.common.truth.IterableSubject;
import com.google.devtools.build.lib.actions.Action;
import com.google.devtools.build.lib.actions.ActionAnalysisMetadata;
@@ -37,6 +35,7 @@
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.cmdline.RepositoryName;
+import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.packages.util.Crosstool.CcToolchainConfig;
import com.google.devtools.build.lib.packages.util.MockCcSupport;
import com.google.devtools.build.lib.util.OS;
@@ -106,7 +105,7 @@
if (emptyShouldOutputStaticLibrary()) {
assertThat(baseNamesOf(getFilesToBuild(emptylib))).isEqualTo("libemptylib.a");
} else {
- assertThat(getFilesToBuild(emptylib)).isEmpty();
+ assertThat(getFilesToBuild(emptylib).toList()).isEmpty();
}
assertThat(
emptylib
@@ -130,7 +129,7 @@
private List<String> getCopts(String target) throws Exception {
ConfiguredTarget cLib = getConfiguredTarget(target);
- Artifact object = getOnlyElement(getOutputGroup(cLib, OutputGroupInfo.FILES_TO_COMPILE));
+ Artifact object = getOutputGroup(cLib, OutputGroupInfo.FILES_TO_COMPILE).getSingleton();
CppCompileAction compileAction = (CppCompileAction) getGeneratingAction(object);
return compileAction.getCompilerOptions();
}
@@ -228,7 +227,7 @@
.getDynamicLibrariesForRuntime(/* linkingStatically= */ false)
.isEmpty())
.isTrue();
- Artifact staticallyDotA = getOnlyElement(getFilesToBuild(statically));
+ Artifact staticallyDotA = getFilesToBuild(statically).getSingleton();
assertThat(getGeneratingAction(staticallyDotA)).isInstanceOf(CppLinkAction.class);
PathFragment dotAPath = staticallyDotA.getExecPath();
assertThat(dotAPath.getPathString()).endsWith(STATIC_LIB);
@@ -243,7 +242,7 @@
"cc_library(name = 'defineslib',",
" srcs = ['defines.cc'],",
" defines = ['FOO', 'BAR'])");
- assertThat(isolatedDefines.get(CcInfo.PROVIDER).getCcCompilationContext().getDefines())
+ assertThat(isolatedDefines.get(CcInfo.PROVIDER).getCcCompilationContext().getDefines().toList())
.containsExactly("FOO", "BAR")
.inOrder();
}
@@ -267,7 +266,7 @@
ConfiguredTarget target = getConfiguredTarget("//test:bin");
CppLinkAction action = (CppLinkAction) getGeneratingAction(getExecutable(target));
- for (Artifact input : action.getInputs()) {
+ for (Artifact input : action.getInputs().toList()) {
String name = input.getFilename();
assertThat(!CppFileTypes.ARCHIVE.matches(name) && !CppFileTypes.PIC_ARCHIVE.matches(name))
.isTrue();
@@ -289,7 +288,7 @@
ConfiguredTarget target = getConfiguredTarget("//test:bin");
CppLinkAction action = (CppLinkAction) getGeneratingAction(getExecutable(target));
- for (Artifact input : action.getInputs()) {
+ for (Artifact input : action.getInputs().toList()) {
String name = input.getFilename();
assertThat(!CppFileTypes.ARCHIVE.matches(name) && !CppFileTypes.PIC_ARCHIVE.matches(name))
.isTrue();
@@ -402,7 +401,7 @@
List<CppCompileAction> compilationSteps =
actionsTestUtil()
.findTransitivePrerequisitesOf(
- getFilesToBuild(target).iterator().next(), CppCompileAction.class);
+ getFilesToBuild(target).toList().get(0), CppCompileAction.class);
return compilationSteps.get(0);
}
@@ -509,7 +508,7 @@
scratchConfiguredTarget(
"mypackage", "mytest", "cc_test(name = 'mytest', srcs = ['mytest.cc'])");
- Iterable<Artifact> runfiles = collectRunfiles(target);
+ NestedSet<Artifact> runfiles = collectRunfiles(target);
assertThat(baseArtifactNames(runfiles)).contains("mytest.dwp");
}
@@ -662,9 +661,9 @@
// make sure we did not print warnings about the linkopt
assertNoEvents();
// make sure the binary is dependent on the static lib
- Action linkAction = getGeneratingAction(getOnlyElement(getFilesToBuild(theApp)));
- ImmutableList<Artifact> filesToBuild = ImmutableList.copyOf(getFilesToBuild(theLib));
- assertThat(ImmutableSet.copyOf(linkAction.getInputs()).containsAll(filesToBuild)).isTrue();
+ Action linkAction = getGeneratingAction(getFilesToBuild(theApp).getSingleton());
+ ImmutableList<Artifact> filesToBuild = getFilesToBuild(theLib).toList();
+ assertThat(linkAction.getInputs().toSet()).containsAtLeastElementsIn(filesToBuild);
}
@Test
@@ -803,7 +802,7 @@
" deps=['a.lds'])");
ConfiguredTarget target = getConfiguredTarget("//a:bin");
CppLinkAction action =
- (CppLinkAction) getGeneratingAction(getOnlyElement(getFilesToBuild(target)));
+ (CppLinkAction) getGeneratingAction(getFilesToBuild(target).getSingleton());
assertThat(MockCcSupport.getLinkopts(action.getLinkCommandLine()))
.containsExactly(
String.format(
@@ -825,8 +824,8 @@
" deps=['a.lds'])");
ConfiguredTarget target = getConfiguredTarget("//a:bin");
CppLinkAction action =
- (CppLinkAction) getGeneratingAction(getOnlyElement(getFilesToBuild(target)));
- Iterable<Artifact> linkInputs = action.getInputs();
+ (CppLinkAction) getGeneratingAction(getFilesToBuild(target).getSingleton());
+ NestedSet<Artifact> linkInputs = action.getInputs();
assertThat(ActionsTestUtil.baseArtifactNames(linkInputs)).contains("a.lds");
}
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcImportBaseConfiguredTargetTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcImportBaseConfiguredTargetTest.java
index 0d79c0f..d168b74 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcImportBaseConfiguredTargetTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcImportBaseConfiguredTargetTest.java
@@ -18,11 +18,11 @@
import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.analysis.util.AnalysisMock;
import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
+import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.packages.util.Crosstool.CcToolchainConfig;
import org.junit.Before;
import org.junit.Test;
@@ -131,7 +131,11 @@
skylarkImplementationLoadStatement,
"cc_import(name = 'foo', shared_library = 'libfoo.dll')");
Artifact dynamicLibrary =
- Iterables.getOnlyElement(target.get(CcInfo.PROVIDER).getCcLinkingContext().getLibraries())
+ target
+ .get(CcInfo.PROVIDER)
+ .getCcLinkingContext()
+ .getLibraries()
+ .getSingleton()
.getResolvedSymlinkDynamicLibrary();
Iterable<Artifact> dynamicLibrariesForRuntime =
target
@@ -151,7 +155,11 @@
skylarkImplementationLoadStatement,
"cc_import(name = 'foo', static_library = 'libfoo.a')");
Artifact library =
- Iterables.getOnlyElement(target.get(CcInfo.PROVIDER).getCcLinkingContext().getLibraries())
+ target
+ .get(CcInfo.PROVIDER)
+ .getCcLinkingContext()
+ .getLibraries()
+ .getSingleton()
.getStaticLibrary();
assertThat(artifactsToStrings(ImmutableList.of(library))).containsExactly("src a/libfoo.a");
}
@@ -166,7 +174,11 @@
skylarkImplementationLoadStatement,
"cc_import(name = 'foo', shared_library = 'libfoo.so')");
Artifact dynamicLibrary =
- Iterables.getOnlyElement(target.get(CcInfo.PROVIDER).getCcLinkingContext().getLibraries())
+ target
+ .get(CcInfo.PROVIDER)
+ .getCcLinkingContext()
+ .getLibraries()
+ .getSingleton()
.getResolvedSymlinkDynamicLibrary();
Iterable<Artifact> dynamicLibrariesForRuntime =
target
@@ -189,7 +201,11 @@
skylarkImplementationLoadStatement,
"cc_import(name = 'foo', shared_library = 'libfoo.so.1ab2.1_a2')");
Artifact dynamicLibrary =
- Iterables.getOnlyElement(target.get(CcInfo.PROVIDER).getCcLinkingContext().getLibraries())
+ target
+ .get(CcInfo.PROVIDER)
+ .getCcLinkingContext()
+ .getLibraries()
+ .getSingleton()
.getResolvedSymlinkDynamicLibrary();
Iterable<Artifact> dynamicLibrariesForRuntime =
target
@@ -227,7 +243,11 @@
+ " interface_library = 'libfoo.ifso')");
;
Artifact library =
- Iterables.getOnlyElement(target.get(CcInfo.PROVIDER).getCcLinkingContext().getLibraries())
+ target
+ .get(CcInfo.PROVIDER)
+ .getCcLinkingContext()
+ .getLibraries()
+ .getSingleton()
.getResolvedSymlinkInterfaceLibrary();
assertThat(artifactsToStrings(ImmutableList.of(library))).containsExactly("src b/libfoo.ifso");
Iterable<Artifact> dynamicLibrariesForRuntime =
@@ -250,12 +270,20 @@
"cc_import(name = 'foo', static_library = 'libfoo.a', shared_library = 'libfoo.so')");
Artifact library =
- Iterables.getOnlyElement(target.get(CcInfo.PROVIDER).getCcLinkingContext().getLibraries())
+ target
+ .get(CcInfo.PROVIDER)
+ .getCcLinkingContext()
+ .getLibraries()
+ .getSingleton()
.getStaticLibrary();
assertThat(artifactsToStrings(ImmutableList.of(library))).containsExactly("src a/libfoo.a");
Artifact dynamicLibrary =
- Iterables.getOnlyElement(target.get(CcInfo.PROVIDER).getCcLinkingContext().getLibraries())
+ target
+ .get(CcInfo.PROVIDER)
+ .getCcLinkingContext()
+ .getLibraries()
+ .getSingleton()
.getResolvedSymlinkDynamicLibrary();
Iterable<Artifact> dynamicLibrariesForRuntime =
target
@@ -277,7 +305,11 @@
skylarkImplementationLoadStatement,
"cc_import(name = 'foo', static_library = 'libfoo.a', alwayslink = 1)");
boolean alwayslink =
- Iterables.getOnlyElement(target.get(CcInfo.PROVIDER).getCcLinkingContext().getLibraries())
+ target
+ .get(CcInfo.PROVIDER)
+ .getCcLinkingContext()
+ .getLibraries()
+ .getSingleton()
.getAlwayslink();
assertThat(alwayslink).isTrue();
}
@@ -291,7 +323,11 @@
skylarkImplementationLoadStatement,
"cc_import(name = 'foo', interface_library = 'libfoo.ifso', system_provided = 1)");
Artifact library =
- Iterables.getOnlyElement(target.get(CcInfo.PROVIDER).getCcLinkingContext().getLibraries())
+ target
+ .get(CcInfo.PROVIDER)
+ .getCcLinkingContext()
+ .getLibraries()
+ .getSingleton()
.getResolvedSymlinkInterfaceLibrary();
assertThat(artifactsToStrings(ImmutableList.of(library))).containsExactly("src a/libfoo.ifso");
Iterable<Artifact> dynamicLibrariesForRuntime =
@@ -304,7 +340,7 @@
@Test
public void testCcImportProvideHeaderFiles() throws Exception {
- Iterable<Artifact> headers =
+ NestedSet<Artifact> headers =
scratchConfiguredTarget(
"a",
"foo",
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java
index 7be005c..4534f1d 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java
@@ -18,7 +18,6 @@
import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.truth.Truth.assertThat;
-import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.actions.ActionExecutionException;
@@ -33,6 +32,7 @@
import com.google.devtools.build.lib.analysis.test.InstrumentedFilesInfo;
import com.google.devtools.build.lib.analysis.util.AnalysisMock;
import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
+import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.packages.ImplicitOutputsFunction;
import com.google.devtools.build.lib.packages.util.Crosstool.CcToolchainConfig;
import com.google.devtools.build.lib.packages.util.MockCcSupport;
@@ -146,7 +146,8 @@
ConfiguredTarget l = scratchConfiguredTarget("a", "l",
"cc_library(name='l', srcs=['l.cc'], defines=['V=$(FOO)'], toolchains=[':v'])",
"make_variable_tester(name='v', variables={'FOO': 'BAR'})");
- assertThat(l.get(CcInfo.PROVIDER).getCcCompilationContext().getDefines()).contains("V=BAR");
+ assertThat(l.get(CcInfo.PROVIDER).getCcCompilationContext().getDefines().toList())
+ .contains("V=BAR");
}
@Test
@@ -217,8 +218,8 @@
getSharedArtifact("_solib_" + cpu + "/libhello_Slibhello.so", hello);
Artifact implInterfaceSharedObjectLink =
getSharedArtifact("_solib_" + cpu + "/libhello_Slibhello.ifso", hello);
- assertThat(getFilesToBuild(hello)).containsExactly(archive, implSharedObject,
- implInterfaceSharedObject);
+ assertThat(getFilesToBuild(hello).toList())
+ .containsExactly(archive, implSharedObject, implInterfaceSharedObject);
assertThat(
LibraryToLink.getDynamicLibrariesForLinking(
hello.getProvider(CcNativeLibraryProvider.class).getTransitiveCcNativeLibraries()))
@@ -237,7 +238,7 @@
useConfiguration("--cpu=k8", "--host_cpu=k8");
ConfiguredTarget hello = getConfiguredTarget("//hello:hello");
Artifact archive = getBinArtifact("libhello.a", hello);
- assertThat(getFilesToBuild(hello)).containsExactly(archive);
+ assertThat(getFilesToBuild(hello).toList()).containsExactly(archive);
}
@Test
@@ -260,7 +261,8 @@
getSharedArtifact("_solib_" + cpu + "/libhello_Slibhello.ifso", hello);
Artifact implSharedObjectLink =
getSharedArtifact("_solib_" + cpu + "/libhello_Slibhello.so", hello);
- assertThat(getFilesToBuild(hello)).containsExactly(archive, sharedObject, implSharedObject);
+ assertThat(getFilesToBuild(hello).toList())
+ .containsExactly(archive, sharedObject, implSharedObject);
assertThat(
LibraryToLink.getDynamicLibrariesForLinking(
hello.getProvider(CcNativeLibraryProvider.class).getTransitiveCcNativeLibraries()))
@@ -278,7 +280,7 @@
useConfiguration("--experimental_save_feature_state");
ConfiguredTarget hello = getConfiguredTarget("//hello:hello");
Artifact archive = getBinArtifact("libhello.a", hello);
- assertThat(getFilesToBuild(hello)).containsExactly(archive);
+ assertThat(getFilesToBuild(hello).toList()).containsExactly(archive);
assertThat(ActionsTestUtil.baseArtifactNames(getOutputGroup(hello, OutputGroupInfo.DEFAULT)))
.containsAtLeast("enabled_features.txt", "requested_features.txt");
}
@@ -303,8 +305,9 @@
// Without interface shared libraries.
useConfiguration("--nointerface_shared_objects");
ConfiguredTarget hello = getConfiguredTarget("//hello:hello");
- Artifact sharedObject = getOnlyElement(FileType.filter(getFilesToBuild(hello),
- CppFileTypes.SHARED_LIBRARY));
+ Artifact sharedObject =
+ getOnlyElement(
+ FileType.filter(getFilesToBuild(hello).toList(), CppFileTypes.SHARED_LIBRARY));
CppLinkAction action = (CppLinkAction) getGeneratingAction(sharedObject);
for (String option : MockCcSupport.getLinkopts(action.getLinkCommandLine())) {
assertThat(option).doesNotContain("-Wl,-soname");
@@ -315,7 +318,9 @@
useConfiguration("--cpu=k8");
hello = getConfiguredTarget("//hello:hello");
sharedObject =
- FileType.filter(getFilesToBuild(hello), CppFileTypes.SHARED_LIBRARY).iterator().next();
+ FileType.filter(getFilesToBuild(hello).toList(), CppFileTypes.SHARED_LIBRARY)
+ .iterator()
+ .next();
action = (CppLinkAction) getGeneratingAction(sharedObject);
assertThat(MockCcSupport.getLinkopts(action.getLinkCommandLine()))
.contains("-Wl,-soname=libhello_Slibhello.so");
@@ -334,8 +339,9 @@
useConfiguration("--nointerface_shared_objects");
ConfiguredTarget hello = getConfiguredTarget("//hello:hello");
- Artifact sharedObject = getOnlyElement(FileType.filter(getFilesToBuild(hello),
- CppFileTypes.SHARED_LIBRARY));
+ Artifact sharedObject =
+ getOnlyElement(
+ FileType.filter(getFilesToBuild(hello).toList(), CppFileTypes.SHARED_LIBRARY));
CppLinkAction action = (CppLinkAction) getGeneratingAction(sharedObject);
ExtraActionInfo.Builder builder = action.getExtraActionInfo(actionKeyContext);
@@ -373,7 +379,9 @@
useConfiguration("--cpu=k8");
ConfiguredTarget hello = getConfiguredTarget("//hello:hello");
Artifact sharedObject =
- FileType.filter(getFilesToBuild(hello), CppFileTypes.SHARED_LIBRARY).iterator().next();
+ FileType.filter(getFilesToBuild(hello).toList(), CppFileTypes.SHARED_LIBRARY)
+ .iterator()
+ .next();
CppLinkAction action = (CppLinkAction) getGeneratingAction(sharedObject);
ExtraActionInfo.Builder builder = action.getExtraActionInfo(actionKeyContext);
@@ -411,7 +419,7 @@
useConfiguration("--features=" + Link.LinkTargetType.STATIC_LIBRARY.getActionName());
ConfiguredTarget hello = getConfiguredTarget("//hello:hello");
Artifact archive =
- FileType.filter(getFilesToBuild(hello), FileType.of(".lib")).iterator().next();
+ FileType.filter(getFilesToBuild(hello).toList(), FileType.of(".lib")).iterator().next();
CppLinkAction action = (CppLinkAction) getGeneratingAction(archive);
@@ -460,18 +468,18 @@
assertThat(helloObjAction).isNotNull();
Artifact helloLib =
- FileType.filter(getFilesToBuild(hello), CppFileTypes.ARCHIVE).iterator().next();
+ FileType.filter(getFilesToBuild(hello).toList(), CppFileTypes.ARCHIVE).iterator().next();
assertThat(helloLib.getExecPathString()).endsWith("hello.lib");
ConfiguredTarget helloAlwaysLink = getConfiguredTarget("//hello:hello_alwayslink");
Artifact helloLibAlwaysLink =
- FileType.filter(getFilesToBuild(helloAlwaysLink), CppFileTypes.ALWAYS_LINK_LIBRARY)
+ FileType.filter(getFilesToBuild(helloAlwaysLink).toList(), CppFileTypes.ALWAYS_LINK_LIBRARY)
.iterator()
.next();
assertThat(helloLibAlwaysLink.getExecPathString()).endsWith("hello_alwayslink.lo.lib");
ConfiguredTarget helloBin = getConfiguredTarget("//hello:hello_bin");
- Artifact helloBinExe = getFilesToBuild(helloBin).iterator().next();
+ Artifact helloBinExe = getFilesToBuild(helloBin).toList().get(0);
assertThat(helloBinExe.getExecPathString()).endsWith("hello_bin.exe");
assertThat(
@@ -533,7 +541,7 @@
useConfiguration("--features=" + Link.LinkTargetType.STATIC_LIBRARY.getActionName());
ConfiguredTarget hello = getConfiguredTarget("//hello:hello");
Artifact archive =
- FileType.filter(getFilesToBuild(hello), CppFileTypes.ARCHIVE).iterator().next();
+ FileType.filter(getFilesToBuild(hello).toList(), CppFileTypes.ARCHIVE).iterator().next();
assertThat(archive.getExecPathString()).endsWith("libhello.a");
}
@@ -551,14 +559,14 @@
assertThat(artifactsToStrings(getOutputGroup(helloStatic, OutputGroupInfo.HIDDEN_TOP_LEVEL)))
.containsExactly("bin hello/_objs/hello_static/hello.pic.o");
Artifact implSharedObject = getBinArtifact("libhello_static.so", helloStatic);
- assertThat(getFilesToBuild(helloStatic)).doesNotContain(implSharedObject);
+ assertThat(getFilesToBuild(helloStatic).toList()).doesNotContain(implSharedObject);
// And for shared libraries.
ConfiguredTarget hello = getConfiguredTarget("//hello:hello");
assertThat(artifactsToStrings(getOutputGroup(helloStatic, OutputGroupInfo.HIDDEN_TOP_LEVEL)))
.containsExactly("bin hello/_objs/hello_static/hello.pic.o");
implSharedObject = getBinArtifact("libhello.so", hello);
- assertThat(getFilesToBuild(hello)).contains(implSharedObject);
+ assertThat(getFilesToBuild(hello).toList()).contains(implSharedObject);
}
@Test
@@ -650,31 +658,22 @@
assertThat(noModuleAction.getCompilerOptions()).doesNotContain("module_name://module:module");
}
- /**
- * Returns the non-system module maps in {@code input}.
- */
- private Iterable<Artifact> getNonSystemModuleMaps(Iterable<Artifact> input) {
- return Iterables.filter(input, new Predicate<Artifact>() {
- @Override
- public boolean apply(Artifact input) {
- PathFragment path = input.getExecPath();
- return CppFileTypes.CPP_MODULE_MAP.matches(path)
- && !path.endsWith(STL_CPPMAP)
- && !path.endsWith(CROSSTOOL_CPPMAP);
- }
- });
+ /** Returns the non-system module maps in {@code input}. */
+ private static Iterable<Artifact> getNonSystemModuleMaps(NestedSet<Artifact> input) {
+ return Iterables.filter(
+ input.toList(),
+ (a) -> {
+ PathFragment path = a.getExecPath();
+ return CppFileTypes.CPP_MODULE_MAP.matches(path)
+ && !path.endsWith(STL_CPPMAP)
+ && !path.endsWith(CROSSTOOL_CPPMAP);
+ });
}
- /**
- * Returns the header module artifacts in {@code input}.
- */
- private Iterable<Artifact> getHeaderModules(Iterable<Artifact> input) {
- return Iterables.filter(input, new Predicate<Artifact>() {
- @Override
- public boolean apply(Artifact input) {
- return CppFileTypes.CPP_MODULE.matches(input.getExecPath());
- }
- });
+ /** Returns the header module artifacts in {@code input}. */
+ private static Iterable<Artifact> getHeaderModules(NestedSet<Artifact> input) {
+ return Iterables.filter(
+ input.toList(), (artifact) -> CppFileTypes.CPP_MODULE.matches(artifact.getExecPath()));
}
/**
@@ -715,16 +714,18 @@
CppCompileAction bModuleAction = (CppCompileAction) getGeneratingAction(bModuleArtifact);
assertThat(bModuleAction.getIncludeScannerSources()).containsExactly(
getSourceArtifact("module/b.h"), getSourceArtifact("module/t.h"));
- assertThat(bModuleAction.getInputs()).contains(getGenfilesArtifact("b.cppmap", moduleB));
+ assertThat(bModuleAction.getInputs().toList())
+ .contains(getGenfilesArtifact("b.cppmap", moduleB));
ConfiguredTarget moduleA = getConfiguredTarget("//module:a");
Artifact aObjectArtifact = getBinArtifact("_objs/a/a.pic.o", moduleA);
CppCompileAction aObjectAction = (CppCompileAction) getGeneratingAction(aObjectArtifact);
assertThat(aObjectAction.getIncludeScannerSources()).containsExactly(
getSourceArtifact("module/a.cc"));
- assertThat(aObjectAction.getCcCompilationContext().getTransitiveModules(true))
+ assertThat(aObjectAction.getCcCompilationContext().getTransitiveModules(true).toList())
.contains(getBinArtifact("_objs/b/b.pic.pcm", moduleB));
- assertThat(aObjectAction.getInputs()).contains(getGenfilesArtifact("b.cppmap", moduleB));
+ assertThat(aObjectAction.getInputs().toList())
+ .contains(getGenfilesArtifact("b.cppmap", moduleB));
assertNoEvents();
}
@@ -760,11 +761,16 @@
assertThat(getGeneratingAction(a3)).isNotNull();
assertThat(getGeneratingAction(b)).isNotNull();
- assertThat(getGeneratingAction(a0).getInputs()).contains(getSourceArtifact("foo/a.cc"));
- assertThat(getGeneratingAction(a1).getInputs()).contains(getSourceArtifact("foo/subpkg1/a.c"));
- assertThat(getGeneratingAction(a2).getInputs()).contains(getSourceArtifact("bar/a.cpp"));
- assertThat(getGeneratingAction(a3).getInputs()).contains(getSourceArtifact("foo/subpkg2/A.c"));
- assertThat(getGeneratingAction(b).getInputs()).contains(getSourceArtifact("foo/subpkg1/b.cc"));
+ assertThat(getGeneratingAction(a0).getInputs().toList())
+ .contains(getSourceArtifact("foo/a.cc"));
+ assertThat(getGeneratingAction(a1).getInputs().toList())
+ .contains(getSourceArtifact("foo/subpkg1/a.c"));
+ assertThat(getGeneratingAction(a2).getInputs().toList())
+ .contains(getSourceArtifact("bar/a.cpp"));
+ assertThat(getGeneratingAction(a3).getInputs().toList())
+ .contains(getSourceArtifact("foo/subpkg2/A.c"));
+ assertThat(getGeneratingAction(b).getInputs().toList())
+ .contains(getSourceArtifact("foo/subpkg1/b.cc"));
}
private void setupPackagesForModuleTests(boolean useHeaderModules) throws Exception {
@@ -1388,7 +1394,7 @@
scratchConfiguredTarget("a", "foo", "cc_library(name = 'foo', srcs = ['foo.cc'])");
LibraryToLink library =
- Iterables.getOnlyElement(target.get(CcInfo.PROVIDER).getCcLinkingContext().getLibraries());
+ target.get(CcInfo.PROVIDER).getCcLinkingContext().getLibraries().getSingleton();
Artifact libraryToUse = library.getPicStaticLibrary();
if (libraryToUse == null) {
// We may get either a static library or pic static library depending on platform.
@@ -1405,7 +1411,7 @@
scratchConfiguredTarget("a", "foo", "cc_library(name = 'foo', srcs = ['libfoo.so'])");
LibraryToLink library =
- Iterables.getOnlyElement(target.get(CcInfo.PROVIDER).getCcLinkingContext().getLibraries());
+ target.get(CcInfo.PROVIDER).getCcLinkingContext().getLibraries().getSingleton();
assertThat(library.getStaticLibrary()).isNull();
assertThat(artifactsToStrings(ImmutableList.of(library.getResolvedSymlinkDynamicLibrary())))
.contains("src a/libfoo.so");
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSelectionTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSelectionTest.java
index 99f13f9..6b4dd9a 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSelectionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSelectionTest.java
@@ -17,7 +17,6 @@
import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
import com.google.devtools.build.lib.analysis.util.ScratchAttributeWriter;
@@ -57,8 +56,7 @@
getRuleContext(target)
.getToolchainContext()
.forToolchainType(Label.parseAbsolute(CPP_TOOLCHAIN_TYPE, ImmutableMap.of()));
- assertThat(Iterables.getOnlyElement(toolchain.getCompilerFiles()).getExecPathString())
- .endsWith("k8");
+ assertThat(toolchain.getCompilerFiles().getSingleton().getExecPathString()).endsWith("k8");
}
@Test
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java
index c0b7a30..e713826 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java
@@ -722,32 +722,34 @@
getOutputGroup(libTarget, "archive").toList().stream()
.collect(MoreCollectors.onlyElement());
ActionAnalysisMetadata staticAction = getGeneratingAction(staticLib);
- assertThat(staticAction.getInputs()).containsAtLeastElementsIn(toolchainProvider.getArFiles());
+ assertThat(staticAction.getInputs().toList())
+ .containsAtLeastElementsIn(toolchainProvider.getArFiles().toList());
Artifact dynamicLib =
getOutputGroup(libTarget, "dynamic_library").toList().stream()
.collect(MoreCollectors.onlyElement());
ActionAnalysisMetadata dynamicAction = getGeneratingAction(dynamicLib);
- assertThat(dynamicAction.getInputs())
- .containsAtLeastElementsIn(toolchainProvider.getLinkerFiles());
+ assertThat(dynamicAction.getInputs().toList())
+ .containsAtLeastElementsIn(toolchainProvider.getLinkerFiles().toList());
ActionAnalysisMetadata cCompileAction =
libTarget.getActions().stream()
.filter((a) -> a.getMnemonic().equals("CppCompile"))
.collect(MoreCollectors.onlyElement());
- assertThat(cCompileAction.getInputs())
- .containsAtLeastElementsIn(toolchainProvider.getCompilerFiles());
+ assertThat(cCompileAction.getInputs().toList())
+ .containsAtLeastElementsIn(toolchainProvider.getCompilerFiles().toList());
ActionAnalysisMetadata asmAction =
((RuleConfiguredTarget) getConfiguredTarget("//a:asm"))
.getActions().stream()
.filter((a) -> a.getMnemonic().equals("CppCompile"))
.collect(MoreCollectors.onlyElement());
- assertThat(asmAction.getInputs()).containsAtLeastElementsIn(toolchainProvider.getAsFiles());
+ assertThat(asmAction.getInputs().toList())
+ .containsAtLeastElementsIn(toolchainProvider.getAsFiles().toList());
ActionAnalysisMetadata preprocessedAsmAction =
((RuleConfiguredTarget) getConfiguredTarget("//a:preprocessed-asm"))
.getActions().stream()
.filter((a) -> a.getMnemonic().equals("CppCompile"))
.collect(MoreCollectors.onlyElement());
- assertThat(preprocessedAsmAction.getInputs())
- .containsAtLeastElementsIn(toolchainProvider.getCompilerFiles());
+ assertThat(preprocessedAsmAction.getInputs().toList())
+ .containsAtLeastElementsIn(toolchainProvider.getCompilerFiles().toList());
}
@Test
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileBuildVariablesTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileBuildVariablesTest.java
index 87d6ed2..de40715 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileBuildVariablesTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileBuildVariablesTest.java
@@ -16,10 +16,8 @@
import static com.google.common.truth.Truth.assertThat;
-import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
-import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget;
import com.google.devtools.build.lib.analysis.util.AnalysisMock;
import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
@@ -38,15 +36,10 @@
return (CppCompileAction)
getGeneratingAction(
Iterables.find(
- getGeneratingAction(
- Iterables.getOnlyElement(getFilesToBuild(getConfiguredTarget(label))))
- .getInputs(),
- new Predicate<Artifact>() {
- @Override
- public boolean apply(Artifact artifact) {
- return artifact.getExecPath().getBaseName().startsWith(name);
- }
- }));
+ getGeneratingAction(getFilesToBuild(getConfiguredTarget(label)).getSingleton())
+ .getInputs()
+ .toList(),
+ (artifact) -> artifact.getExecPath().getBaseName().startsWith(name)));
}
/** Returns active build variables for a compile action of given type for given target. */
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java
index 4f4a1b2..88280f3 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java
@@ -22,7 +22,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
import com.google.common.primitives.Ints;
import com.google.devtools.build.lib.actions.Action;
import com.google.devtools.build.lib.actions.ActionAnalysisMetadata;
@@ -662,7 +661,8 @@
assertThat(resources.getCpuUsage())
.isAtLeast(CppLinkAction.MIN_STATIC_LINK_RESOURCES.getCpuUsage());
- final int linkSize = Iterables.size(linkAction.getLinkCommandLine().getLinkerInputArtifacts());
+ final int linkSize =
+ linkAction.getLinkCommandLine().getLinkerInputArtifacts().memoizedFlattenAndGetSize();
ResourceSet scaledSet =
ResourceSet.createWithRamCpu(
CppLinkAction.LINK_RESOURCES_PER_INPUT.getMemoryMb() * linkSize,
@@ -771,8 +771,7 @@
ConfiguredTarget configuredTarget = getConfiguredTarget("//foo:foo");
assertThat(configuredTarget).isNotNull();
ImmutableList<String> inputs =
- ImmutableList.copyOf(getGeneratingAction(configuredTarget, "foo/libfoo.so").getInputs())
- .stream()
+ getGeneratingAction(configuredTarget, "foo/libfoo.so").getInputs().toList().stream()
.map(Artifact::getExecPathString)
.collect(ImmutableList.toImmutableList());
assertThat(inputs.stream().anyMatch(i -> i.contains("tools/cpp/link_dynamic_library")))
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkstampCompileHelperTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkstampCompileHelperTest.java
index 051c118..d194337 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkstampCompileHelperTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkstampCompileHelperTest.java
@@ -123,7 +123,7 @@
CppLinkAction generatingAction = (CppLinkAction) getGeneratingAction(executable);
Artifact compiledLinkstamp =
ActionsTestUtil.getFirstArtifactEndingWith(generatingAction.getInputs(), "ls.o");
- assertThat(generatingAction.getInputs()).contains(compiledLinkstamp);
+ assertThat(generatingAction.getInputs().toList()).contains(compiledLinkstamp);
CppCompileAction linkstampCompileAction =
(CppCompileAction) getGeneratingAction(compiledLinkstamp);
@@ -167,7 +167,7 @@
CppLinkAction generatingAction = (CppLinkAction) getGeneratingAction(executable);
Artifact compiledLinkstamp =
ActionsTestUtil.getFirstArtifactEndingWith(generatingAction.getInputs(), "ls.o");
- assertThat(generatingAction.getInputs()).contains(compiledLinkstamp);
+ assertThat(generatingAction.getInputs().toList()).contains(compiledLinkstamp);
CppCompileAction linkstampCompileAction =
(CppCompileAction) getGeneratingAction(compiledLinkstamp);
@@ -193,7 +193,7 @@
CppLinkAction generatingAction = (CppLinkAction) getGeneratingAction(executable);
Artifact compiledLinkstamp =
ActionsTestUtil.getFirstArtifactEndingWith(generatingAction.getInputs(), "ls.o");
- assertThat(generatingAction.getInputs()).contains(compiledLinkstamp);
+ assertThat(generatingAction.getInputs().toList()).contains(compiledLinkstamp);
CppCompileAction linkstampCompileAction =
(CppCompileAction) getGeneratingAction(compiledLinkstamp);
@@ -248,13 +248,11 @@
ActionsTestUtil.getFirstArtifactEndingWith(
generatingAction.getInputs(), usePic ? "main.pic.o" : "main.o");
Artifact bar =
- ImmutableList.copyOf(generatingAction.getInputs())
- .stream()
+ generatingAction.getInputs().toList().stream()
.filter(a -> a.getExecPath().getBaseName().contains("bar"))
.findFirst()
.get();
- ImmutableList<Artifact> linkstampInputs =
- ImmutableList.copyOf(linkstampCompileAction.getInputs());
+ ImmutableList<Artifact> linkstampInputs = linkstampCompileAction.getInputs().toList();
assertThat(linkstampInputs).containsAtLeast(mainObject, bar);
}
@@ -278,7 +276,7 @@
CppLinkAction generatingAction = (CppLinkAction) getGeneratingAction(executable);
Artifact compiledLinkstamp =
ActionsTestUtil.getFirstArtifactEndingWith(generatingAction.getInputs(), "ls.o");
- assertThat(generatingAction.getInputs()).contains(compiledLinkstamp);
+ assertThat(generatingAction.getInputs().toList()).contains(compiledLinkstamp);
CppCompileAction linkstampCompileAction =
(CppCompileAction) getGeneratingAction(compiledLinkstamp);
@@ -306,7 +304,7 @@
CppLinkAction generatingAction = (CppLinkAction) getGeneratingAction(executable);
Artifact compiledLinkstamp =
ActionsTestUtil.getFirstArtifactEndingWith(generatingAction.getInputs(), "ls.o");
- assertThat(generatingAction.getInputs()).contains(compiledLinkstamp);
+ assertThat(generatingAction.getInputs().toList()).contains(compiledLinkstamp);
CppCompileAction linkstampCompileAction =
(CppCompileAction) getGeneratingAction(compiledLinkstamp);
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/LibraryLinkingTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/LibraryLinkingTest.java
index e48af84..181aa35 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/LibraryLinkingTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/LibraryLinkingTest.java
@@ -15,7 +15,6 @@
import static com.google.common.truth.Truth.assertThat;
-import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
@@ -107,13 +106,8 @@
Artifact archiveLib =
Iterables.getOnlyElement(
Iterables.filter(
- ccLib.getProvider(FileProvider.class).getFilesToBuild(),
- new Predicate<Artifact>() {
- @Override
- public boolean apply(Artifact artifact) {
- return artifact.getFilename().equals("libcustom_malloc.a");
- }
- }));
+ ccLib.getProvider(FileProvider.class).getFilesToBuild().toList(),
+ (artifact) -> artifact.getFilename().equals("libcustom_malloc.a")));
CppLinkAction archiveLink = (CppLinkAction) getGeneratingAction(archiveLib);
List<String> args = archiveLink.getArguments();
assertThat(args).doesNotContain(linkOpt1);
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/LinkBuildVariablesTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/LinkBuildVariablesTest.java
index 45d358c..3cea7f4 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/LinkBuildVariablesTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/LinkBuildVariablesTest.java
@@ -487,7 +487,7 @@
}
private Action getPredecessorByInputName(Action action, String str) {
- for (Artifact a : action.getInputs()) {
+ for (Artifact a : action.getInputs().toList()) {
if (a.getExecPathString().contains(str)) {
return getGeneratingAction(a);
}
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcCommonTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcCommonTest.java
index ee3be76..6719a01 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcCommonTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcCommonTest.java
@@ -5595,7 +5595,8 @@
scratch, "tools/build_defs/foo", "additional_inputs=ctx.files._additional_inputs");
ConfiguredTarget target = getConfiguredTarget("//foo:skylark_lib");
assertThat(target).isNotNull();
- assertThat(target.get(CcInfo.PROVIDER).getCcLinkingContext().getNonCodeInputs()).hasSize(1);
+ assertThat(target.get(CcInfo.PROVIDER).getCcLinkingContext().getNonCodeInputs().toList())
+ .hasSize(1);
}
@Test
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoLibraryTest.java
index 6f6513c..521ba1a 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoLibraryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoLibraryTest.java
@@ -212,7 +212,7 @@
AspectParameters.EMPTY));
CcCompilationContext ccCompilationContext =
target.get(CcInfo.PROVIDER).getCcCompilationContext();
- assertThat(ccCompilationContext.getDeclaredIncludeSrcs()).containsExactly(headerFile);
+ assertThat(ccCompilationContext.getDeclaredIncludeSrcs().toList()).containsExactly(headerFile);
}
@Test
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/AppleBinaryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/AppleBinaryTest.java
index ad378c7..68fc5a1 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/AppleBinaryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/AppleBinaryTest.java
@@ -368,7 +368,7 @@
SymlinkAction action = (SymlinkAction) lipoBinAction("//x:x");
CommandAction linkAction = linkAction("//x:x");
- assertThat(action.getInputs())
+ assertThat(action.getInputs().toList())
.containsExactly(Iterables.getOnlyElement(linkAction.getOutputs()));
}
@@ -1274,7 +1274,7 @@
Action lipoAction = actionProducingArtifact("//examples:bin", "_lipobin");
ArrayList<String> genfileRoots = new ArrayList<>();
- for (Artifact archBinary : lipoAction.getInputs()) {
+ for (Artifact archBinary : lipoAction.getInputs().toList()) {
if (archBinary.getExecPathString().endsWith("bin_bin")) {
Artifact protoLib =
getFirstArtifactEndingWith(
@@ -1658,7 +1658,7 @@
assertThat(executableBinaryProvider).isNotNull();
CommandAction testLinkAction = linkAction("//test:test");
- assertThat(testLinkAction.getInputs())
+ assertThat(testLinkAction.getInputs().toList())
.contains(executableBinaryProvider.getAppleExecutableBinary());
}
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/AppleStaticLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/AppleStaticLibraryTest.java
index ed4c9f3..4268823 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/AppleStaticLibraryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/AppleStaticLibraryTest.java
@@ -104,7 +104,7 @@
SymlinkAction action = (SymlinkAction) lipoLibAction("//x:x");
CommandAction linkAction = linkLibAction("//x:x");
- assertThat(action.getInputs())
+ assertThat(action.getInputs().toList())
.containsExactly(Iterables.getOnlyElement(linkAction.getOutputs()));
}
@@ -135,9 +135,9 @@
String x8664Lib =
configurationBin("x86_64", ConfigurationDistinguisher.APPLEBIN_IOS) + "x/x-fl.a";
- assertThat(Artifact.toExecPaths(action.getInputs()))
- .containsExactly(i386Lib, x8664Lib, MOCK_XCRUNWRAPPER_PATH,
- MOCK_XCRUNWRAPPER_EXECUTABLE_PATH);
+ assertThat(Artifact.asExecPaths(action.getInputs()))
+ .containsExactly(
+ i386Lib, x8664Lib, MOCK_XCRUNWRAPPER_PATH, MOCK_XCRUNWRAPPER_EXECUTABLE_PATH);
assertThat(action.getArguments())
.containsExactly(
@@ -207,9 +207,9 @@
getGeneratingAction(
getFirstArtifactEndingWith(action.getInputs(), x8664Prefix + "package/test-fl.a"));
- assertThat(Artifact.toExecPaths(i386BinAction.getInputs()))
+ assertThat(Artifact.asExecPaths(i386BinAction.getInputs()))
.contains(i386Prefix + "package/libcclib.a");
- assertThat(Artifact.toExecPaths(x8664BinAction.getInputs()))
+ assertThat(Artifact.asExecPaths(x8664BinAction.getInputs()))
.contains(x8664Prefix + "package/libcclib.a");
}
@@ -226,9 +226,9 @@
String armv7kBin = configurationBin("armv7k", ConfigurationDistinguisher.APPLEBIN_WATCHOS)
+ "x/x-fl.a";
- assertThat(Artifact.toExecPaths(action.getInputs()))
- .containsExactly(i386Bin, armv7kBin, MOCK_XCRUNWRAPPER_PATH,
- MOCK_XCRUNWRAPPER_EXECUTABLE_PATH);
+ assertThat(Artifact.asExecPaths(action.getInputs()))
+ .containsExactly(
+ i386Bin, armv7kBin, MOCK_XCRUNWRAPPER_PATH, MOCK_XCRUNWRAPPER_EXECUTABLE_PATH);
assertContainsSublist(action.getArguments(), ImmutableList.of(
MOCK_XCRUNWRAPPER_EXECUTABLE_PATH, LIPO, "-create"));
@@ -288,13 +288,13 @@
"avoid_deps", "['//libs:apple_low_level_lib']");
CommandAction linkAction = linkLibAction("//x:x");
- Iterable<Artifact> linkActionInputs = linkAction.getInputs();
+ Iterable<Artifact> linkActionInputs = linkAction.getInputs().toList();
ImmutableList.Builder<Artifact> objects = ImmutableList.builder();
for (Artifact binActionArtifact : linkActionInputs) {
if (binActionArtifact.getRootRelativePath().getPathString().endsWith(".a")) {
CommandAction subLinkAction = (CommandAction) getGeneratingAction(binActionArtifact);
- for (Artifact linkActionArtifact : subLinkAction.getInputs()) {
+ for (Artifact linkActionArtifact : subLinkAction.getInputs().toList()) {
if (linkActionArtifact.getRootRelativePath().getPathString().endsWith(".o")) {
objects.add(linkActionArtifact);
}
@@ -475,9 +475,12 @@
assertThat(provider).isNotNull();
assertThat(provider.getMultiArchArchive()).isNotNull();
assertThat(provider.getDepsObjcProvider()).isNotNull();
- assertThat(provider.getMultiArchArchive()).isEqualTo(
- Iterables.getOnlyElement(
- provider.getDepsObjcProvider().get(ObjcProvider.MULTI_ARCH_LINKED_ARCHIVES)));
+ assertThat(provider.getMultiArchArchive())
+ .isEqualTo(
+ provider
+ .getDepsObjcProvider()
+ .get(ObjcProvider.MULTI_ARCH_LINKED_ARCHIVES)
+ .getSingleton());
}
@Test
@@ -679,9 +682,12 @@
assertThat(provider).isNotNull();
assertThat(provider.getMultiArchArchive()).isNotNull();
assertThat(provider.getDepsObjcProvider()).isNotNull();
- assertThat(provider.getMultiArchArchive()).isEqualTo(
- Iterables.getOnlyElement(
- provider.getDepsObjcProvider().get(ObjcProvider.MULTI_ARCH_LINKED_ARCHIVES)));
+ assertThat(provider.getMultiArchArchive())
+ .isEqualTo(
+ provider
+ .getDepsObjcProvider()
+ .get(ObjcProvider.MULTI_ARCH_LINKED_ARCHIVES)
+ .getSingleton());
}
@Test
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcLibraryTest.java
index f4a9247..1bcb22d 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcLibraryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcLibraryTest.java
@@ -101,7 +101,7 @@
+ "/";
assertThat(
Iterables.transform(
- provider.get(ObjcProvider.INCLUDE), PathFragment::getSafePathString))
+ provider.get(ObjcProvider.INCLUDE).toList(), PathFragment::getSafePathString))
.containsExactly(execPath + "java/com/google/dummy/test/_j2objc/test");
}
@@ -146,7 +146,7 @@
getConfiguration(target).getBinDirectory(RepositoryName.MAIN).getExecPath() + "/";
assertThat(
Iterables.transform(
- provider.get(ObjcProvider.INCLUDE), PathFragment::getSafePathString))
+ provider.get(ObjcProvider.INCLUDE).toList(), PathFragment::getSafePathString))
.containsExactly(
execPath + "java/com/google/test/_j2objc/test/" + genfilesFragment,
execPath + "java/com/google/test/_j2objc/test");
@@ -209,9 +209,8 @@
ConfiguredTarget target = getJ2ObjCAspectConfiguredTarget("//java/com/google/transpile:dummy");
J2ObjcMappingFileProvider provider = target.getProvider(J2ObjcMappingFileProvider.class);
- assertThat(Iterables.getOnlyElement(provider.getHeaderMappingFiles())
- .getRootRelativePath().toString()).isEqualTo(
- "java/com/google/transpile/dummy.mapping.j2objc");
+ assertThat(provider.getHeaderMappingFiles().getSingleton().getRootRelativePath().toString())
+ .isEqualTo("java/com/google/transpile/dummy.mapping.j2objc");
}
@Test
@@ -232,9 +231,8 @@
ConfiguredTarget target = getJ2ObjCAspectConfiguredTarget("//java/com/google/transpile:dummy");
J2ObjcMappingFileProvider provider = target.getProvider(J2ObjcMappingFileProvider.class);
- assertThat(Iterables.getOnlyElement(provider.getHeaderMappingFiles())
- .getRootRelativePath().toString()).isEqualTo(
- "java/com/google/dep/dep.mapping.j2objc");
+ assertThat(provider.getHeaderMappingFiles().getSingleton().getRootRelativePath().toString())
+ .isEqualTo("java/com/google/dep/dep.mapping.j2objc");
}
@Test
@@ -269,7 +267,7 @@
"//java/com/google/dummy/test/proto:test_proto", getAppleCrosstoolConfiguration()),
getJ2ObjcAspect());
- assertThat(provider.getClassMappingFiles()).containsExactly(classMappingFile);
+ assertThat(provider.getClassMappingFiles().toList()).containsExactly(classMappingFile);
}
@Test
@@ -296,13 +294,13 @@
J2ObjcMappingFileProvider provider = target.getProvider(J2ObjcMappingFileProvider.class);
Artifact classMappingFile =
getGenfilesArtifact("test.clsmap.properties", test, getJ2ObjcAspect());
- assertThat(provider.getClassMappingFiles()).containsExactly(classMappingFile);
+ assertThat(provider.getClassMappingFiles().toList()).containsExactly(classMappingFile);
ObjcProvider objcProvider = target.get(ObjcProvider.SKYLARK_CONSTRUCTOR);
Artifact headerFile = getGenfilesArtifact("test.j2objc.pb.h", test, getJ2ObjcAspect());
Artifact sourceFile = getGenfilesArtifact("test.j2objc.pb.m", test, getJ2ObjcAspect());
- assertThat(objcProvider.get(ObjcProvider.HEADER)).contains(headerFile);
- assertThat(objcProvider.get(ObjcProvider.SOURCE)).contains(sourceFile);
+ assertThat(objcProvider.get(ObjcProvider.HEADER).toList()).contains(headerFile);
+ assertThat(objcProvider.get(ObjcProvider.SOURCE).toList()).contains(sourceFile);
}
@Test
@@ -344,7 +342,7 @@
Artifact classMappingFile =
getGenfilesArtifact("../external/bla/foo/test.clsmap.properties", test, getJ2ObjcAspect());
- assertThat(provider.getClassMappingFiles()).containsExactly(classMappingFile);
+ assertThat(provider.getClassMappingFiles().toList()).containsExactly(classMappingFile);
ObjcProvider objcProvider = target.get(ObjcProvider.SKYLARK_CONSTRUCTOR);
@@ -352,9 +350,9 @@
getGenfilesArtifact("../external/bla/foo/test.j2objc.pb.h", test, getJ2ObjcAspect());
Artifact sourceFile =
getGenfilesArtifact("../external/bla/foo/test.j2objc.pb.m", test, getJ2ObjcAspect());
- assertThat(objcProvider.get(ObjcProvider.HEADER)).contains(headerFile);
- assertThat(objcProvider.get(ObjcProvider.SOURCE)).contains(sourceFile);
- assertThat(objcProvider.get(ObjcProvider.INCLUDE))
+ assertThat(objcProvider.get(ObjcProvider.HEADER).toList()).contains(headerFile);
+ assertThat(objcProvider.get(ObjcProvider.SOURCE).toList()).contains(sourceFile);
+ assertThat(objcProvider.get(ObjcProvider.INCLUDE).toList())
.contains(getConfiguration(target).getGenfilesFragment().getRelative("external/bla"));
}
@@ -371,10 +369,9 @@
ConfiguredTarget target = getJ2ObjCAspectConfiguredTarget("//java/com/google/transpile:dummy");
J2ObjcMappingFileProvider provider = target.getProvider(J2ObjcMappingFileProvider.class);
- assertThat(Iterables.getOnlyElement(provider.getHeaderMappingFiles())
- .getRootRelativePath().toString()).isEqualTo(
- "java/com/google/transpile/dummy.mapping.j2objc");
- assertThat(provider.getClassMappingFiles()).isEmpty();
+ assertThat(provider.getHeaderMappingFiles().getSingleton().getRootRelativePath().toString())
+ .isEqualTo("java/com/google/transpile/dummy.mapping.j2objc");
+ assertThat(provider.getClassMappingFiles().toList()).isEmpty();
}
protected void checkObjcArchiveAndLinkActions(
@@ -643,7 +640,7 @@
getConfiguration(objcTarget).getBinDirectory(RepositoryName.MAIN).getExecPath() + "/";
assertThat(
Iterables.transform(
- provider.get(ObjcProvider.INCLUDE), PathFragment::getSafePathString))
+ provider.get(ObjcProvider.INCLUDE).toList(), PathFragment::getSafePathString))
.containsExactly(execPath + "java/com/google/dummy/test/_j2objc/test");
}
@@ -693,7 +690,7 @@
getConfiguration(objcTarget).getBinDirectory(RepositoryName.MAIN).getExecPath() + "/";
assertThat(
Iterables.transform(
- provider.get(ObjcProvider.INCLUDE), PathFragment::getSafePathString))
+ provider.get(ObjcProvider.INCLUDE).toList(), PathFragment::getSafePathString))
.containsExactly(execPath + "app/_j2objc/dummyOne", execPath + "app/_j2objc/dummyTwo");
}
@@ -838,7 +835,7 @@
// Test that the module map action contains the header tree artifact as both the public header
// and part of the action inputs.
assertThat(moduleMapAction.getPublicHeaders()).contains(headers);
- assertThat(moduleMapAction.getInputs()).contains(headers);
+ assertThat(moduleMapAction.getInputs().toList()).contains(headers);
ActionExecutionContext dummyActionExecutionContext =
new ActionExecutionContext(
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcImportTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcImportTest.java
index 33d4b14..247fadf 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcImportTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcImportTest.java
@@ -63,8 +63,9 @@
" deps = ['//imp:imp'],",
")");
ObjcProvider provider = providerForTarget("//lib:lib");
- assertThat(Artifact.toExecPaths(provider.get(ObjcProvider.IMPORTED_LIBRARY)))
- .containsExactly("imp/precomp_lib.a").inOrder();
+ assertThat(Artifact.asExecPaths(provider.get(ObjcProvider.IMPORTED_LIBRARY)))
+ .containsExactly("imp/precomp_lib.a")
+ .inOrder();
}
@Test
@@ -73,8 +74,7 @@
createBinaryTargetWriter("//bin:bin").setList("deps", "//imp:imp").write();
CommandAction linkBinAction = linkAction("//bin:bin");
verifyObjlist(linkBinAction, "imp/precomp_lib.a");
- assertThat(Artifact.toExecPaths(linkBinAction.getInputs()))
- .contains("imp/precomp_lib.a");
+ assertThat(Artifact.asExecPaths(linkBinAction.getInputs())).contains("imp/precomp_lib.a");
}
@Test
@@ -110,7 +110,9 @@
" sdk_dylibs = ['libdy1', 'libdy2'],",
")");
ObjcProvider provider = providerForTarget("//imp:imp");
- assertThat(provider.get(ObjcProvider.SDK_DYLIB)).containsExactly("libdy1", "libdy2").inOrder();
+ assertThat(provider.get(ObjcProvider.SDK_DYLIB).toList())
+ .containsExactly("libdy1", "libdy2")
+ .inOrder();
}
@Test
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java
index d3e7037..7b25ee7 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java
@@ -30,7 +30,6 @@
import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.SRCS_TYPE;
import static com.google.devtools.build.lib.testutil.MoreAsserts.assertThrows;
-import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@@ -46,6 +45,7 @@
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.analysis.config.CompilationMode;
import com.google.devtools.build.lib.analysis.util.ScratchAttributeWriter;
+import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.packages.NoSuchTargetException;
import com.google.devtools.build.lib.packages.util.MockObjcSupport;
import com.google.devtools.build.lib.rules.apple.AppleToolchain;
@@ -53,7 +53,6 @@
import com.google.devtools.build.lib.rules.cpp.CppModuleMap;
import com.google.devtools.build.lib.rules.cpp.CppModuleMapAction;
import com.google.devtools.build.lib.rules.cpp.CppRuleClasses;
-import com.google.devtools.build.lib.rules.cpp.LibraryToLink;
import com.google.devtools.build.lib.rules.objc.ObjcProvider.Key;
import com.google.devtools.build.lib.testutil.TestConstants;
import com.google.devtools.common.options.OptionsParsingException;
@@ -115,7 +114,7 @@
.setAndCreateFiles("srcs", "a.m", "b.m", "private.h")
.write();
- Iterable<Artifact> files = getFilesToBuild(target);
+ NestedSet<Artifact> files = getFilesToBuild(target);
assertThat(Artifact.toRootRelativePaths(files)).containsExactly("objc/libOne.a");
}
@@ -165,10 +164,12 @@
assertThat(getGeneratingAction(a2)).isNotNull();
assertThat(getGeneratingAction(b)).isNotNull();
- assertThat(getGeneratingAction(a0).getInputs()).contains(getSourceArtifact("foo/a.m"));
- assertThat(getGeneratingAction(a1).getInputs()).contains(getSourceArtifact("foo/pkg1/a.m"));
- assertThat(getGeneratingAction(a2).getInputs()).contains(getSourceArtifact("foo/pkg2/a.m"));
- assertThat(getGeneratingAction(b).getInputs()).contains(getSourceArtifact("foo/b.m"));
+ assertThat(getGeneratingAction(a0).getInputs().toList()).contains(getSourceArtifact("foo/a.m"));
+ assertThat(getGeneratingAction(a1).getInputs().toList())
+ .contains(getSourceArtifact("foo/pkg1/a.m"));
+ assertThat(getGeneratingAction(a2).getInputs().toList())
+ .contains(getSourceArtifact("foo/pkg2/a.m"));
+ assertThat(getGeneratingAction(b).getInputs().toList()).contains(getSourceArtifact("foo/b.m"));
}
@Test
@@ -293,7 +294,7 @@
.setList("deps", "//baselib:baselib")
.write();
ObjcProvider provider = providerForTarget("//lib:lib");
- assertThat(provider.get(LIBRARY))
+ assertThat(provider.get(LIBRARY).toList())
.containsExactlyElementsIn(archiveAction("//baselib:baselib").getOutputs());
}
@@ -857,7 +858,7 @@
.setList("deps", "//objc:lib_dep")
.write();
ObjcProvider objcProvider = providerForTarget("//objc2:lib");
- assertThat(objcProvider.get(CC_LIBRARY)).isEmpty();
+ assertThat(objcProvider.get(CC_LIBRARY).toList()).isEmpty();
}
@Test
@@ -968,8 +969,10 @@
.write();
CppCompileAction compileAction = (CppCompileAction) compileAction("//lib:lib", "a.o");
assertThat(
- compileAction.discoverInputsFromDotdFiles(
- new ActionExecutionContextBuilder().build(), null, null, null))
+ compileAction
+ .discoverInputsFromDotdFiles(
+ new ActionExecutionContextBuilder().build(), null, null, null)
+ .toList())
.isEmpty();
}
@@ -1015,8 +1018,9 @@
ObjcProvider baseProvider = providerForTarget("//base_lib:lib");
ObjcProvider dependerProvider = providerForTarget("//depender_lib:lib");
- assertThat(baseProvider.get(WEAK_SDK_FRAMEWORK)).containsExactly(new SdkFramework("foo"));
- assertThat(dependerProvider.get(WEAK_SDK_FRAMEWORK))
+ assertThat(baseProvider.get(WEAK_SDK_FRAMEWORK).toList())
+ .containsExactly(new SdkFramework("foo"));
+ assertThat(dependerProvider.get(WEAK_SDK_FRAMEWORK).toList())
.containsExactly(new SdkFramework("foo"), new SdkFramework("bar"));
}
@@ -1055,7 +1059,7 @@
.setList("sdk_dylibs", "libdy1", "libdy2")
.write();
ObjcProvider provider = providerForTarget("//lib:lib");
- assertThat(provider.get(SDK_DYLIB)).containsExactly("libdy1", "libdy2").inOrder();
+ assertThat(provider.get(SDK_DYLIB).toList()).containsExactly("libdy1", "libdy2").inOrder();
}
@Test
@@ -1302,8 +1306,8 @@
.addAll(outputArgs(compileActionA.getOutputs()))
.build());
- assertThat(compileActionA.getPossibleInputsForTesting()).contains(
- getFileConfiguredTarget("//objc:some.pch").getArtifact());
+ assertThat(compileActionA.getPossibleInputsForTesting().toList())
+ .contains(getFileConfiguredTarget("//objc:some.pch").getArtifact());
}
// Converts output artifacts into expected command-line arguments.
@@ -1352,13 +1356,7 @@
Iterable<Artifact> linkerInputArtifacts =
Iterables.transform(
- objcProvider.get(CC_LIBRARY),
- new Function<LibraryToLink, Artifact>() {
- @Override
- public Artifact apply(LibraryToLink library) {
- return library.getStaticLibrary();
- }
- });
+ objcProvider.get(CC_LIBRARY).toList(), (library) -> library.getStaticLibrary());
assertThat(linkerInputArtifacts)
.containsAtLeast(
@@ -1388,8 +1386,9 @@
Set<SdkFramework> baseFrameworks = ImmutableSet.of(new SdkFramework("foo"));
Set<SdkFramework> dependerFrameworks =
ImmutableSet.of(new SdkFramework("foo"), new SdkFramework("bar"));
- assertThat(baseProvider.get(SDK_FRAMEWORK)).containsExactlyElementsIn(baseFrameworks);
- assertThat(dependerProvider.get(SDK_FRAMEWORK)).containsExactlyElementsIn(dependerFrameworks);
+ assertThat(baseProvider.get(SDK_FRAMEWORK).toList()).containsExactlyElementsIn(baseFrameworks);
+ assertThat(dependerProvider.get(SDK_FRAMEWORK).toList())
+ .containsExactlyElementsIn(dependerFrameworks);
// Make sure that the archive action does not actually include the frameworks. This is needed
// for creating binaries but is ignored for libraries.
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProtoAspectTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProtoAspectTest.java
index 9eb240d..b013efb 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProtoAspectTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProtoAspectTest.java
@@ -89,17 +89,17 @@
ConfiguredTarget topTarget = getObjcProtoAspectConfiguredTarget("//x:x");
ObjcProtoProvider objcProtoProvider = topTarget.get(ObjcProtoProvider.SKYLARK_CONSTRUCTOR);
assertThat(objcProtoProvider).isNotNull();
- assertThat(Artifact.toExecPaths(objcProtoProvider.getProtobufHeaders()))
+ assertThat(Artifact.asExecPaths(objcProtoProvider.getProtobufHeaders()))
.containsExactly(TestConstants.TOOLS_REPOSITORY_PATH_PREFIX + "objcproto/include/header.h");
- Artifact header = Iterables.getOnlyElement(objcProtoProvider.getProtobufHeaders());
+ Artifact header = objcProtoProvider.getProtobufHeaders().getSingleton();
PathFragment includePath = header.getExecPath().getParentDirectory();
PathFragment genIncludePath =
PathFragment.create(
configurationGenfiles("x86_64", ConfigurationDistinguisher.APPLEBIN_IOS, null)
+ "/" + includePath);
- assertThat(objcProtoProvider.getProtobufHeaderSearchPaths())
+ assertThat(objcProtoProvider.getProtobufHeaderSearchPaths().toList())
.containsExactly(includePath, genIncludePath);
}
@@ -149,9 +149,9 @@
ObjcProtoProvider objcProtoProvider = topTarget.get(ObjcProtoProvider.SKYLARK_CONSTRUCTOR);
assertThat(objcProtoProvider).isNotNull();
- assertThat(Artifact.toExecPaths(Iterables.concat(objcProtoProvider.getProtoFiles())))
+ assertThat(Artifact.asExecPaths(Iterables.concat(objcProtoProvider.getProtoFiles().toList())))
.containsExactly("x/data.proto");
- assertThat(Artifact.toExecPaths(objcProtoProvider.getPortableProtoFilters()))
+ assertThat(Artifact.asExecPaths(objcProtoProvider.getPortableProtoFilters()))
.containsExactly("x/data_filter.pbascii");
}
@@ -181,7 +181,7 @@
ObjcProtoProvider objcProtoProvider = topTarget.get(ObjcProtoProvider.SKYLARK_CONSTRUCTOR);
assertThat(objcProtoProvider).isNotNull();
- assertThat(Artifact.toExecPaths(objcProtoProvider.getPortableProtoFilters()))
+ assertThat(Artifact.asExecPaths(objcProtoProvider.getPortableProtoFilters()))
.containsExactly(
configurationGenfiles("x86_64", ConfigurationDistinguisher.APPLEBIN_IOS, null)
+ "/x/_proto_filters/objc_proto/generated_filter_file.pbascii");
@@ -224,7 +224,7 @@
ObjcProtoProvider objcProtoProvider = topTarget.get(ObjcProtoProvider.SKYLARK_CONSTRUCTOR);
assertThat(objcProtoProvider).isNotNull();
- assertThat(Artifact.toExecPaths(objcProtoProvider.getPortableProtoFilters()))
+ assertThat(Artifact.asExecPaths(objcProtoProvider.getPortableProtoFilters()))
.containsAtLeast(
"x/filter.pbascii",
configurationGenfiles("x86_64", ConfigurationDistinguisher.APPLEBIN_IOS, null)
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProtoProviderTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProtoProviderTest.java
index 80bcea7..be027fd 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProtoProviderTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProtoProviderTest.java
@@ -44,7 +44,7 @@
@Test
public void emptyProvider() {
ObjcProtoProvider empty = new ObjcProtoProvider.Builder().build();
- assertThat(empty.getProtoFiles()).isEmpty();
+ assertThat(empty.getProtoFiles().toList()).isEmpty();
}
@Test
@@ -54,7 +54,7 @@
new ObjcProtoProvider.Builder()
.addProtoFiles(NestedSetBuilder.<Artifact>create(Order.NAIVE_LINK_ORDER, foo))
.build();
- assertThat(Iterables.concat(onlyPropagates.getProtoFiles())).containsExactly(foo);
+ assertThat(Iterables.concat(onlyPropagates.getProtoFiles().toList())).containsExactly(foo);
}
@Test
@@ -81,10 +81,10 @@
ObjcProtoProvider depender =
new ObjcProtoProvider.Builder().addTransitive(ImmutableList.of(base1, base2)).build();
- assertThat(Iterables.concat(depender.getProtoFiles())).containsExactly(foo, bar);
- assertThat(depender.getPortableProtoFilters()).containsExactly(baz);
- assertThat(depender.getProtobufHeaders()).containsExactly(header);
- assertThat(depender.getProtobufHeaderSearchPaths()).containsExactly(searchPath);
+ assertThat(Iterables.concat(depender.getProtoFiles().toList())).containsExactly(foo, bar);
+ assertThat(depender.getPortableProtoFilters().toList()).containsExactly(baz);
+ assertThat(depender.getProtobufHeaders().toList()).containsExactly(header);
+ assertThat(depender.getProtobufHeaderSearchPaths().toList()).containsExactly(searchPath);
}
private Artifact getTestArtifact(String name) throws Exception {
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProviderTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProviderTest.java
index c778ed4..b81a060 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProviderTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProviderTest.java
@@ -63,7 +63,7 @@
@Test
public void emptyProvider() {
ObjcProvider empty = objcProviderBuilder().build();
- assertThat(empty.get(ObjcProvider.SDK_DYLIB)).isEmpty();
+ assertThat(empty.get(ObjcProvider.SDK_DYLIB).toList()).isEmpty();
}
@Test
@@ -153,7 +153,7 @@
ObjcProvider onlyPropagates = objcProviderBuilder()
.add(ObjcProvider.SDK_DYLIB, "foo")
.build();
- assertThat(onlyPropagates.get(ObjcProvider.SDK_DYLIB)).containsExactly("foo");
+ assertThat(onlyPropagates.get(ObjcProvider.SDK_DYLIB).toList()).containsExactly("foo");
}
@Test
@@ -174,9 +174,9 @@
.build();
ObjcProvider depender = objcProviderBuilder().addTransitiveAndPropagate(provider).build();
- assertThat(provider.get(ObjcProvider.INCLUDE))
+ assertThat(provider.get(ObjcProvider.INCLUDE).toList())
.containsExactly(strictInclude, propagatedInclude);
- assertThat(depender.get(ObjcProvider.INCLUDE)).containsExactly(propagatedInclude);
+ assertThat(depender.get(ObjcProvider.INCLUDE).toList()).containsExactly(propagatedInclude);
}
@Test
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java
index a74b4c5..b6691b7 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java
@@ -333,7 +333,7 @@
protected void verifyObjlist(Action originalAction, String... inputArchives) throws Exception {
ImmutableList.Builder<String> execPaths = ImmutableList.builder();
for (String inputArchive : inputArchives) {
- execPaths.add(execPathEndingWith(originalAction.getInputs(), inputArchive));
+ execPaths.add(execPathEndingWith(originalAction.getInputs().toList(), inputArchive));
}
assertThat(paramFileArgsForAction(originalAction)).containsExactlyElementsIn(execPaths.build());
}
@@ -457,7 +457,7 @@
protected Iterable<Artifact> inputsEndingWith(Action action, final String suffix) {
return Iterables.filter(
- action.getInputs(), artifact -> artifact.getExecPathString().endsWith(suffix));
+ action.getInputs().toList(), artifact -> artifact.getExecPathString().endsWith(suffix));
}
/**
@@ -535,8 +535,8 @@
ObjcProvider provider =
getConfiguredTarget("//x:x", getAppleCrosstoolConfiguration())
.get(ObjcProvider.SKYLARK_CONSTRUCTOR);
- assertThat(provider.get(HEADER)).containsExactly(getSourceArtifact("x/a.h"));
- assertThat(provider.get(INCLUDE))
+ assertThat(provider.get(HEADER).toList()).containsExactly(getSourceArtifact("x/a.h"));
+ assertThat(provider.get(INCLUDE).toList())
.containsExactly(
PathFragment.create("x/incdir"),
getAppleCrosstoolConfiguration().getGenfilesFragment().getRelative("x/incdir"));
@@ -548,7 +548,7 @@
ruleType.scratchTarget(scratch,
"srcs", "['a.m']",
"hdrs", "['a.h']");
- assertThat(compileAction("//x:x", "a.o").getPossibleInputsForTesting())
+ assertThat(compileAction("//x:x", "a.o").getPossibleInputsForTesting().toList())
.contains(getSourceArtifact("x/a.h"));
}
@@ -638,10 +638,10 @@
protected ImmutableList<Artifact> getAllObjectFilesLinkedInBin(Artifact bin) {
ImmutableList.Builder<Artifact> objects = ImmutableList.builder();
CommandAction binAction = (CommandAction) getGeneratingAction(bin);
- for (Artifact binActionArtifact : binAction.getInputs()) {
+ for (Artifact binActionArtifact : binAction.getInputs().toList()) {
if (binActionArtifact.getRootRelativePath().getPathString().endsWith(".a")) {
CommandAction linkAction = (CommandAction) getGeneratingAction(binActionArtifact);
- for (Artifact linkActionArtifact : linkAction.getInputs()) {
+ for (Artifact linkActionArtifact : linkAction.getInputs().toList()) {
if (linkActionArtifact.getRootRelativePath().getPathString().endsWith(".o")) {
objects.add(linkActionArtifact);
}
@@ -660,14 +660,14 @@
ObjcProtoProvider protoProvider = libTarget.get(ObjcProtoProvider.SKYLARK_CONSTRUCTOR);
assertThat(protoProvider).isNotNull();
assertThat(
- Artifact.toExecPaths(
- ImmutableSet.copyOf(Iterables.concat(protoProvider.getProtoFiles()))))
+ Artifact.asExecPaths(
+ ImmutableSet.copyOf(Iterables.concat(protoProvider.getProtoFiles().toList()))))
.containsExactly(
"protos/data_a.proto",
"protos/data_b.proto",
"protos/data_c.proto",
"protos/data_d.proto");
- assertThat(Artifact.toExecPaths(protoProvider.getPortableProtoFilters()))
+ assertThat(Artifact.asExecPaths(protoProvider.getPortableProtoFilters()))
.containsExactly("protos/filter_a.pbascii", "protos/filter_b.pbascii");
}
@@ -696,7 +696,7 @@
*/
protected Iterable<Artifact> getExpandedActionInputs(Action action) {
List<Artifact> containedArtifacts = new ArrayList<>();
- for (Artifact input : action.getInputs()) {
+ for (Artifact input : action.getInputs().toList()) {
if (input.isMiddlemanArtifact()) {
Action middlemanAction = getGeneratingAction(input);
Iterables.addAll(containedArtifacts, getExpandedActionInputs(middlemanAction));
@@ -724,7 +724,7 @@
Artifact bin = getBinArtifact("x_bin", topTarget);
CommandAction binAction = (CommandAction) getGeneratingAction(bin);
- assertThat(binAction.getInputs()).contains(protosGroupLib);
+ assertThat(binAction.getInputs().toList()).contains(protosGroupLib);
}
protected void checkProtoBundlingDoesNotHappen(RuleType ruleType) throws Exception {
@@ -1283,9 +1283,9 @@
String x8664Bin =
configurationBin("x86_64", ConfigurationDistinguisher.APPLEBIN_IOS) + "x/x_bin";
- assertThat(Artifact.toExecPaths(action.getInputs()))
- .containsExactly(i386Bin, x8664Bin, MOCK_XCRUNWRAPPER_PATH,
- MOCK_XCRUNWRAPPER_EXECUTABLE_PATH);
+ assertThat(Artifact.asExecPaths(action.getInputs()))
+ .containsExactly(
+ i386Bin, x8664Bin, MOCK_XCRUNWRAPPER_PATH, MOCK_XCRUNWRAPPER_EXECUTABLE_PATH);
assertThat(action.getArguments())
.containsExactly(MOCK_XCRUNWRAPPER_EXECUTABLE_PATH, LIPO,
@@ -1321,9 +1321,9 @@
verifyObjlist(i386BinAction, "package/libcclib.a");
verifyObjlist(x8664BinAction, "package/libcclib.a");
- assertThat(Artifact.toExecPaths(i386BinAction.getInputs()))
+ assertThat(Artifact.asExecPaths(i386BinAction.getInputs()))
.containsAtLeast(i386Prefix + "package/libcclib.a", i386Prefix + "x/x-linker.objlist");
- assertThat(Artifact.toExecPaths(x8664BinAction.getInputs()))
+ assertThat(Artifact.asExecPaths(x8664BinAction.getInputs()))
.containsAtLeast(x8664Prefix + "package/libcclib.a", x8664Prefix + "x/x-linker.objlist");
}
@@ -1418,7 +1418,7 @@
"deps", "['//bin:custom']");
Artifact inputFile = getSourceArtifact("bin/input.txt");
- assertThat(linkAction("//x").getInputs()).contains(inputFile);
+ assertThat(linkAction("//x").getInputs().toList()).contains(inputFile);
}
protected void checkAppleSdkVersionEnv(RuleType ruleType) throws Exception {
@@ -1567,9 +1567,9 @@
String armv7kBin = configurationBin("armv7k", ConfigurationDistinguisher.APPLEBIN_WATCHOS)
+ "x/x_bin";
- assertThat(Artifact.toExecPaths(action.getInputs()))
- .containsExactly(i386Bin, armv7kBin, MOCK_XCRUNWRAPPER_PATH,
- MOCK_XCRUNWRAPPER_EXECUTABLE_PATH);
+ assertThat(Artifact.asExecPaths(action.getInputs()))
+ .containsExactly(
+ i386Bin, armv7kBin, MOCK_XCRUNWRAPPER_PATH, MOCK_XCRUNWRAPPER_EXECUTABLE_PATH);
assertContainsSublist(action.getArguments(), ImmutableList.of(
MOCK_XCRUNWRAPPER_EXECUTABLE_PATH, LIPO, "-create"));
@@ -1819,11 +1819,11 @@
assertThat(compileActionA.getArguments()).doesNotContain("-fmodule-name");
ObjcProvider provider = providerForTarget("//z:testModuleMap");
- assertThat(Artifact.toExecPaths(provider.get(MODULE_MAP)))
+ assertThat(Artifact.asExecPaths(provider.get(MODULE_MAP)))
.containsExactly("y/module.modulemap");
provider = providerForTarget("//x:x");
- assertThat(Artifact.toExecPaths(provider.get(MODULE_MAP))).contains("y/module.modulemap");
+ assertThat(Artifact.asExecPaths(provider.get(MODULE_MAP))).contains("y/module.modulemap");
}
/**
@@ -1912,7 +1912,7 @@
@Nullable
protected Artifact getSingleArchBinaryIfAvailable(Action lipoAction, String arch) {
- for (Artifact archBinary : lipoAction.getInputs()) {
+ for (Artifact archBinary : lipoAction.getInputs().toList()) {
String execPath = archBinary.getExecPathString();
if (execPath.endsWith("_bin") && execPath.contains(arch)) {
return archBinary;
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcSkylarkTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcSkylarkTest.java
index b0f290d..49b5019 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcSkylarkTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcSkylarkTest.java
@@ -24,6 +24,7 @@
import com.google.devtools.build.lib.actions.util.ActionsTestUtil;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.cmdline.Label;
+import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.packages.Provider;
import com.google.devtools.build.lib.packages.SkylarkInfo;
import com.google.devtools.build.lib.packages.SkylarkProvider;
@@ -174,7 +175,7 @@
StructImpl myInfo = getMyInfoFromTarget(skylarkTarget);
Depset defineSet = (Depset) myInfo.getValue("define");
- assertThat(defineSet.getSet(String.class)).containsExactly("mock_define");
+ assertThat(defineSet.getSet(String.class).toList()).containsExactly("mock_define");
}
@Test
@@ -303,7 +304,7 @@
assertThat(Artifact.toRootRelativePaths(objcProvider.get(ObjcProvider.LIBRARY)))
.contains("examples/apple_skylark/liblib.a");
- assertThat(objcProvider.get(ObjcProvider.DEFINE)).contains("mock_define");
+ assertThat(objcProvider.get(ObjcProvider.DEFINE).toList()).contains("mock_define");
}
@Test
@@ -341,7 +342,7 @@
binaryTarget.get(AppleExecutableBinaryInfo.SKYLARK_CONSTRUCTOR);
ObjcProvider objcProvider = executableProvider.getDepsObjcProvider();
- assertThat(objcProvider.get(ObjcProvider.DEFINE)).contains("mock_define");
+ assertThat(objcProvider.get(ObjcProvider.DEFINE).toList()).contains("mock_define");
}
@Test
@@ -921,9 +922,9 @@
" return [created_provider]");
Iterable<String> foundLinkopts =
- skylarkTarget.get(ObjcProvider.SKYLARK_CONSTRUCTOR).get(ObjcProvider.LINKOPT);
+ skylarkTarget.get(ObjcProvider.SKYLARK_CONSTRUCTOR).get(ObjcProvider.LINKOPT).toList();
Iterable<String> foundDefines =
- skylarkTarget.get(ObjcProvider.SKYLARK_CONSTRUCTOR).get(ObjcProvider.DEFINE);
+ skylarkTarget.get(ObjcProvider.SKYLARK_CONSTRUCTOR).get(ObjcProvider.DEFINE).toList();
boolean usesSwift =
skylarkTarget.get(ObjcProvider.SKYLARK_CONSTRUCTOR).is(ObjcProvider.Flag.USES_SWIFT);
@@ -943,7 +944,7 @@
"(link_inputs=link_inputs)",
" return [created_provider]");
- Iterable<Artifact> foundLinkInputs =
+ NestedSet<Artifact> foundLinkInputs =
skylarkTarget.get(ObjcProvider.SKYLARK_CONSTRUCTOR).get(ObjcProvider.LINK_INPUTS);
assertThat(ActionsTestUtil.baseArtifactNames(foundLinkInputs)).contains("foo.ast");
}
@@ -971,7 +972,7 @@
" return [created_provider]");
Iterable<PathFragment> foundIncludes =
- skylarkTarget.get(ObjcProvider.SKYLARK_CONSTRUCTOR).get(ObjcProvider.INCLUDE);
+ skylarkTarget.get(ObjcProvider.SKYLARK_CONSTRUCTOR).get(ObjcProvider.INCLUDE).toList();
assertThat(foundIncludes)
.containsExactly(
@@ -998,11 +999,11 @@
ObjcProvider skylarkProviderIndirectDepender =
objcProviderBuilder().addTransitiveAndPropagate(skylarkProviderDirectDepender).build();
- assertThat(skylarkProvider.get(ObjcProvider.INCLUDE))
+ assertThat(skylarkProvider.get(ObjcProvider.INCLUDE).toList())
.containsExactly(PathFragment.create("path1"), PathFragment.create("path2"));
- assertThat(skylarkProviderDirectDepender.get(ObjcProvider.INCLUDE))
+ assertThat(skylarkProviderDirectDepender.get(ObjcProvider.INCLUDE).toList())
.containsExactly(PathFragment.create("path1"), PathFragment.create("path2"));
- assertThat(skylarkProviderIndirectDepender.get(ObjcProvider.INCLUDE))
+ assertThat(skylarkProviderIndirectDepender.get(ObjcProvider.INCLUDE).toList())
.containsExactly(PathFragment.create("path2"));
}
@@ -1017,7 +1018,7 @@
" return [created_provider]");
Iterable<String> foundStrings =
- skylarkTarget.get(ObjcProvider.SKYLARK_CONSTRUCTOR).get(ObjcProvider.DEFINE);
+ skylarkTarget.get(ObjcProvider.SKYLARK_CONSTRUCTOR).get(ObjcProvider.DEFINE).toList();
assertThat(foundStrings).containsExactly("define_from_dep", "define_from_impl");
}
@@ -1459,8 +1460,8 @@
ObjcProvider objc = framework.get(ObjcProvider.SKYLARK_CONSTRUCTOR);
assertThat(Artifact.toRootRelativePaths(objc.staticFrameworkFile()))
.containsExactly("fx/fx1.framework/fx1", "fx/fx2.framework/fx2");
- assertThat(objc.staticFrameworkNames()).containsExactly("fx1", "fx2");
- assertThat(objc.staticFrameworkPaths()).containsExactly("fx");
+ assertThat(objc.staticFrameworkNames().toList()).containsExactly("fx1", "fx2");
+ assertThat(objc.staticFrameworkPaths().toList()).containsExactly("fx");
}
@Test
@@ -1488,7 +1489,7 @@
ObjcProvider objc = framework.get(ObjcProvider.SKYLARK_CONSTRUCTOR);
assertThat(Artifact.toRootRelativePaths(objc.dynamicFrameworkFile()))
.containsExactly("fx/fx1.framework/fx1", "fx/fx2.framework/fx2");
- assertThat(objc.dynamicFrameworkNames()).containsExactly("fx1", "fx2");
- assertThat(objc.dynamicFrameworkPaths()).containsExactly("fx");
+ assertThat(objc.dynamicFrameworkNames().toList()).containsExactly("fx1", "fx2");
+ assertThat(objc.dynamicFrameworkPaths().toList()).containsExactly("fx");
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/rules/python/PyBinaryConfiguredTargetTest.java b/src/test/java/com/google/devtools/build/lib/rules/python/PyBinaryConfiguredTargetTest.java
index ca2a0b9..088be37 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/python/PyBinaryConfiguredTargetTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/python/PyBinaryConfiguredTargetTest.java
@@ -107,7 +107,7 @@
" srcs = ['foo.py'])");
ConfiguredTarget target = getOkPyTarget("//pkg:foo");
FileConfiguredTarget srcFile = getFileConfiguredTarget("//pkg:foo.py");
- assertThat(getFilesToBuild(target))
+ assertThat(getFilesToBuild(target).toList())
.containsExactly(getExecutable(target), srcFile.getArtifact());
assertThat(getExecutable(target).getExecPath().getPathString())
.containsMatch(TestConstants.PRODUCT_NAME + "-out/.*/bin/pkg/foo");
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java b/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java
index 89f548d..f9e8d32 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java
@@ -489,8 +489,7 @@
ActionResult actionResult = super.execute(actionExecutionContext);
try {
FileSystemUtils.copyFile(
- Iterables.getOnlyElement(getInputs()).getPath(),
- Iterables.getOnlyElement(getOutputs()).getPath());
+ getInputs().getSingleton().getPath(), Iterables.getOnlyElement(getOutputs()).getPath());
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/src/test/java/com/google/devtools/build/lib/testutil/UnknownRuleConfiguredTarget.java b/src/test/java/com/google/devtools/build/lib/testutil/UnknownRuleConfiguredTarget.java
index f0cfb95..33b0fae 100644
--- a/src/test/java/com/google/devtools/build/lib/testutil/UnknownRuleConfiguredTarget.java
+++ b/src/test/java/com/google/devtools/build/lib/testutil/UnknownRuleConfiguredTarget.java
@@ -51,8 +51,11 @@
}
Rule rule = context.getRule();
- context.registerAction(new FailAction(context.getActionOwner(),
- filesToBuild, "cannot build " + rule.getRuleClass() + " rules such as " + rule.getLabel()));
+ context.registerAction(
+ new FailAction(
+ context.getActionOwner(),
+ filesToBuild.toList(),
+ "cannot build " + rule.getRuleClass() + " rules such as " + rule.getLabel()));
return new RuleConfiguredTargetBuilder(context)
.setFilesToBuild(filesToBuild)
.add(RunfilesProvider.class, RunfilesProvider.simple(Runfiles.EMPTY))