Skip to content

Commit f2c2f39

Browse files
committed
improved output from VFSTest
1 parent bca0a84 commit f2c2f39

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

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

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,12 @@
7373
import java.util.concurrent.Callable;
7474
import java.util.function.BiFunction;
7575
import java.util.function.Function;
76+
import java.util.logging.Handler;
77+
import java.util.logging.Level;
78+
import java.util.logging.Logger;
7679

7780
import org.graalvm.polyglot.Context;
81+
import org.graalvm.polyglot.Context.Builder;
7882
import org.graalvm.polyglot.HostAccess;
7983
import org.graalvm.polyglot.PolyglotException;
8084
import org.graalvm.polyglot.io.FileSystem;
@@ -110,6 +114,14 @@ public class VirtualFileSystemTest {
110114
extractFilter(p -> p.getFileName().toString().equals("extractme")).//
111115
resourceLoadingClass(VirtualFileSystemTest.class).build();
112116

117+
public VirtualFileSystemTest() {
118+
Logger logger = Logger.getLogger(VirtualFileSystem.class.getName());
119+
for (Handler handler : logger.getHandlers()) {
120+
handler.setLevel(Level.FINE);
121+
}
122+
logger.setLevel(Level.FINE);
123+
}
124+
113125
@Test
114126
public void defaultValues() throws Exception {
115127
VirtualFileSystem fs = VirtualFileSystem.create();
@@ -322,7 +334,7 @@ public void delete() throws Exception {
322334
assertFalse(Files.exists(realFSPath));
323335
}
324336

325-
private void checkDelete(FileSystem fs, String path) {
337+
private static void checkDelete(FileSystem fs, String path) {
326338
checkException(SecurityException.class, () -> {
327339
fs.delete(Path.of(path));
328340
return null;
@@ -373,7 +385,7 @@ public void newByteChannel() throws IOException {
373385
}
374386
}
375387

376-
private void checkCanOnlyRead(FileSystem fs, Path path, StandardOpenOption... options) {
388+
private static void checkCanOnlyRead(FileSystem fs, Path path, StandardOpenOption... options) {
377389
checkException(SecurityException.class, () -> fs.newByteChannel(path, Set.of(options)), "should only be able to read from VFS");
378390
}
379391

@@ -766,7 +778,7 @@ public Context getContext(Function<VirtualFileSystem.Builder, VirtualFileSystem.
766778
builder = builderFunction.apply(builder);
767779
}
768780
VirtualFileSystem fs = builder.build();
769-
Context context = GraalPyResources.contextBuilder(fs).build();
781+
Context context = addTestOptions(GraalPyResources.contextBuilder(fs)).build();
770782
if (builderFunction == null) {
771783
cachedContext = context;
772784
}
@@ -775,10 +787,10 @@ public Context getContext(Function<VirtualFileSystem.Builder, VirtualFileSystem.
775787

776788
@Test
777789
public void vfsBuilderTest() {
778-
Context context = GraalPyResources.contextBuilder().allowAllAccess(true).allowHostAccess(HostAccess.ALL).build();
790+
Context context = addTestOptions(GraalPyResources.contextBuilder()).allowAllAccess(true).allowHostAccess(HostAccess.ALL).build();
779791
context.eval(PYTHON, "import java; java.type('java.lang.String')");
780792

781-
context = GraalPyResources.contextBuilder().allowAllAccess(false).allowHostAccess(HostAccess.NONE).build();
793+
context = addTestOptions(GraalPyResources.contextBuilder()).allowAllAccess(false).allowHostAccess(HostAccess.NONE).build();
782794
context.eval(PYTHON, """
783795
import java
784796
try:
@@ -793,13 +805,13 @@ public void vfsBuilderTest() {
793805
unixMountPoint(VFS_MOUNT_POINT).//
794806
windowsMountPoint(VFS_WIN_MOUNT_POINT).//
795807
resourceLoadingClass(VirtualFileSystemTest.class).build();
796-
context = GraalPyResources.contextBuilder(fs).build();
808+
context = addTestOptions(GraalPyResources.contextBuilder(fs)).build();
797809
context.eval(PYTHON, patchMountPoint("from os import listdir; listdir('/test_mount_point')"));
798810

799811
context = GraalPyResources.createContext();
800812
context.eval(PYTHON, "from os import listdir; listdir('.')");
801813

802-
context = GraalPyResources.contextBuilder().allowIO(IOAccess.NONE).build();
814+
context = addTestOptions(GraalPyResources.contextBuilder()).allowIO(IOAccess.NONE).build();
803815
boolean gotPE = false;
804816
try {
805817
context.eval(PYTHON, "from os import listdir; listdir('.')");
@@ -835,9 +847,13 @@ public void externalResourcesBuilderTest() throws IOException {
835847
checkExtractedFile(resourcesDir.resolve(Path.of("file1")), new String[]{"text1", "text2"});
836848

837849
// create context with extracted resource dir and check if we can see the extracted file
838-
try (Context context = GraalPyResources.contextBuilder(resourcesDir).build()) {
850+
try (Context context = addTestOptions(GraalPyResources.contextBuilder(resourcesDir)).build()) {
839851
context.eval("python", "import os; assert os.path.exists('" + resourcesDir.resolve("file1").toString().replace("\\", "\\\\") + "')");
840852
}
841853
}
842854

855+
private static Builder addTestOptions(Builder builder) {
856+
return builder.option("engine.WarnInterpreterOnly", "false");
857+
}
858+
843859
}

0 commit comments

Comments
 (0)