60
60
import java .nio .file .AccessMode ;
61
61
import java .nio .file .DirectoryStream ;
62
62
import java .nio .file .Files ;
63
+ import java .nio .file .InvalidPathException ;
63
64
import java .nio .file .NoSuchFileException ;
64
65
import java .nio .file .NotDirectoryException ;
65
66
import java .nio .file .Path ;
77
78
import java .util .logging .Level ;
78
79
import java .util .logging .Logger ;
79
80
81
+ import com .oracle .graal .python .test .integration .Utils ;
80
82
import org .graalvm .polyglot .Context ;
81
83
import org .graalvm .polyglot .Context .Builder ;
82
84
import org .graalvm .polyglot .HostAccess ;
@@ -494,6 +496,10 @@ private static void checkExtractedFile(Path extractedFile, String[] expectedCont
494
496
}
495
497
}
496
498
499
+ private static void checkException (Class <?> exType , Callable <Object > c ) {
500
+ checkException (exType , c , null );
501
+ }
502
+
497
503
private static void checkException (Class <?> exType , Callable <Object > c , String msg ) {
498
504
boolean gotEx = false ;
499
505
try {
@@ -502,7 +508,7 @@ private static void checkException(Class<?> exType, Callable<Object> c, String m
502
508
assert e .getClass () == exType ;
503
509
gotEx = true ;
504
510
}
505
- assertTrue (msg , gotEx );
511
+ assertTrue (msg != null ? msg : "expected " + exType . getName () , gotEx );
506
512
}
507
513
508
514
@ Test
@@ -863,6 +869,22 @@ public void externalResourcesBuilderTest() throws IOException {
863
869
}
864
870
}
865
871
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
+
866
888
private static Builder addTestOptions (Builder builder ) {
867
889
return builder .option ("engine.WarnInterpreterOnly" , "false" );
868
890
}
0 commit comments