Skip to content

Commit 9e5b831

Browse files
committed
more VFS tests
1 parent 89822ba commit 9e5b831

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

graalpython/com.oracle.graal.python.test.integration/src/org/graalvm/python/embedding/utils/test/VirtualFileSystemTest.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import java.nio.file.AccessMode;
6161
import java.nio.file.DirectoryStream;
6262
import java.nio.file.Files;
63+
import java.nio.file.InvalidPathException;
6364
import java.nio.file.NoSuchFileException;
6465
import java.nio.file.NotDirectoryException;
6566
import java.nio.file.Path;
@@ -77,6 +78,7 @@
7778
import java.util.logging.Level;
7879
import java.util.logging.Logger;
7980

81+
import com.oracle.graal.python.test.integration.Utils;
8082
import org.graalvm.polyglot.Context;
8183
import org.graalvm.polyglot.Context.Builder;
8284
import org.graalvm.polyglot.HostAccess;
@@ -494,6 +496,10 @@ private static void checkExtractedFile(Path extractedFile, String[] expectedCont
494496
}
495497
}
496498

499+
private static void checkException(Class<?> exType, Callable<Object> c) {
500+
checkException(exType, c, null);
501+
}
502+
497503
private static void checkException(Class<?> exType, Callable<Object> c, String msg) {
498504
boolean gotEx = false;
499505
try {
@@ -502,7 +508,7 @@ private static void checkException(Class<?> exType, Callable<Object> c, String m
502508
assert e.getClass() == exType;
503509
gotEx = true;
504510
}
505-
assertTrue(msg, gotEx);
511+
assertTrue(msg != null ? msg : "expected " + exType.getName(), gotEx);
506512
}
507513

508514
@Test
@@ -863,6 +869,22 @@ public void externalResourcesBuilderTest() throws IOException {
863869
}
864870
}
865871

872+
@Test
873+
public void vfsMountPointTest() {
874+
if (IS_WINDOWS) {
875+
checkException(IllegalArgumentException.class, () -> VirtualFileSystem.newBuilder().windowsMountPoint("test").build());
876+
checkException(IllegalArgumentException.class, () -> VirtualFileSystem.newBuilder().windowsMountPoint("test\\").build());
877+
checkException(IllegalArgumentException.class, () -> VirtualFileSystem.newBuilder().windowsMountPoint("\\test\\").build());
878+
checkException(IllegalArgumentException.class, () -> VirtualFileSystem.newBuilder().windowsMountPoint("\\test").build());
879+
checkException(InvalidPathException.class, () -> VirtualFileSystem.newBuilder().windowsMountPoint("X:\\test|test").build());
880+
} else {
881+
checkException(IllegalArgumentException.class, () -> VirtualFileSystem.newBuilder().unixMountPoint("test").build());
882+
checkException(IllegalArgumentException.class, () -> VirtualFileSystem.newBuilder().unixMountPoint("test/").build());
883+
checkException(IllegalArgumentException.class, () -> VirtualFileSystem.newBuilder().unixMountPoint("/test/").build());
884+
checkException(InvalidPathException.class, () -> VirtualFileSystem.newBuilder().unixMountPoint("/test/\0").build());
885+
}
886+
}
887+
866888
private static Builder addTestOptions(Builder builder) {
867889
return builder.option("engine.WarnInterpreterOnly", "false");
868890
}

0 commit comments

Comments
 (0)