6060import java .nio .file .AccessMode ;
6161import java .nio .file .DirectoryStream ;
6262import java .nio .file .Files ;
63+ import java .nio .file .InvalidPathException ;
6364import java .nio .file .NoSuchFileException ;
6465import java .nio .file .NotDirectoryException ;
6566import java .nio .file .Path ;
7778import java .util .logging .Level ;
7879import java .util .logging .Logger ;
7980
81+ import com .oracle .graal .python .test .integration .Utils ;
8082import org .graalvm .polyglot .Context ;
8183import org .graalvm .polyglot .Context .Builder ;
8284import 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