aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/analysis/RunfilesSupplierImplTest.java
diff options
context:
space:
mode:
authorGravatar Michajlo Matijkiw <michajlo@google.com>2017-01-27 19:30:34 +0000
committerGravatar Yun Peng <pcloudy@google.com>2017-01-30 09:01:24 +0000
commit4a877386b0d647885dbba48714d1be36a36362f4 (patch)
treef629b9892f5afb7efb2ac37e2817fa87dade3e65 /src/test/java/com/google/devtools/build/lib/analysis/RunfilesSupplierImplTest.java
parentd7e965a3676026d09bb5450425792571aa257a00 (diff)
Switch to RunfilesSuppliers for communicating runfiles
ActionSpawn/SpawnAction now deal exclusively in RunfilesSuppliers, manifests maps are no more. There is some lingering awkwardness, in particular: - Manifests still need to be tracked in some places, we can work out if this is still necessary on a case by case basis. - Skylark makes actions' runfiles available via 'resolve_command' where they are consumed by 'action'. I've updated the documentation, though the name isn't entirely accurate anymore. That being said these interfaces _are_ marked as experimental, so we _should_ be able to be flexible here. Overall, I think the benefits consolidating runfiles into suppliers, from both code cleanliness and performance perspectives (no longer needing to parse manifests), outweights the awkwardnesses. RELNOTES: resolve_command/action's input_manifest return/parameter is now list -- PiperOrigin-RevId: 145817429 MOS_MIGRATED_REVID=145817429
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/analysis/RunfilesSupplierImplTest.java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/RunfilesSupplierImplTest.java43
1 files changed, 21 insertions, 22 deletions
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 70024c460e..0234699c28 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
@@ -17,7 +17,6 @@ package com.google.devtools.build.lib.analysis;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.Root;
@@ -25,15 +24,13 @@ import com.google.devtools.build.lib.actions.RunfilesSupplier;
import com.google.devtools.build.lib.testutil.Scratch;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
-
+import java.io.IOException;
+import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
-import java.io.IOException;
-import java.util.List;
-
/** Tests for RunfilesSupplierImpl */
@RunWith(JUnit4.class)
public class RunfilesSupplierImplTest {
@@ -54,37 +51,39 @@ public class RunfilesSupplierImplTest {
public void testGetArtifactsWithSingleMapping() {
List<Artifact> artifacts = mkArtifacts(rootDir, "thing1", "thing2");
- RunfilesSupplierImpl underTest = new RunfilesSupplierImpl(
- ImmutableMap.of(new PathFragment("notimportant"), mkRunfiles(artifacts)));
+ RunfilesSupplierImpl underTest =
+ new RunfilesSupplierImpl(new PathFragment("notimportant"), mkRunfiles(artifacts));
assertThat(underTest.getArtifacts()).containsExactlyElementsIn(artifacts);
}
@Test
- public void testGetArtifactsWithMultipleMappings() {
- List<Artifact> artifacts1 = mkArtifacts(rootDir, "thing_1", "thing_2", "duplicated");
- List<Artifact> artifacts2 = mkArtifacts(rootDir, "thing_3", "thing_4", "duplicated");
-
- RunfilesSupplierImpl underTest = new RunfilesSupplierImpl(ImmutableMap.of(
- new PathFragment("notimportant"), mkRunfiles(artifacts1),
- new PathFragment("stillnotimportant"), mkRunfiles(artifacts2)));
-
- assertThat(underTest.getArtifacts()).containsExactlyElementsIn(
- mkArtifacts(rootDir, "thing_1", "thing_2", "thing_3", "thing_4", "duplicated"));
- }
-
- @Test
public void testGetArtifactsFilterMiddlemen() {
List<Artifact> artifacts = mkArtifacts(rootDir, "thing1", "thing2");
Artifact middleman = new Artifact(new PathFragment("middleman"), middlemanRoot);
Runfiles runfiles = mkRunfiles(Iterables.concat(artifacts, ImmutableList.of(middleman)));
- RunfilesSupplier underTest = new RunfilesSupplierImpl(
- ImmutableMap.of(new PathFragment("notimportant"), runfiles));
+ RunfilesSupplier underTest =
+ new RunfilesSupplierImpl(new PathFragment("notimportant"), runfiles);
assertThat(underTest.getArtifacts()).containsExactlyElementsIn(artifacts);
}
+ @Test
+ public void testGetManifestsWhenNone() {
+ RunfilesSupplier underTest =
+ new RunfilesSupplierImpl(new PathFragment("ignored"), Runfiles.EMPTY, null);
+ assertThat(underTest.getManifests()).isEmpty();
+ }
+
+ @Test
+ public void testGetManifestsWhenSupplied() {
+ Artifact manifest = new Artifact(new PathFragment("manifest"), rootDir);
+ RunfilesSupplier underTest =
+ new RunfilesSupplierImpl(new PathFragment("ignored"), Runfiles.EMPTY, manifest);
+ assertThat(underTest.getManifests()).containsExactly(manifest);
+ }
+
private static Runfiles mkRunfiles(Iterable<Artifact> artifacts) {
return new Runfiles.Builder("TESTING", false).addArtifacts(artifacts).build();
}