Skip to content

Commit 641114e

Browse files
committed
added test for packages config to test_standalone
1 parent c26ab9e commit 641114e

File tree

2 files changed

+115
-1
lines changed

2 files changed

+115
-1
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved.
4+
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5+
6+
The Universal Permissive License (UPL), Version 1.0
7+
8+
Subject to the condition set forth below, permission is hereby granted to any
9+
person obtaining a copy of this software, associated documentation and/or
10+
data (collectively the "Software"), free of charge and under any and all
11+
copyright rights in the Software, and any and all patent rights owned or
12+
freely licensable by each licensor hereunder covering either (i) the
13+
unmodified Software as contributed to or provided by such licensor, or (ii)
14+
the Larger Works (as defined below), to deal in both
15+
16+
(a) the Software, and
17+
18+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
19+
one is included with the Software each a "Larger Work" to which the Software
20+
is contributed by such licensors),
21+
22+
without restriction, including without limitation the rights to copy, create
23+
derivative works of, display, perform, and distribute the Software and make,
24+
use, sell, offer for sale, import, export, have made, and have sold the
25+
Software and the Larger Work(s), and to sublicense the foregoing rights on
26+
either these or other terms.
27+
28+
This license is subject to the following condition:
29+
30+
The above copyright notice and either this complete permission notice or at a
31+
minimum a reference to the UPL must be included in all copies or substantial
32+
portions of the Software.
33+
34+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
40+
SOFTWARE.
41+
-->
42+
<project xmlns="http://maven.apache.org/POM/4.0.0"
43+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
45+
<modelVersion>4.0.0</modelVersion>
46+
47+
<groupId>org.apache.maven.plugin.my.unit</groupId>
48+
<artifactId>project-check-packages</artifactId>
49+
<version>1.0-SNAPSHOT</version>
50+
<packaging>jar</packaging>
51+
<name>Test MyMojo</name>
52+
53+
<dependencies>
54+
<dependency>
55+
<groupId>org.graalvm.polyglot</groupId>
56+
<artifactId>python-community</artifactId>
57+
<version>${env.GRAALPY_VERSION}</version>
58+
<type>pom</type>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.graalvm.python</groupId>
62+
<artifactId>python-launcher</artifactId>
63+
<version>${env.GRAALPY_VERSION}</version>
64+
</dependency>
65+
</dependencies>
66+
67+
<build>
68+
<plugins>
69+
<plugin>
70+
<groupId>org.graalvm.python</groupId>
71+
<artifactId>graalpy-maven-plugin</artifactId>
72+
<version>${env.GRAALPY_VERSION}</version>
73+
<executions>
74+
<execution>
75+
<configuration>
76+
<packages>
77+
78+
</packages>
79+
</configuration>
80+
<goals>
81+
<goal>process-graalpy-resources</goal>
82+
</goals>
83+
</execution>
84+
</executions>
85+
</plugin>
86+
</plugins>
87+
</build>
88+
</project>

graalpython/com.oracle.graal.python.test/src/tests/standalone/test_standalone.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ def get_gp():
7575

7676
return graalpy
7777

78+
def replace_in_file(file, str, replace_str):
79+
with open(file, "r") as f:
80+
contents = f.read()
81+
with open(file, "w") as f:
82+
f.write(contents.replace(str, replace_str))
83+
7884
class PolyglotAppTest(unittest.TestCase):
7985

8086
def setUpClass(self):
@@ -274,7 +280,7 @@ def test_gen_launcher_and_venv(self):
274280

275281
@unittest.skipUnless(is_enabled, "ENABLE_STANDALONE_UNITTESTS is not true")
276282
def test_check_home(self):
277-
with tempfile.TemporaryDirectory() as tmpdir:
283+
with tempfile.TemporaryDirectory() as tmpdir:
278284
target_name = "check_home_test"
279285
target_dir = os.path.join(str(tmpdir), target_name)
280286
pom_template = os.path.join(os.path.dirname(__file__), "check_home_pom.xml")
@@ -297,6 +303,26 @@ def test_check_home(self):
297303
assert line.endswith("/__init__.py")
298304
assert not line.endswith("html/__init__.py")
299305

306+
@unittest.skipUnless(is_enabled, "ENABLE_STANDALONE_UNITTESTS is not true")
307+
def test_empty_packages(self):
308+
with tempfile.TemporaryDirectory() as tmpdir:
309+
target_name = "empty_packages_test"
310+
target_dir = os.path.join(str(tmpdir), target_name)
311+
pom_template = os.path.join(os.path.dirname(__file__), "check_packages_pom.xml")
312+
self.generate_app(tmpdir, target_dir, target_name, pom_template)
313+
314+
mvnw_cmd = util.get_mvn_wrapper(target_dir, self.env)
315+
316+
cmd = mvnw_cmd + ["process-resources"]
317+
out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir)
318+
util.check_ouput("BUILD SUCCESS", out)
319+
320+
replace_in_file(os.path.join(target_dir, "pom.xml"), "</packages>", "<package></package><package> </package></packages>")
321+
322+
cmd = mvnw_cmd + ["process-resources"]
323+
out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir)
324+
util.check_ouput("BUILD SUCCESS", out)
325+
300326
@unittest.skipUnless(is_enabled, "ENABLE_STANDALONE_UNITTESTS is not true")
301327
def test_native_executable_one_file():
302328
graalpy = util.get_gp()

0 commit comments

Comments
 (0)