diff options
author | 2015-10-20 21:54:34 +0000 | |
---|---|---|
committer | 2015-10-21 14:39:08 +0000 | |
commit | d8b6ff2dad1de2d98a407ecf67a34fe12e67d494 (patch) | |
tree | 030c5ebb89ca5835e76854ed51c0d2a75b04e4e3 /src/test/java/com/google | |
parent | 11ef8fc44821fb593a512eb5a3423013abbe39aa (diff) |
Introduce Path#isSpecialFile, FileSystem#isSpecialFile, and FileStatus#isSpecialFile to help disambiguate between a regular file and a special file, since the file size of a special file cannot be trusted.
--
MOS_MIGRATED_REVID=105903622
Diffstat (limited to 'src/test/java/com/google')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/vfs/ScopeEscapableFileSystemTest.java | 1 | ||||
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/vfs/UnixFileSystemTest.java | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/ScopeEscapableFileSystemTest.java b/src/test/java/com/google/devtools/build/lib/vfs/ScopeEscapableFileSystemTest.java index 719ffde41c..87c4cce17a 100644 --- a/src/test/java/com/google/devtools/build/lib/vfs/ScopeEscapableFileSystemTest.java +++ b/src/test/java/com/google/devtools/build/lib/vfs/ScopeEscapableFileSystemTest.java @@ -85,6 +85,7 @@ public abstract class ScopeEscapableFileSystemTest extends SymlinkAwareFileSyste @Override protected boolean isWritable(Path path) { throw re(); } @Override protected boolean isDirectory(Path path, boolean followSymlinks) { throw re(); } @Override protected boolean isFile(Path path, boolean followSymlinks) { throw re(); } + @Override protected boolean isSpecialFile(Path path, boolean followSymlinks) { throw re(); } @Override protected boolean isExecutable(Path path) { throw re(); } @Override protected boolean exists(Path path, boolean followSymlinks) {throw re(); } @Override protected boolean isSymbolicLink(Path path) { throw re(); } diff --git a/src/test/java/com/google/devtools/build/lib/vfs/UnixFileSystemTest.java b/src/test/java/com/google/devtools/build/lib/vfs/UnixFileSystemTest.java index cb5685ed6b..40ace2b6f6 100644 --- a/src/test/java/com/google/devtools/build/lib/vfs/UnixFileSystemTest.java +++ b/src/test/java/com/google/devtools/build/lib/vfs/UnixFileSystemTest.java @@ -15,8 +15,10 @@ package com.google.devtools.build.lib.vfs; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import com.google.devtools.build.lib.unix.FilesystemUtils; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -60,4 +62,20 @@ public class UnixFileSystemTest extends SymlinkAwareFileSystemTest { // Expected. } } + + @Test + public void testIsSpecialFile() throws Exception { + Path regular = absolutize("regular"); + Path fifo = absolutize("fifo"); + FileSystemUtils.createEmptyFile(regular); + FilesystemUtils.mkfifo(fifo.toString(), 0777); + assertTrue(regular.isFile()); + assertFalse(regular.isSpecialFile()); + assertTrue(regular.stat().isFile()); + assertFalse(regular.stat().isSpecialFile()); + assertTrue(fifo.isFile()); + assertTrue(fifo.isSpecialFile()); + assertTrue(fifo.stat().isFile()); + assertTrue(fifo.stat().isSpecialFile()); + } } |