Allows symlink tree actions to construct fileset links without consuming the input manifest. Instead, construct the links directly from the Fileset links propagated through the action execution values.
PiperOrigin-RevId: 292183775
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/actions/SymlinkTreeActionTest.java b/src/test/java/com/google/devtools/build/lib/analysis/actions/SymlinkTreeActionTest.java
index 1b01f43..24a70d7 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/actions/SymlinkTreeActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/actions/SymlinkTreeActionTest.java
@@ -69,7 +69,7 @@
? new Runfiles.Builder("TESTING", false).addArtifact(runfile).build()
: new Runfiles.Builder("TESTING", false).addArtifact(runfile2).build(),
outputManifest,
- /*filesetTree=*/ false,
+ /*filesetRoot=*/ null,
createActionEnvironment(
attributesToFlip.contains(RunfilesActionAttributes.FIXED_ENVIRONMENT),
attributesToFlip.contains(RunfilesActionAttributes.VARIABLE_ENVIRONMENT)),
@@ -84,7 +84,7 @@
inputManifest,
/*runfiles=*/ null,
outputManifest,
- /*filesetTree=*/ true,
+ /*filesetRoot=*/ "root",
createActionEnvironment(
attributesToFlip.contains(FilesetActionAttributes.FIXED_ENVIRONMENT),
attributesToFlip.contains(FilesetActionAttributes.VARIABLE_ENVIRONMENT)),
@@ -102,7 +102,7 @@
? new Runfiles.Builder("TESTING", false).addArtifact(runfile).build()
: new Runfiles.Builder("TESTING", false).addArtifact(runfile2).build(),
outputManifest,
- /*filesetTree=*/ false,
+ /*filesetRoot=*/ null,
createActionEnvironment(
attributesToFlip.contains(SkipManifestAttributes.FIXED_ENVIRONMENT),
attributesToFlip.contains(SkipManifestAttributes.VARIABLE_ENVIRONMENT)),
@@ -130,7 +130,7 @@
inputManifest,
/*runfiles=*/ null,
outputManifest,
- /*filesetTree=*/ false,
+ /*filesetRoot=*/ null,
createActionEnvironment(false, false),
/*enableRunfiles=*/ true,
/*inprocessSymlinkCreation=*/ false,
diff --git a/src/test/java/com/google/devtools/build/lib/exec/SymlinkTreeHelperTest.java b/src/test/java/com/google/devtools/build/lib/exec/SymlinkTreeHelperTest.java
index 8e81445..e510e4e 100644
--- a/src/test/java/com/google/devtools/build/lib/exec/SymlinkTreeHelperTest.java
+++ b/src/test/java/com/google/devtools/build/lib/exec/SymlinkTreeHelperTest.java
@@ -15,18 +15,16 @@
package com.google.devtools.build.lib.exec;
import static com.google.common.truth.Truth.assertThat;
-import static com.google.devtools.build.lib.testutil.MoreAsserts.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import com.google.devtools.build.lib.actions.FilesetOutputSymlink;
+import com.google.devtools.build.lib.actions.HasDigest;
import com.google.devtools.build.lib.shell.Command;
import com.google.devtools.build.lib.vfs.FileSystem;
-import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem;
-import java.io.FileNotFoundException;
-import java.io.IOException;
import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -56,50 +54,53 @@
}
@Test
- public void readManifest() throws Exception {
- Path execRoot = fs.getPath("/my/workspace");
- execRoot.createDirectoryAndParents();
- Path inputManifestPath = execRoot.getRelative("input_manifest");
- FileSystemUtils.writeContentAsLatin1(inputManifestPath, "from to\nmetadata");
+ public void readManifest() {
+ PathFragment execRoot = PathFragment.create("/my/workspace");
+
+ FilesetOutputSymlink link =
+ FilesetOutputSymlink.createForTesting(
+ PathFragment.create("from"), PathFragment.create("to"), execRoot);
+
Map<PathFragment, PathFragment> symlinks =
- SymlinkTreeHelper.readSymlinksFromFilesetManifest(inputManifestPath);
- assertThat(symlinks).containsExactly(PathFragment.create("from"), PathFragment.create("to"));
+ SymlinkTreeHelper.processFilesetLinks(
+ ImmutableList.of(link), PathFragment.create("root"), execRoot);
+ assertThat(symlinks)
+ .containsExactly(PathFragment.create("root/from"), PathFragment.create("to"));
}
@Test
- public void readMultilineManifest() throws Exception {
- Path execRoot = fs.getPath("/my/workspace");
- execRoot.createDirectoryAndParents();
- Path inputManifestPath = execRoot.getRelative("input_manifest");
- FileSystemUtils.writeContentAsLatin1(
- inputManifestPath, "from to\nmetadata\n/foo /bar\nmetadata");
+ public void readMultilineManifest() {
+ PathFragment execRoot = PathFragment.create("/my/workspace");
+
+ FilesetOutputSymlink link1 =
+ FilesetOutputSymlink.createForTesting(
+ PathFragment.create("from"), PathFragment.create("to"), execRoot);
+ FilesetOutputSymlink link2 =
+ FilesetOutputSymlink.createForTesting(
+ PathFragment.create("foo"), PathFragment.create("/bar"), execRoot);
+ FilesetOutputSymlink link3 =
+ FilesetOutputSymlink.createAlreadyRelativized(
+ PathFragment.create("rel"), PathFragment.create("path"), HasDigest.EMPTY, true, true);
+ FilesetOutputSymlink link4 =
+ FilesetOutputSymlink.createAlreadyRelativized(
+ PathFragment.create("rel2"),
+ PathFragment.create("/path"),
+ HasDigest.EMPTY,
+ false,
+ false);
+
Map<PathFragment, PathFragment> symlinks =
- SymlinkTreeHelper.readSymlinksFromFilesetManifest(inputManifestPath);
+ SymlinkTreeHelper.processFilesetLinks(
+ ImmutableList.of(link1, link2, link3, link4), PathFragment.create("root2"), execRoot);
assertThat(symlinks)
.containsExactly(
- PathFragment.create("from"),
+ PathFragment.create("root2/from"),
PathFragment.create("to"),
- PathFragment.create("/foo"),
- PathFragment.create("/bar"));
- }
-
- @Test
- public void readCorruptManifest() throws Exception {
- Path execRoot = fs.getPath("/my/workspace");
- execRoot.createDirectoryAndParents();
- Path inputManifestPath = execRoot.getRelative("input_manifest");
- FileSystemUtils.writeContentAsLatin1(inputManifestPath, "from to");
- assertThrows(
- IOException.class,
- () -> SymlinkTreeHelper.readSymlinksFromFilesetManifest(inputManifestPath));
- }
-
- @Test
- public void readNonExistentManifestFails() {
- Path execRoot = fs.getPath("/my/workspace");
- Path inputManifestPath = execRoot.getRelative("input_manifest");
- assertThrows(
- FileNotFoundException.class,
- () -> SymlinkTreeHelper.readSymlinksFromFilesetManifest(inputManifestPath));
+ PathFragment.create("root2/foo"),
+ PathFragment.create("/bar"),
+ PathFragment.create("root2/rel"),
+ execRoot.getRelative("path"),
+ PathFragment.create("root2/rel2"),
+ PathFragment.create("/path"));
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/exec/SymlinkTreeStrategyTest.java b/src/test/java/com/google/devtools/build/lib/exec/SymlinkTreeStrategyTest.java
index c50c7f6..839a4bb 100644
--- a/src/test/java/com/google/devtools/build/lib/exec/SymlinkTreeStrategyTest.java
+++ b/src/test/java/com/google/devtools/build/lib/exec/SymlinkTreeStrategyTest.java
@@ -92,7 +92,7 @@
inputManifest,
runfiles,
outputManifest,
- /*filesetTree=*/ false,
+ /*filesetRoot=*/ null,
ActionEnvironment.EMPTY,
/*enableRunfiles=*/ true,
/*inprocessSymlinkCreation=*/ false,
@@ -138,7 +138,7 @@
inputManifest,
runfiles,
outputManifest,
- /*filesetTree=*/ false,
+ /*filesetRoot=*/ null,
ActionEnvironment.EMPTY,
/*enableRunfiles=*/ true,
/*inprocessSymlinkCreation=*/ true,