|
38 | 38 | import java.io.OutputStream;
|
39 | 39 | import java.io.PrintStream;
|
40 | 40 | import java.io.Reader;
|
| 41 | +import java.lang.management.ManagementFactory; |
41 | 42 | import java.lang.reflect.Field;
|
42 | 43 | import java.net.JarURLConnection;
|
43 | 44 | import java.net.URLConnection;
|
@@ -81,11 +82,24 @@ public class PythonTests {
|
81 | 82 | private static Engine engine = Engine.newBuilder().out(PythonTests.outStream).err(PythonTests.errStream).build();
|
82 | 83 | private static Context context = null;
|
83 | 84 |
|
| 85 | + private static final String executable; |
| 86 | + static { |
| 87 | + StringBuilder sb = new StringBuilder(); |
| 88 | + sb.append(System.getProperty("java.home")).append(File.separator).append("bin").append(File.separator).append("java"); |
| 89 | + for (String arg : ManagementFactory.getRuntimeMXBean().getInputArguments()) { |
| 90 | + sb.append(' ').append(arg); |
| 91 | + } |
| 92 | + sb.append(" -classpath "); |
| 93 | + sb.append(System.getProperty("java.class.path")); |
| 94 | + sb.append(" com.oracle.graal.python.shell.GraalPythonMain"); |
| 95 | + executable = sb.toString(); |
| 96 | + } |
| 97 | + |
84 | 98 | public static void enterContext(String... newArgs) {
|
85 | 99 | PythonTests.outArray.reset();
|
86 | 100 | PythonTests.errArray.reset();
|
87 | 101 | Context prevContext = context;
|
88 |
| - context = Context.newBuilder().engine(engine).allowAllAccess(true).arguments("python", newArgs).build(); |
| 102 | + context = Context.newBuilder().engine(engine).allowAllAccess(true).arguments("python", newArgs).option("python.Executable", executable).build(); |
89 | 103 | context.initialize("python");
|
90 | 104 | if (prevContext != null) {
|
91 | 105 | closeContext(prevContext);
|
|
0 commit comments