Skip to content

Commit ed10770

Browse files
committed
Gate task: JUnit integration tests of unchained driven by Maven
(cherry picked from commit 6f672ba)
1 parent fe66f4c commit ed10770

File tree

8 files changed

+189
-64
lines changed

8 files changed

+189
-64
lines changed

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

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ Additionally, one can change the polyglot artifacts version with
5656
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5757
<modelVersion>4.0.0</modelVersion>
5858

59-
<groupId>org.graalvm.test</groupId>
60-
<artifactId>cpembedder</artifactId>
59+
<groupId>com.oracle.graal.python.test</groupId>
60+
<artifactId>integration</artifactId>
6161
<version>1.0-SNAPSHOT</version>
6262

6363
<properties>
6464
<maven.compiler.source>17</maven.compiler.source>
6565
<maven.compiler.target>17</maven.compiler.target>
6666
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
67-
<polyglot.version>23.1.0-SNAPSHOT</polyglot.version>
67+
<polyglot.version>24.0.0-dev</polyglot.version>
6868
</properties>
6969

7070
<build>
@@ -78,7 +78,7 @@ Additionally, one can change the polyglot artifacts version with
7878
<plugin>
7979
<groupId>org.apache.maven.plugins</groupId>
8080
<artifactId>maven-surefire-plugin</artifactId>
81-
<version>2.22.0</version>
81+
<version>2.22.2</version>
8282
<dependencies>
8383
<dependency>
8484
<groupId>org.apache.maven.surefire</groupId>
@@ -99,7 +99,27 @@ Additionally, one can change the polyglot artifacts version with
9999

100100
<profiles>
101101
<profile>
102-
<id>Custom repo</id>
102+
<id>Custom central repo</id>
103+
<activation>
104+
<property>
105+
<name>central_repo</name>
106+
</property>
107+
</activation>
108+
<repositories>
109+
<repository>
110+
<id>release</id>
111+
<url>${central_repo}</url>
112+
<releases>
113+
<enabled>true</enabled>
114+
</releases>
115+
<snapshots>
116+
<enabled>true</enabled>
117+
</snapshots>
118+
</repository>
119+
</repositories>
120+
</profile>
121+
<profile>
122+
<id>Custom polyglot repo</id>
103123
<activation>
104124
<property>
105125
<name>polyglot_repo</name>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
*/
4141
package com.oracle.graal.python.test.integration;
4242

43+
import static com.oracle.graal.python.test.integration.Utils.IS_WINDOWS;
4344
import static org.junit.Assert.assertEquals;
45+
import static org.junit.Assume.assumeFalse;
4446

4547
import org.graalvm.polyglot.Context;
4648
import org.graalvm.polyglot.Engine;
@@ -50,6 +52,7 @@ public class EngineOptionsTests {
5052

5153
@Test
5254
public void engineOptions() {
55+
assumeFalse(IS_WINDOWS);
5356
Engine engine = Engine.newBuilder().build();
5457

5558
assertEquals("java", doit(engine, null));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* The Universal Permissive License (UPL), Version 1.0
6+
*
7+
* Subject to the condition set forth below, permission is hereby granted to any
8+
* person obtaining a copy of this software, associated documentation and/or
9+
* data (collectively the "Software"), free of charge and under any and all
10+
* copyright rights in the Software, and any and all patent rights owned or
11+
* freely licensable by each licensor hereunder covering either (i) the
12+
* unmodified Software as contributed to or provided by such licensor, or (ii)
13+
* the Larger Works (as defined below), to deal in both
14+
*
15+
* (a) the Software, and
16+
*
17+
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
18+
* one is included with the Software each a "Larger Work" to which the Software
19+
* is contributed by such licensors),
20+
*
21+
* without restriction, including without limitation the rights to copy, create
22+
* derivative works of, display, perform, and distribute the Software and make,
23+
* use, sell, offer for sale, import, export, have made, and have sold the
24+
* Software and the Larger Work(s), and to sublicense the foregoing rights on
25+
* either these or other terms.
26+
*
27+
* This license is subject to the following condition:
28+
*
29+
* The above copyright notice and either this complete permission notice or at a
30+
* minimum a reference to the UPL must be included in all copies or substantial
31+
* portions of the Software.
32+
*
33+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39+
* SOFTWARE.
40+
*/
41+
package com.oracle.graal.python.test.integration;
42+
43+
import java.util.Locale;
44+
45+
public class Utils {
46+
public static final boolean IS_WINDOWS = System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("windows");
47+
}

graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/module/PosixTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@
2828
import static com.oracle.graal.python.test.integration.PythonTests.assertLastLineError;
2929
import static com.oracle.graal.python.test.integration.PythonTests.assertLastLineErrorContains;
3030
import static com.oracle.graal.python.test.integration.PythonTests.assertPrints;
31+
import static com.oracle.graal.python.test.integration.Utils.IS_WINDOWS;
3132
import static org.junit.Assert.assertEquals;
3233
import static org.junit.Assert.assertTrue;
34+
import static org.junit.Assume.assumeFalse;
3335

3436
import java.io.IOException;
3537
import java.nio.file.Files;
@@ -60,6 +62,7 @@ String open(String arg2) {
6062

6163
@Test
6264
public void stat() {
65+
assumeFalse(IS_WINDOWS);
6366
String source = "import posix\n" +
6467
"result = posix.stat('/')\n" +
6568
"def isdir(stat_result):\n" +
@@ -70,11 +73,13 @@ public void stat() {
7073

7174
@Test
7275
public void open() {
76+
assumeFalse(IS_WINDOWS);
7377
assertPrints("True\n", open("0") + "print(fd > 2)");
7478
}
7579

7680
@Test
7781
public void openFail() {
82+
assumeFalse(IS_WINDOWS);
7883
// TODO this should be checked for FileNotFoundError, but now randomly fails
7984
// because sometimes is OSError
8085
assertLastLineErrorContains("No such file or directory",
@@ -83,13 +88,15 @@ public void openFail() {
8388

8489
@Test
8590
public void fstatFile() {
91+
assumeFalse(IS_WINDOWS);
8692
assertPrints("True\n", "" +
8793
open("0") +
8894
"print((posix.fstat(fd).st_mode & 0xf000) == 0x8000)\n");
8995
}
9096

9197
@Test
9298
public void fstatDir() throws IOException {
99+
assumeFalse(IS_WINDOWS);
93100
Path tmp = Files.createTempDirectory("graalpython");
94101
assertPrints("True\n", "" +
95102
"import posix\n" +
@@ -101,6 +108,7 @@ public void fstatDir() throws IOException {
101108

102109
@Test
103110
public void openCreat() throws IOException {
111+
assumeFalse(IS_WINDOWS);
104112
try {
105113
Files.delete(tmpfile);
106114
assertTrue(Files.notExists(tmpfile));
@@ -117,20 +125,23 @@ public void openCreat() throws IOException {
117125

118126
@Test
119127
public void openTrunc() throws IOException {
128+
assumeFalse(IS_WINDOWS);
120129
Files.write(tmpfile, "hello".getBytes());
121130
assertPrints("", open("posix.O_TRUNC"));
122131
assertTrue(Files.readAllBytes(tmpfile).length == 0);
123132
}
124133

125134
@Test
126135
public void read() throws IOException {
136+
assumeFalse(IS_WINDOWS);
127137
Files.write(tmpfile, "hello".getBytes());
128138
assertPrints("b'hello'\n", open("0") +
129139
"print(posix.read(fd, 5))");
130140
}
131141

132142
@Test
133143
public void lseek() throws IOException {
144+
assumeFalse(IS_WINDOWS);
134145
Files.write(tmpfile, "hello".getBytes());
135146
assertPrints("b'llo'\n", open("0") +
136147
"import os\n" +
@@ -140,13 +151,15 @@ public void lseek() throws IOException {
140151

141152
@Test
142153
public void write() throws IOException {
154+
assumeFalse(IS_WINDOWS);
143155
assertPrints("", open("posix.O_RDWR") +
144156
"posix.write(fd, b'hello')");
145157
assertTrue(new String(Files.readAllBytes(tmpfile)).equals("hello"));
146158
}
147159

148160
@Test
149161
public void close() throws IOException {
162+
assumeFalse(IS_WINDOWS);
150163
assertLastLineErrorContains("OSError",
151164
open("posix.O_RDWR") +
152165
"posix.write(fd, b'hello')\n" +
@@ -157,26 +170,31 @@ public void close() throws IOException {
157170

158171
@Test
159172
public void stdout() {
173+
assumeFalse(IS_WINDOWS);
160174
assertPrints("hello\n", "import sys; sys.stdout.write('hello\\n')");
161175
}
162176

163177
@Test
164178
public void stderr() {
179+
assumeFalse(IS_WINDOWS);
165180
assertLastLineError("error\n", "import sys; sys.stderr.write('error\\n')");
166181
}
167182

168183
@Test
169184
public void printToStdout() {
185+
assumeFalse(IS_WINDOWS);
170186
assertPrints("1-2...", "import sys; print('1', '2', sep='-', file=sys.stdout, end='...', flush=True)");
171187
}
172188

173189
@Test
174190
public void printToStderr() {
191+
assumeFalse(IS_WINDOWS);
175192
assertLastLineError("1-2...", "import sys; print('1', '2', sep='-', file=sys.stderr, end='...', flush=True)");
176193
}
177194

178195
@Test
179196
public void printToFile() throws IOException {
197+
assumeFalse(IS_WINDOWS);
180198
assertPrints("", open("posix.O_RDWR") +
181199
"import _io\n" +
182200
"f = _io.FileIO(fd, mode='w')\n" +
@@ -189,6 +207,7 @@ public void printToFile() throws IOException {
189207

190208
@Test
191209
public void readlinkWithSymlink() throws IOException {
210+
assumeFalse(IS_WINDOWS);
192211
Path realPath = tmpfile.toRealPath();
193212
Path symlinkPath = realPath.getParent().resolve(tmpfile.getFileName() + "__symlink");
194213
try {
@@ -202,13 +221,15 @@ public void readlinkWithSymlink() throws IOException {
202221

203222
@Test
204223
public void readlinkWithOriginalFile() throws IOException {
224+
assumeFalse(IS_WINDOWS);
205225
Path realPath = tmpfile.toRealPath();
206226
assertLastLineErrorContains("OSError", "import posix\n" +
207227
"print(posix.readlink('" + realPath.toString() + "'))\n");
208228
}
209229

210230
@Test
211231
public void sysExcInfo0() {
232+
assumeFalse(IS_WINDOWS);
212233
assertPrints("42\n", "import sys\n" +
213234
"sys.exc_info = lambda: [42, 24, 4224]\n" +
214235
"try:\n" +

graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/module/ThreadPoolTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
*/
4141
package com.oracle.graal.python.test.integration.module;
4242

43+
import static com.oracle.graal.python.test.integration.Utils.IS_WINDOWS;
4344
import static org.junit.Assert.assertEquals;
45+
import static org.junit.Assume.assumeFalse;
4446

4547
import java.io.ByteArrayOutputStream;
4648
import java.io.PrintStream;
@@ -54,6 +56,7 @@ public class ThreadPoolTests {
5456

5557
@Test
5658
public void threadPool() {
59+
assumeFalse(IS_WINDOWS);
5760
String source = "import sysconfig\n" +
5861
"assert sysconfig.get_config_vars().get('WITH_THREAD'), 'context was not started for threading'\n" +
5962
"from multiprocessing.pool import ThreadPool\n" +

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@
2828
import java.io.IOException;
2929
import java.nio.file.Path;
3030
import java.nio.file.Paths;
31-
import java.util.Locale;
3231

3332
public class GraalPythonEnvVars {
34-
public static final boolean IS_WINDOWS = System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("windows");
3533

3634
private static final String PROP_TESTS_HOME = "test.graalpython.home";
3735
private static final String NO_TESTS_HOME = "Fatal: You need to set Java property '%s' to a directory that " +

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/modules/PathConversionNodeTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
*/
4141
package com.oracle.graal.python.test.builtin.modules;
4242

43-
import static com.oracle.graal.python.test.GraalPythonEnvVars.IS_WINDOWS;
4443
import static com.oracle.graal.python.test.PythonTests.ts;
44+
import static com.oracle.graal.python.test.integration.Utils.IS_WINDOWS;
4545
import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING;
4646

4747
import java.math.BigInteger;

0 commit comments

Comments
 (0)