aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java
diff options
context:
space:
mode:
authorGravatar Nathan Harmata <nharmata@google.com>2015-09-15 14:16:10 +0000
committerGravatar John Field <jfield@google.com>2015-09-15 20:28:00 +0000
commitd927e4d5c047d4966c03d00efd7af5ed343ce015 (patch)
tree9d2d3dd2fe3d8da70b144d3ca046199387907218 /src/test/java
parent4f7288ede042b1e9e01b196de56ee16fec7b1440 (diff)
Add a test for FileSystem#resolveSymbolicLinks for dangling symlinks.
-- MOS_MIGRATED_REVID=103090211
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/vfs/FileSystemTest.java21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/FileSystemTest.java b/src/test/java/com/google/devtools/build/lib/vfs/FileSystemTest.java
index 599c767984..7fcc8e218d 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/FileSystemTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/FileSystemTest.java
@@ -54,6 +54,7 @@ public abstract class FileSystemTest {
// Some useful examples of various kinds of files (mnemonic: "x" = "eXample")
protected Path xNothing;
+ protected Path xLink;
protected Path xFile;
protected Path xNonEmptyDirectory;
protected Path xNonEmptyDirectoryFoo;
@@ -73,6 +74,7 @@ public abstract class FileSystemTest {
// drwxrwxr-x xEmptyDirectory
xNothing = absolutize("xNothing");
+ xLink = absolutize("xLink");
xFile = absolutize("xFile");
xNonEmptyDirectory = absolutize("xNonEmptyDirectory");
xNonEmptyDirectoryFoo = xNonEmptyDirectory.getChild("foo");
@@ -1331,10 +1333,23 @@ public abstract class FileSystemTest {
@Test
public void testResolveSymlinks() throws Exception {
if (supportsSymlinks) {
- createSymbolicLink(xNothing, xFile);
+ createSymbolicLink(xLink, xFile);
FileSystemUtils.createEmptyFile(xFile);
- assertEquals(xFile.asFragment(), testFS.resolveOneLink(xNothing));
- assertEquals(xFile, xNothing.resolveSymbolicLinks());
+ assertEquals(xFile.asFragment(), testFS.resolveOneLink(xLink));
+ assertEquals(xFile, xLink.resolveSymbolicLinks());
+ }
+ }
+
+ @Test
+ public void testResolveDanglingSymlinks() throws Exception {
+ if (supportsSymlinks) {
+ createSymbolicLink(xLink, xNothing);
+ assertEquals(xNothing.asFragment(), testFS.resolveOneLink(xLink));
+ try {
+ xLink.resolveSymbolicLinks();
+ fail();
+ } catch (IOException expected) {
+ }
}
}