Skip to content

Commit a05a9e3

Browse files
committed
added test to check maven plugin with deprecated embedding.utils package
1 parent 6d7e264 commit a05a9e3

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

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

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,50 @@ def test_generated_app(self):
139139
util.check_ouput("Deleting GraalPy venv due to changed launcher path", out)
140140
util.check_ouput("hello java", out)
141141

142+
@unittest.skipUnless(util.is_maven_plugin_test_enabled, "ENABLE_MAVEN_PLUGIN_UNITTESTS is not true")
143+
def test_generated_app_utils_pkg(self):
144+
# check if java classes from the deprecated embedding.utils pkg work as expected
145+
with util.TemporaryTestDirectory() as tmpdir:
146+
147+
target_name = "generated_app_test_utils_pkg"
148+
target_dir = os.path.join(str(tmpdir), target_name)
149+
self.generate_app(tmpdir, target_dir, target_name)
150+
151+
util.replace_in_file(os.path.join(target_dir, "src", "main", "java", "it", "pkg", "GraalPy.java"),
152+
"import org.graalvm.python.embedding.GraalPyResources;",
153+
"import org.graalvm.python.embedding.utils.GraalPyResources;")
154+
155+
mvnw_cmd = util.get_mvn_wrapper(target_dir, self.env)
156+
157+
# build
158+
cmd = mvnw_cmd + ["package", "-Pnative", "-DmainClass=it.pkg.GraalPy"]
159+
out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir)
160+
util.check_ouput("BUILD SUCCESS", out)
161+
162+
# check fileslist.txt
163+
fl_path = os.path.join(target_dir, "target", "classes", util.VFS_PREFIX, "fileslist.txt")
164+
with open(fl_path) as f:
165+
lines = f.readlines()
166+
assert "/" + util.VFS_PREFIX + "/\n" in lines, "unexpected output from " + str(cmd)
167+
168+
# execute and check native image
169+
cmd = [os.path.join(target_dir, "target", target_name)]
170+
out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir)
171+
util.check_ouput("hello java", out)
172+
173+
# 2.) check java build and exec
174+
# run with java asserts on
175+
if self.env.get("MAVEN_OPTS"):
176+
self.env["MAVEN_OPTS"] = self.env.get("MAVEN_OPTS") + " -ea -esa"
177+
else:
178+
self.env["MAVEN_OPTS"] = "-ea -esa"
179+
180+
# rebuild and exec
181+
cmd = mvnw_cmd + ["package", "exec:java", "-Dexec.mainClass=it.pkg.GraalPy"]
182+
out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir)
183+
util.check_ouput("BUILD SUCCESS", out)
184+
util.check_ouput("hello java", out)
185+
142186
@unittest.skipUnless(util.is_maven_plugin_test_enabled, "ENABLE_MAVEN_PLUGIN_UNITTESTS is not true")
143187
def test_generated_app_external_resources(self):
144188
with util.TemporaryTestDirectory() as tmpdir:
@@ -278,7 +322,7 @@ def test_check_home(self):
278322
log = Logger()
279323
util.replace_in_file(os.path.join(target_dir, "pom.xml"), "<fallback>false</fallback>",
280324
textwrap.dedent("""<systemProperties>
281-
<org.graalvm.python.resources.include>.*</org.graalvm.python.resources.include>
325+
<org.graalvm.python.resources.include>.*</org.graalvm.python.resources.include>
282326
<org.graalvm.python.resources.log>true</org.graalvm.python.resources.log>
283327
</systemProperties>
284328
<fallback>false</fallback>"""))

0 commit comments

Comments
 (0)