aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar ulfjack <ulfjack@google.com>2018-05-30 03:25:35 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-05-30 03:26:44 -0700
commit1973be49ca38a17e5272e8af1d0ba6b00e442d1f (patch)
tree2d34125a305948fc24293f53a8d3047b5f18a5ad /src/test/java/com/google/devtools/build
parent22f4bb9afa6a8454a15fbd21edbb69c4518fbbf2 (diff)
Allow passing the relative symlink resolution policy to the SpawnInputExpander
PiperOrigin-RevId: 198535546
Diffstat (limited to 'src/test/java/com/google/devtools/build')
-rw-r--r--src/test/java/com/google/devtools/build/lib/exec/FilesetManifestTest.java2
-rw-r--r--src/test/java/com/google/devtools/build/lib/exec/SpawnInputExpanderTest.java51
2 files changed, 52 insertions, 1 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/exec/FilesetManifestTest.java b/src/test/java/com/google/devtools/build/lib/exec/FilesetManifestTest.java
index 391cd16d41..36fb420265 100644
--- a/src/test/java/com/google/devtools/build/lib/exec/FilesetManifestTest.java
+++ b/src/test/java/com/google/devtools/build/lib/exec/FilesetManifestTest.java
@@ -280,7 +280,7 @@ public class FilesetManifestTest {
assertThat(e).hasMessageThat()
.isEqualTo(
"runfiles target 'foo' is not absolute, and could not be resolved in the same "
- + "Fileset");
+ + "Fileset");
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/exec/SpawnInputExpanderTest.java b/src/test/java/com/google/devtools/build/lib/exec/SpawnInputExpanderTest.java
index f875251370..211dbe911b 100644
--- a/src/test/java/com/google/devtools/build/lib/exec/SpawnInputExpanderTest.java
+++ b/src/test/java/com/google/devtools/build/lib/exec/SpawnInputExpanderTest.java
@@ -14,14 +14,20 @@
package com.google.devtools.build.lib.exec;
import static com.google.common.truth.Truth.assertThat;
+import static com.google.devtools.build.lib.exec.FilesetManifest.RelativeSymlinkBehavior.ERROR;
+import static com.google.devtools.build.lib.exec.FilesetManifest.RelativeSymlinkBehavior.IGNORE;
+import static com.google.devtools.build.lib.exec.FilesetManifest.RelativeSymlinkBehavior.RESOLVE;
import static org.junit.Assert.fail;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
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.ArtifactRoot;
import com.google.devtools.build.lib.actions.EmptyRunfilesSupplier;
+import com.google.devtools.build.lib.actions.FilesetOutputSymlink;
import com.google.devtools.build.lib.actions.RunfilesSupplier;
import com.google.devtools.build.lib.analysis.Runfiles;
import com.google.devtools.build.lib.analysis.RunfilesSupplierImpl;
@@ -35,6 +41,7 @@ import com.google.devtools.build.lib.vfs.Root;
import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
@@ -262,4 +269,48 @@ public class SpawnInputExpanderTest {
.containsEntry(
PathFragment.create("out/foo/bar"), ActionInputHelper.fromPath("/some"));
}
+
+ private FilesetOutputSymlink filesetSymlink(String from, String to) {
+ return new FilesetOutputSymlink(PathFragment.create(from), PathFragment.create(to));
+ }
+
+ private ImmutableMap<PathFragment, ImmutableList<FilesetOutputSymlink>> simpleFilesetManifest() {
+ return ImmutableMap.of(
+ PathFragment.create("out"),
+ ImmutableList.of(
+ filesetSymlink("workspace/bar", "foo"),
+ filesetSymlink("workspace/foo", "/foo/bar")));
+ }
+
+ @Test
+ public void testManifestWithErrorOnRelativeSymlink() throws Exception {
+ expander = new SpawnInputExpander(execRoot, /*strict=*/ true, ERROR);
+ try {
+ expander.addFilesetManifests(simpleFilesetManifest(), new HashMap<>());
+ fail();
+ } catch (IOException e) {
+ assertThat(e).hasMessageThat().contains("runfiles target is not absolute: foo");
+ }
+ }
+
+ @Test
+ public void testManifestWithIgnoredRelativeSymlink() throws Exception {
+ expander = new SpawnInputExpander(execRoot, /*strict=*/ true, IGNORE);
+ Map<PathFragment, ActionInput> entries = new HashMap<>();
+ expander.addFilesetManifests(simpleFilesetManifest(), entries);
+ assertThat(entries)
+ .containsExactly(
+ PathFragment.create("out/workspace/foo"), ActionInputHelper.fromPath("/foo/bar"));
+ }
+
+ @Test
+ public void testManifestWithResolvedRelativeSymlink() throws Exception {
+ expander = new SpawnInputExpander(execRoot, /*strict=*/ true, RESOLVE);
+ Map<PathFragment, ActionInput> entries = new HashMap<>();
+ expander.addFilesetManifests(simpleFilesetManifest(), entries);
+ assertThat(entries)
+ .containsExactly(
+ PathFragment.create("out/workspace/bar"), ActionInputHelper.fromPath("/foo/bar"),
+ PathFragment.create("out/workspace/foo"), ActionInputHelper.fromPath("/foo/bar"));
+ }
}