Skip to content

Commit c7b14d7

Browse files
committed
set executable in JUnit tests since it's the embedders responsibility, really
1 parent 75d95f3 commit c7b14d7

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/PythonTests.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import java.io.OutputStream;
3939
import java.io.PrintStream;
4040
import java.io.Reader;
41+
import java.lang.management.ManagementFactory;
4142
import java.lang.reflect.Field;
4243
import java.net.JarURLConnection;
4344
import java.net.URLConnection;
@@ -81,11 +82,24 @@ public class PythonTests {
8182
private static Engine engine = Engine.newBuilder().out(PythonTests.outStream).err(PythonTests.errStream).build();
8283
private static Context context = null;
8384

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+
8498
public static void enterContext(String... newArgs) {
8599
PythonTests.outArray.reset();
86100
PythonTests.errArray.reset();
87101
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();
89103
context.initialize("python");
90104
if (prevContext != null) {
91105
closeContext(prevContext);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonOptions.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ public static int getTerminalWidth() {
200200

201201
@TruffleBoundary
202202
public static String[] getExecutableList() {
203-
return getOption(PythonLanguage.getContextRef().get(), ExecutableList).split(EXECUTABLE_LIST_SEPARATOR);
203+
String option = getOption(PythonLanguage.getContextRef().get(), ExecutableList);
204+
if (option.isEmpty()) {
205+
return getOption(PythonLanguage.getContextRef().get(), Executable).split(" ");
206+
} else {
207+
return getOption(PythonLanguage.getContextRef().get(), ExecutableList).split(EXECUTABLE_LIST_SEPARATOR);
208+
}
204209
}
205210
}

0 commit comments

Comments
 (0)