diff options
author | Han-Wen Nienhuys <hanwen@google.com> | 2015-08-13 16:20:32 +0000 |
---|---|---|
committer | Philipp Wollermann <philwo@google.com> | 2015-08-14 20:06:45 +0000 |
commit | ce408291c8f378e0bf15c8a0556d5dcd9b9846af (patch) | |
tree | fbdc63b85c656496bd7d9fadaf43d10abc8f00ac /src/test/java/com/google | |
parent | d655f2a2870af33f0be3994a983d779e4ad1fb15 (diff) |
Do not assume a specific layout of root dir on the system.
Fixes #375
--
MOS_MIGRATED_REVID=100581187
Diffstat (limited to 'src/test/java/com/google')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/vfs/SymlinkAwareFileSystemTest.java | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/SymlinkAwareFileSystemTest.java b/src/test/java/com/google/devtools/build/lib/vfs/SymlinkAwareFileSystemTest.java index e48a5dd010..67c885d480 100644 --- a/src/test/java/com/google/devtools/build/lib/vfs/SymlinkAwareFileSystemTest.java +++ b/src/test/java/com/google/devtools/build/lib/vfs/SymlinkAwareFileSystemTest.java @@ -14,11 +14,7 @@ package com.google.devtools.build.lib.vfs; import static com.google.common.truth.Truth.assertThat; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.Assert.*; import com.google.devtools.build.lib.testutil.MoreAsserts; import com.google.devtools.build.lib.vfs.FileSystem.NotASymlinkException; @@ -216,6 +212,13 @@ public abstract class SymlinkAwareFileSystemTest extends FileSystemTest { @Test public void testLinkToRootResolvesCorrectly() throws IOException { Path rootPath = testFS.getPath("/"); + + try { + rootPath.getChild("testDir").createDirectory(); + } catch (IOException e) { + // Do nothing. This is a real FS, and we don't have permission. + } + Path linkPath = absolutize("link"); createSymbolicLink(linkPath, rootPath); @@ -226,11 +229,17 @@ public abstract class SymlinkAwareFileSystemTest extends FileSystemTest { } catch (FileNotFoundException e) { /* ok */ } // The path may not be a symlink, neither on Darwin nor on Linux. - Path rootChild = testFS.getPath("/sbin"); - if (!rootChild.isDirectory()) { - rootChild.createDirectory(); + String nonLinkEntry = null; + for (Path p : testFS.getDirectoryEntries(rootPath)) { + if (!p.isSymbolicLink() && p.isDirectory()) { + nonLinkEntry = p.getBaseName(); + break; + } } - assertEquals(rootChild, linkPath.getRelative("sbin").resolveSymbolicLinks()); + + assertNotNull(nonLinkEntry); + Path rootChild = testFS.getPath("/" + nonLinkEntry); + assertEquals(rootChild, linkPath.getRelative(nonLinkEntry).resolveSymbolicLinks()); } @Test |