Skip to content

Commit fb2211b

Browse files
committed
Execute maven integration tests also with polyglot process isolates
1 parent 7f34da9 commit fb2211b

23 files changed

+84
-52
lines changed

graalpython/com.oracle.graal.python.test.integration/pom.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,14 @@ Additionally, one can change the polyglot artifacts version with
160160
</dependency>
161161
<dependency>
162162
<groupId>org.graalvm.polyglot</groupId>
163-
<artifactId>python-community</artifactId>
163+
<artifactId>python</artifactId>
164+
<version>${com.oracle.graal.python.test.polyglot.version}</version>
165+
<scope>runtime</scope>
166+
<type>pom</type>
167+
</dependency>
168+
<dependency>
169+
<groupId>org.graalvm.polyglot</groupId>
170+
<artifactId>python-isolate</artifactId>
164171
<version>${com.oracle.graal.python.test.polyglot.version}</version>
165172
<scope>runtime</scope>
166173
<type>pom</type>

graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/EngineOptionsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class EngineOptionsTests {
5353
@Test
5454
public void engineOptions() {
5555
assumeFalse(IS_WINDOWS);
56-
Engine engine = Engine.newBuilder().build();
56+
Engine engine = Engine.newBuilder("python").allowExperimentalOptions(true).build();
5757

5858
assertEquals("java", doit(engine, null));
5959
assertEquals("java", doit(engine, "java"));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class PythonTests {
5858
static final PrintStream errStream = new PrintStream(errArray);
5959
static final PrintStream outStream = new PrintStream(outArray);
6060

61-
private static final Engine engine = Engine.newBuilder().out(PythonTests.outStream).err(PythonTests.errStream).build();
61+
private static final Engine engine = Engine.newBuilder("python").allowExperimentalOptions(true).out(PythonTests.outStream).err(PythonTests.errStream).build();
6262
private static Context context = null;
6363

6464
public static Context enterContext(String... newArgs) {

graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/advanced/MultiContextTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
public class MultiContextTest extends PythonTests {
5050
@Test
5151
public void testSharingWithMemoryview() {
52-
Engine engine = Engine.newBuilder().build();
52+
Engine engine = Engine.newBuilder("python").allowExperimentalOptions(true).build();
5353
for (int i = 0; i < 10; i++) {
5454
try (Context context = newContext(engine)) {
5555
context.eval("python", "memoryview(b'abc')");
@@ -59,7 +59,7 @@ public void testSharingWithMemoryview() {
5959

6060
@Test
6161
public void testTryCatch() {
62-
Engine engine = Engine.newBuilder().build();
62+
Engine engine = Engine.newBuilder("python").allowExperimentalOptions(true).build();
6363
for (int i = 0; i < 10; i++) {
6464
try (Context context = newContext(engine)) {
6565
context.eval("python", "last_val = -1\n" +

graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/advanced/NativeExtTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static void setUpClass() {
6363
@Test
6464
public void testSharingErrorWithCpythonSre() throws InterruptedException {
6565
// The first context is the one that will use native extensions
66-
Engine engine = Engine.newBuilder().build();
66+
Engine engine = Engine.newBuilder("python").allowExperimentalOptions(true).build();
6767
Context cextContext = newContext(engine).option("python.IsolateNativeModules", "true").build();
6868
try {
6969
cextContext.eval("python", "import _cpython_sre\nassert _cpython_sre.ascii_tolower(88) == 120\n");

graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/advanced/ResourcesTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import java.io.File;
4646

4747
import org.graalvm.polyglot.Context;
48+
import org.graalvm.polyglot.Engine;
4849
import org.graalvm.polyglot.io.IOAccess;
4950
import org.junit.Before;
5051
import org.junit.Test;
@@ -72,7 +73,7 @@ public void testResourcesAsHome() {
7273

7374
@Test
7475
public void testResourcesAlwaysAllowReading() {
75-
try (Context context = Context.newBuilder("python").allowIO(IOAccess.NONE).option("python.PythonHome", "/path/that/does/not/exist").build()) {
76+
try (Context context = Context.newBuilder("python").engine(Engine.newBuilder("python").allowExperimentalOptions(true).build()).allowIO(IOAccess.NONE).option("python.PythonHome", "/path/that/does/not/exist").build()) {
7677
String foundHome = context.eval("python", "import email; email.__spec__.origin").asString();
7778
assertTrue(foundHome, foundHome.contains("python" + File.separator + "python-home"));
7879
}

graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/advanced/ShutdownTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import java.util.concurrent.atomic.AtomicReference;
4646

4747
import org.graalvm.polyglot.Context;
48+
import org.graalvm.polyglot.Engine;
4849
import org.graalvm.polyglot.PolyglotException;
4950
import org.junit.Assert;
5051
import org.junit.Assume;
@@ -161,7 +162,7 @@ public void testJavaThreadNotExecutingPythonAnymore() throws InterruptedExceptio
161162
}
162163

163164
private static Context createContext() {
164-
return Context.newBuilder().allowExperimentalOptions(true).allowAllAccess(true).option("python.IsolateNativeModules", "true").build();
165+
return Context.newBuilder().engine(Engine.newBuilder("python").allowExperimentalOptions(true).build()).allowExperimentalOptions(true).allowAllAccess(true).option("python.IsolateNativeModules", "true").build();
165166
}
166167

167168
private static void loadNativeExtension(Context context) {

graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/basic/HelloWorldTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.io.PrintStream;
3232

3333
import org.graalvm.polyglot.Context;
34+
import org.graalvm.polyglot.Engine;
3435
import org.junit.Test;
3536

3637
import com.oracle.graal.python.test.integration.PythonTests;
@@ -53,7 +54,7 @@ public void helloworldAgain() {
5354
public void usesFrozenModules() {
5455
final ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
5556
final PrintStream printStream = new PrintStream(byteArray);
56-
try (Context c = Context.newBuilder().option("log.python.level", "FINE").out(printStream).err(printStream).build()) {
57+
try (Context c = Context.newBuilder().engine(Engine.newBuilder("python").allowExperimentalOptions(true).build()).option("log.python.level", "FINE").out(printStream).err(printStream).build()) {
5758
c.initialize("python");
5859
}
5960
String result = byteArray.toString().replaceAll("\r\n", "\n");

graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/engine/SharedEngineMultithreadingBenchmarkTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static void setUpClass() {
5959

6060
@Test
6161
public void testRichardsInParallelInMultipleContexts() throws Throwable {
62-
try (Engine engine = Engine.newBuilder().allowExperimentalOptions(true).option("python.IsolateNativeModules", "true").build()) {
62+
try (Engine engine = Engine.newBuilder("python").allowExperimentalOptions(true).option("python.IsolateNativeModules", "true").build()) {
6363
Source richardsSource = PythonTests.getScriptSource("richards3.py");
6464
Task[] tasks = new Task[THREADS_COUNT];
6565
for (int taskIdx = 0; taskIdx < tasks.length; taskIdx++) {

graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/engine/SharedEngineMultithreadingImportsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class SharedEngineMultithreadingImportsTest extends SharedEngineMultithre
5555
public void testImportsInParallel() throws InterruptedException, ExecutionException {
5656
ExecutorService executorService = createExecutorService();
5757
for (int runIndex = 0; runIndex < RUNS_COUNT; runIndex++) {
58-
try (Engine engine = Engine.create()) {
58+
try (Engine engine = Engine.newBuilder("python").allowExperimentalOptions(true).build()) {
5959
Task[] tasks = new Task[Runtime.getRuntime().availableProcessors()];
6060
Arrays.fill(tasks, (Task) () -> {
6161
try (InitializedContext ctx = initContext(engine, new String[0])) {

0 commit comments

Comments
 (0)