diff options
author | 2018-02-20 05:12:44 -0800 | |
---|---|---|
committer | 2018-02-20 05:14:35 -0800 | |
commit | ba2739462911b85a600e8eaffbdb9336d23ae6d8 (patch) | |
tree | bfe035a7fae3f1728e88a0d7afe6ef34e4edeb29 /src | |
parent | 053dfd1822727a18cecaaee924a36f537b2463b2 (diff) |
Add additional tests for Filesets with symlinks
- Make sure that we correctly resolve symlinks starting with ./ and ../. This
is currently failing, although it's working at head.
From my reading, https://github.com/bazelbuild/bazel/commit/a729b9b4c3d7844a7d44934bf3365f92633c0a60 changes PathFragment.getRelative to always
normalize the return value, which it wasn't doing before.
PiperOrigin-RevId: 186289431
Diffstat (limited to 'src')
-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( |