diff options
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/exec/FilesetManifestTest.java | 44 |
1 files changed, 43 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 73a4a3b226..fc13b44653 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 @@ -50,7 +50,7 @@ public class FilesetManifestTest { private void scratchFile(String file, String... lines) throws Exception { Path path = fs.getPath(file); - FileSystemUtils.createDirectoryAndParents(path.getParentDirectory()); + path.getParentDirectory().createDirectoryAndParents(); FileSystemUtils.writeLinesAs(path, StandardCharsets.UTF_8, lines); } @@ -221,6 +221,48 @@ public class FilesetManifestTest { } @Test + public void testManifestWithResolvedRelativeSymlinkWithDotSlash() throws Exception { + // See AnalysisUtils for the mapping from "foo" to "_foo/MANIFEST". + scratchFile( + "/root/out/_foo/MANIFEST", + "workspace/bar ./foo", + "<some digest>", + "workspace/foo /foo/bar", + "<some digest>"); + + ArtifactRoot outputRoot = + ArtifactRoot.asDerivedRoot(fs.getPath("/root"), fs.getPath("/root/out")); + Artifact artifact = new Artifact(fs.getPath("/root/out/foo"), outputRoot); + FilesetManifest manifest = + FilesetManifest.parseManifestFile(artifact, execRoot, "workspace", RESOLVE); + assertThat(manifest.getEntries()) + .containsExactly( + PathFragment.create("out/foo/bar"), "/foo/bar", + PathFragment.create("out/foo/foo"), "/foo/bar"); + } + + @Test + public void testManifestWithResolvedRelativeSymlinkWithDotDotSlash() throws Exception { + // See AnalysisUtils for the mapping from "foo" to "_foo/MANIFEST". + scratchFile( + "/root/out/_foo/MANIFEST", + "workspace/bar/bar ../foo/foo", + "<some digest>", + "workspace/foo/foo /foo/bar", + "<some digest>"); + + ArtifactRoot outputRoot = + ArtifactRoot.asDerivedRoot(fs.getPath("/root"), fs.getPath("/root/out")); + Artifact artifact = new Artifact(fs.getPath("/root/out/foo"), outputRoot); + FilesetManifest manifest = + FilesetManifest.parseManifestFile(artifact, execRoot, "workspace", RESOLVE); + assertThat(manifest.getEntries()) + .containsExactly( + PathFragment.create("out/foo/bar/bar"), "/foo/bar", + PathFragment.create("out/foo/foo/foo"), "/foo/bar"); + } + + @Test public void testManifestWithUnresolvableRelativeSymlink() throws Exception { // See AnalysisUtils for the mapping from "foo" to "_foo/MANIFEST". scratchFile( |