Allow tests to specify fileset mappings via SpawnBuilder
RELNOTES: None.
@@ -21,6 +21,7 @@ import com.google.devtools.build.lib.actions.ActionInput;
import com.google.devtools.build.lib.actions.ActionInputHelper;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.EmptyRunfilesSupplier;
+import com.google.devtools.build.lib.actions.FilesetOutputSymlink;
import com.google.devtools.build.lib.actions.ResourceSet;
import com.google.devtools.build.lib.actions.SimpleSpawn;
import com.google.devtools.build.lib.actions.Spawn;
@@ -42,6 +43,8 @@ public final class SpawnBuilder {
private final Map<String, String> executionInfo = new HashMap<>();
private final List<ActionInput> inputs = new ArrayList<>();
private final List<ActionInput> outputs = new ArrayList<>();
+ private final Map<Artifact, ImmutableList<FilesetOutputSymlink>> filesetMappings =
+ new HashMap<>();
public SpawnBuilder(String... args) {
this.args = ImmutableList.copyOf(args);
@@ -55,7 +58,7 @@ public final class SpawnBuilder {
ImmutableMap.copyOf(environment),
ImmutableMap.copyOf(executionInfo),
/*runfilesSupplier=*/ EmptyRunfilesSupplier.INSTANCE,
- ImmutableMap.of(),
+ ImmutableMap.copyOf(filesetMappings),
ImmutableList.copyOf(inputs),
/*tools=*/ ImmutableList.<Artifact>of(),
ImmutableList.copyOf(outputs),
@@ -115,4 +118,11 @@ public final class SpawnBuilder {
}
return this;
}
+
+ public SpawnBuilder withFilesetMapping(
+ Artifact fileset, ImmutableList<FilesetOutputSymlink> mappings) {
+ Preconditions.checkArgument(fileset.isFileset(), "Artifact %s is not fileset", fileset);
+ filesetMappings.put(fileset, mappings);
+ return this;
+ }
}
