@@ -435,47 +435,40 @@ def run_embedded_native_python_test(args=None):
435
435
those contexts having access to the core files, due to caching in the shared
436
436
engine.
437
437
"""
438
- filename = dirname = None
439
438
with mx .TempDirCwd (os .getcwd ()) as dirname :
440
- try :
441
- python_launcher = python_gvm ()
442
- graalvm_javac = os .path .join (os .path .dirname (python_launcher ), "javac" )
443
- graalvm_native_image = os .path .join (os .path .dirname (python_launcher ), "native-image" )
444
-
445
- filename = os .path .join (dirname , "HelloWorld.java" )
446
- with open (filename , "w" ) as f :
447
- f .write ("""
448
- import org.graalvm.polyglot.*;
449
-
450
- public class HelloWorld {
451
- static final Engine engine = Engine.newBuilder().allowExperimentalOptions(true).option("log.python.level", "FINEST").build();
452
- static {
453
- try (Context contextNull = Context.newBuilder("python").engine(engine).build()) {
454
- contextNull.initialize("python");
455
- }
456
- }
439
+ python_launcher = python_gvm ()
440
+ graalvm_javac = os .path .join (os .path .dirname (python_launcher ), "javac" )
441
+ graalvm_native_image = os .path .join (os .path .dirname (python_launcher ), "native-image" )
442
+
443
+ filename = os .path .join (dirname , "HelloWorld.java" )
444
+ with open (filename , "w" ) as f :
445
+ f .write ("""
446
+ import org.graalvm.polyglot.*;
447
+
448
+ public class HelloWorld {
449
+ static final Engine engine = Engine.newBuilder().allowExperimentalOptions(true).option("log.python.level", "FINEST").build();
450
+ static {
451
+ try (Context contextNull = Context.newBuilder("python").engine(engine).build()) {
452
+ contextNull.initialize("python");
453
+ }
454
+ }
457
455
458
- public static void main(String[] args) {
459
- try (Context context1 = Context.newBuilder("python").engine(engine).build()) {
460
- context1.eval("python", "print(42)");
461
- try (Context context2 = Context.newBuilder("python").engine(engine).build()) {
462
- context2.eval("python", "print(42 + 1)");
463
- }
456
+ public static void main(String[] args) {
457
+ try (Context context1 = Context.newBuilder("python").engine(engine).build()) {
458
+ context1.eval("python", "print(b'abc'.decode('ascii'))");
459
+ try (Context context2 = Context.newBuilder("python").engine(engine).build()) {
460
+ context2.eval("python", "print(b'xyz'.decode('ascii'))");
464
461
}
465
462
}
466
463
}
467
- """ )
468
- out = mx .OutputCapture ()
469
- mx .run ([graalvm_javac , filename ])
470
- mx .run ([graalvm_native_image , "--initialize-at-build-time" , "--language:python" , "HelloWorld" ])
471
- mx .run (["./helloworld" ], out = mx .TeeOutputCapture (out ))
472
- assert "42" in out .data
473
- assert "43" in out .data
474
- finally :
475
- try :
476
- os .unlink (filename )
477
- except :
478
- pass
464
+ }
465
+ """ )
466
+ out = mx .OutputCapture ()
467
+ mx .run ([graalvm_javac , filename ])
468
+ mx .run ([graalvm_native_image , "--initialize-at-build-time" , "--language:python" , "HelloWorld" ])
469
+ mx .run (["./helloworld" ], out = mx .TeeOutputCapture (out ))
470
+ assert "abc" in out .data
471
+ assert "xyz" in out .data
479
472
480
473
481
474
def run_shared_lib_test (args = None ):
0 commit comments