aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com
diff options
context:
space:
mode:
authorGravatar felly <felly@google.com>2017-04-14 20:09:49 +0200
committerGravatar Klaus Aehlig <aehlig@google.com>2017-04-18 11:27:18 +0200
commit8fd7f754771a3793d1089e3845320342cf6d61bb (patch)
tree171688a66675022343480d9a8b7f0750350d5c11 /src/test/java/com
parenta45939bba2e85eb5f5941033e37dc2d6f8e87489 (diff)
Migrate UnixGlob to Path#statIfFound() instead of #statNullable(). The latter swallows all filesystem failures, and does not disambiguate missing files from filesystem problems.
The syscall cache now tracks IOExceptions if they are present, just as it does with readdir(). RELNOTES: None PiperOrigin-RevId: 153185433
Diffstat (limited to 'src/test/java/com')
-rw-r--r--src/test/java/com/google/devtools/build/lib/vfs/GlobTest.java29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/GlobTest.java b/src/test/java/com/google/devtools/build/lib/vfs/GlobTest.java
index 430078ae86..c74e61d3b1 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/GlobTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/GlobTest.java
@@ -185,11 +185,36 @@ public class GlobTest {
}
@Test
+ public void testIOFailureOnStat() throws Exception {
+ UnixGlob.FilesystemCalls syscalls = new UnixGlob.FilesystemCalls() {
+ @Override
+ public FileStatus statIfFound(Path path, Symlinks symlinks) throws IOException {
+ throw new IOException("EIO");
+ }
+
+ @Override
+ public Collection<Dirent> readdir(Path path, Symlinks symlinks) {
+ throw new IllegalStateException();
+ }
+ };
+
+ try {
+ new UnixGlob.Builder(tmpPath)
+ .addPattern("foo/bar/wiz/file")
+ .setFilesystemCalls(new AtomicReference<>(syscalls))
+ .glob();
+ fail("Expected failure");
+ } catch (IOException e) {
+ assertThat(e).hasMessageThat().isEqualTo("EIO");
+ }
+ }
+
+ @Test
public void testGlobWithoutWildcardsDoesNotCallReaddir() throws Exception {
UnixGlob.FilesystemCalls syscalls = new UnixGlob.FilesystemCalls() {
@Override
- public FileStatus statNullable(Path path, Symlinks symlinks) {
- return UnixGlob.DEFAULT_SYSCALLS.statNullable(path, symlinks);
+ public FileStatus statIfFound(Path path, Symlinks symlinks) throws IOException {
+ return UnixGlob.DEFAULT_SYSCALLS.statIfFound(path, symlinks);
}
@Override