Skip to content

Commit 630b1d6

Browse files
committed
[GR-52500] Set maven.repo.local for gate jobs - remove mvn purge from tests.
PullRequest: graalpython/3234
2 parents 4f29b84 + 3c5ec68 commit 630b1d6

File tree

2 files changed

+74
-113
lines changed

2 files changed

+74
-113
lines changed

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

Lines changed: 74 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import shutil
4747

4848
is_enabled = 'ENABLE_STANDALONE_UNITTESTS' in os.environ and os.environ['ENABLE_STANDALONE_UNITTESTS'] == "true"
49-
skip_purge = 'SKIP_STANDALONE_UNITTESTS_PURGE' in os.environ and os.environ['SKIP_STANDALONE_UNITTESTS_PURGE'] == "true"
5049

5150
MVN_CMD = [shutil.which('mvn'), "--batch-mode"]
5251

@@ -252,53 +251,39 @@ def create_test_pom(self, template, pom):
252251
line = line.replace("{graalpy-maven-plugin-version}", self.graalvmVersion)
253252
f.write(line)
254253

255-
def purge_local_repo(self, target_dir, resolve=True):
256-
if not skip_purge:
257-
self.env["MVN"] = " ".join(MVN_CMD + [f"-Dgraalpy.version={self.graalvmVersion}", "-Dgraalpy.edition=python-community"])
258-
if resolve:
259-
cmd = MVN_CMD + ["dependency:purge-local-repository", f"-Dinclude=org.graalvm.python:graalpy-maven-plugin", f"-Dgraalpy.version={self.graalvmVersion}", "-Dgraalpy.edition=python-community"]
260-
else:
261-
cmd = MVN_CMD + ["dependency:purge-local-repository", "-DreResolve=false", f"-Dinclude=org.graalvm.python:graalpy-maven-plugin", f"-Dgraalpy.version={self.graalvmVersion}", "-Dgraalpy.edition=python-community"]
262-
run_cmd(cmd, self.env, cwd=target_dir)
263-
264254
@unittest.skipUnless(is_enabled, "ENABLE_STANDALONE_UNITTESTS is not true")
265255
def test_generated_app(self):
266256
with tempfile.TemporaryDirectory() as tmpdir:
267257
target_name = "generated_app_test"
268258
target_dir = os.path.join(str(tmpdir), target_name)
269259
self.generate_app(tmpdir, target_dir, target_name)
270-
self.purge_local_repo(target_dir)
271-
272-
try:
273-
# build
274-
cmd = MVN_CMD + ["package", "-Pnative", "-DmainClass=it.pkg.GraalPy"] #, f"-Dgraalpy.version={self.graalvmVersion}", "-Dgraalpy.edition=python-community"]
275-
out, return_code = run_cmd(cmd, self.env, cwd=target_dir)
276-
assert "BUILD SUCCESS" in out
277-
278-
# check fileslist.txt
279-
fl_path = os.path.join(target_dir, "target", "classes", "vfs", "fileslist.txt")
280-
with open(fl_path) as f:
281-
lines = f.readlines()
282-
assert "/vfs/\n" in lines
283-
assert "/vfs/home/\n" in lines
284-
assert "/vfs/home/lib-graalpython/\n" in lines
285-
assert "/vfs/home/lib-python/\n" in lines
286-
287-
# execute and check native image
288-
cmd = [os.path.join(target_dir, "target", target_name)]
289-
out, return_code = run_cmd(cmd, self.env, cwd=target_dir)
290-
assert "hello java" in out
291-
292-
# execute with java and check
293-
cmd = MVN_CMD + ["exec:java", "-Dexec.mainClass=it.pkg.GraalPy"]
294-
out, return_code = run_cmd(cmd, self.env, cwd=target_dir)
295-
assert "hello java" in out
296-
297-
#GR-51132 - NoClassDefFoundError when running polyglot app in java mode
298-
assert "java.lang.NoClassDefFoundError" not in out
299-
300-
finally:
301-
self.purge_local_repo(target_dir, False)
260+
261+
# build
262+
cmd = MVN_CMD + ["package", "-Pnative", "-DmainClass=it.pkg.GraalPy"] #, f"-Dgraalpy.version={self.graalvmVersion}", "-Dgraalpy.edition=python-community"]
263+
out, return_code = run_cmd(cmd, self.env, cwd=target_dir)
264+
assert "BUILD SUCCESS" in out
265+
266+
# check fileslist.txt
267+
fl_path = os.path.join(target_dir, "target", "classes", "vfs", "fileslist.txt")
268+
with open(fl_path) as f:
269+
lines = f.readlines()
270+
assert "/vfs/\n" in lines
271+
assert "/vfs/home/\n" in lines
272+
assert "/vfs/home/lib-graalpython/\n" in lines
273+
assert "/vfs/home/lib-python/\n" in lines
274+
275+
# execute and check native image
276+
cmd = [os.path.join(target_dir, "target", target_name)]
277+
out, return_code = run_cmd(cmd, self.env, cwd=target_dir)
278+
assert "hello java" in out
279+
280+
# execute with java and check
281+
cmd = MVN_CMD + ["exec:java", "-Dexec.mainClass=it.pkg.GraalPy"]
282+
out, return_code = run_cmd(cmd, self.env, cwd=target_dir)
283+
assert "hello java" in out
284+
285+
#GR-51132 - NoClassDefFoundError when running polyglot app in java mode
286+
assert "java.lang.NoClassDefFoundError" not in out
302287

303288
@unittest.skipUnless(is_enabled, "ENABLE_STANDALONE_UNITTESTS is not true")
304289
def test_fail_without_graalpy_dep(self):
@@ -307,19 +292,10 @@ def test_fail_without_graalpy_dep(self):
307292
target_dir = os.path.join(str(tmpdir), target_name)
308293
pom_template = os.path.join(os.path.dirname(__file__), "fail_without_graalpy_dep_pom.xml")
309294
self.generate_app(tmpdir, target_dir, target_name, pom_template)
310-
self.purge_local_repo(target_dir)
311295

312-
if not skip_purge:
313-
self.env["MVN"] = " ".join(MVN_CMD + [f"-Dgraalpy.version={self.graalvmVersion}", "-Dgraalpy.edition=python-community"])
314-
cmd = MVN_CMD + ["dependency:purge-local-repository", f"-Dgraalpy.version={self.graalvmVersion}", "-Dgraalpy.edition=python-community"]
315-
run_cmd(cmd, self.env, cwd=target_dir)
316-
try:
317-
cmd = MVN_CMD + ["process-resources"]
318-
out, return_code = run_cmd(cmd, self.env, cwd=target_dir)
319-
assert "Missing GraalPy dependency. Please add to your pom either org.graalvm.polyglot:python-community or org.graalvm.polyglot:python" in out
320-
321-
finally:
322-
self.purge_local_repo(target_dir, False)
296+
cmd = MVN_CMD + ["process-resources"]
297+
out, return_code = run_cmd(cmd, self.env, cwd=target_dir)
298+
assert "Missing GraalPy dependency. Please add to your pom either org.graalvm.polyglot:python-community or org.graalvm.polyglot:python" in out
323299

324300
@unittest.skipUnless(is_enabled, "ENABLE_STANDALONE_UNITTESTS is not true")
325301
def test_gen_launcher_and_venv(self):
@@ -328,40 +304,35 @@ def test_gen_launcher_and_venv(self):
328304
target_dir = os.path.join(str(tmpdir), target_name)
329305
pom_template = os.path.join(os.path.dirname(__file__), "prepare_venv_pom.xml")
330306
self.generate_app(tmpdir, target_dir, target_name, pom_template)
331-
self.purge_local_repo(target_dir)
332-
333-
try:
334-
cmd = MVN_CMD + ["process-resources"]
335-
out, return_code = run_cmd(cmd, self.env, cwd=target_dir)
336-
assert "-m venv" in out
337-
assert "-m ensurepip" in out
338-
assert "ujson" in out
339-
assert "termcolor" in out
340-
341-
# run again and assert that we do not regenerate the venv
342-
cmd = MVN_CMD + ["process-resources"]
343-
out, return_code = run_cmd(cmd, self.env, cwd=target_dir)
344-
assert "-m venv" not in out
345-
assert "-m ensurepip" not in out
346-
assert "ujson" not in out
347-
assert "termcolor" not in out
348-
349-
# remove ujson pkg from plugin config and check if unistalled
350-
with open(os.path.join(target_dir, "pom.xml"), "r") as f:
351-
contents = f.read()
352-
353-
with open(os.path.join(target_dir, "pom.xml"), "w") as f:
354-
f.write(contents.replace("<package>ujson</package>", ""))
355-
356-
cmd = MVN_CMD + ["process-resources"]
357-
out, return_code = run_cmd(cmd, self.env, cwd=target_dir)
358-
assert "-m venv" not in out
359-
assert "-m ensurepip" not in out
360-
assert "Uninstalling ujson" in out
361-
assert "termcolor" not in out
362-
363-
finally:
364-
self.purge_local_repo(target_dir, False)
307+
308+
cmd = MVN_CMD + ["process-resources"]
309+
out, return_code = run_cmd(cmd, self.env, cwd=target_dir)
310+
assert "-m venv" in out
311+
assert "-m ensurepip" in out
312+
assert "ujson" in out
313+
assert "termcolor" in out
314+
315+
# run again and assert that we do not regenerate the venv
316+
cmd = MVN_CMD + ["process-resources"]
317+
out, return_code = run_cmd(cmd, self.env, cwd=target_dir)
318+
assert "-m venv" not in out
319+
assert "-m ensurepip" not in out
320+
assert "ujson" not in out
321+
assert "termcolor" not in out
322+
323+
# remove ujson pkg from plugin config and check if unistalled
324+
with open(os.path.join(target_dir, "pom.xml"), "r") as f:
325+
contents = f.read()
326+
327+
with open(os.path.join(target_dir, "pom.xml"), "w") as f:
328+
f.write(contents.replace("<package>ujson</package>", ""))
329+
330+
cmd = MVN_CMD + ["process-resources"]
331+
out, return_code = run_cmd(cmd, self.env, cwd=target_dir)
332+
assert "-m venv" not in out
333+
assert "-m ensurepip" not in out
334+
assert "Uninstalling ujson" in out
335+
assert "termcolor" not in out
365336

366337
@unittest.skipUnless(is_enabled, "ENABLE_STANDALONE_UNITTESTS is not true")
367338
def test_check_home(self):
@@ -370,25 +341,21 @@ def test_check_home(self):
370341
target_dir = os.path.join(str(tmpdir), target_name)
371342
pom_template = os.path.join(os.path.dirname(__file__), "check_home_pom.xml")
372343
self.generate_app(tmpdir, target_dir, target_name, pom_template)
373-
self.purge_local_repo(target_dir)
374-
375-
try:
376-
cmd = MVN_CMD + ["process-resources"]
377-
out, return_code = run_cmd(cmd, self.env, cwd=target_dir)
378-
379-
# check fileslist.txt
380-
fl_path = os.path.join(target_dir, "target", "classes", "vfs", "fileslist.txt")
381-
with open(fl_path) as f:
382-
for line in f:
383-
line = f.readline()
384-
# string \n
385-
line = line[:len(line)-1]
386-
if line.endswith("/") or line == "/vfs/home/tagfile" or line == "/vfs/proj/hello.py":
387-
continue
388-
assert line.endswith("/__init__.py")
389-
assert not line.endswith("html/__init__.py")
390-
finally:
391-
self.purge_local_repo(target_dir, False)
344+
345+
cmd = MVN_CMD + ["process-resources"]
346+
out, return_code = run_cmd(cmd, self.env, cwd=target_dir)
347+
348+
# check fileslist.txt
349+
fl_path = os.path.join(target_dir, "target", "classes", "vfs", "fileslist.txt")
350+
with open(fl_path) as f:
351+
for line in f:
352+
line = f.readline()
353+
# string \n
354+
line = line[:len(line)-1]
355+
if line.endswith("/") or line == "/vfs/home/tagfile" or line == "/vfs/proj/hello.py":
356+
continue
357+
assert line.endswith("/__init__.py")
358+
assert not line.endswith("html/__init__.py")
392359

393360
@unittest.skipUnless(is_enabled, "ENABLE_STANDALONE_UNITTESTS is not true")
394361
def test_native_executable_one_file():

mx.graalpython/mx_graalpython.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,9 +1435,6 @@ def graalpython_gate_runner(args, tasks):
14351435
f'-Dcom.oracle.graal.python.test.central_repo={central_override}',
14361436
'--batch-mode']
14371437

1438-
mx.logv("Purging the local repository before the test")
1439-
mx.run_maven(mvn_cmd_base + ['dependency:purge-local-repository', '-DreResolve=false'])
1440-
14411438
mx.log("Running integration JUnit tests on GraalVM SDK")
14421439
env['JAVA_HOME'] = graalvm_jdk()
14431440
mx.run_maven(mvn_cmd_base + ['-U', 'clean', 'test'], env=env)
@@ -1446,9 +1443,6 @@ def graalpython_gate_runner(args, tasks):
14461443
mx.log(f"Running integration JUnit tests on vanilla JDK: {os.environ.get('JAVA_HOME', 'system java')}")
14471444
mx.run_maven(mvn_cmd_base + ['-U', '-Dpolyglot.engine.WarnInterpreterOnly=false', 'clean', 'test'])
14481445

1449-
mx.logv("Purging the local repository after the test")
1450-
mx.run_maven(mvn_cmd_base + ['dependency:purge-local-repository', '-DreResolve=false'])
1451-
14521446
# Unittests on JVM
14531447
with Task('GraalPython Python unittests', tasks, tags=[GraalPythonTags.unittest]) as task:
14541448
if task:

0 commit comments

Comments
 (0)