Skip to content

Commit d499c60

Browse files
committed
Install patchelf for testing if needed
1 parent 48c2122 commit d499c60

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

mx.graalpython/mx_graalpython.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,17 @@ def punittest(ars, report=False):
382382
Pass --regex to further filter the junit and TSK tests. GraalPy tests are always run in two configurations:
383383
with language home on filesystem and with language home served from the Truffle resources.
384384
"""
385+
path = os.environ.get("PATH", "")
386+
if mx.is_linux() and not shutil.which("patchelf"):
387+
venv = Path(SUITE.get_output_root()).absolute() / "patchelf-venv"
388+
path += os.pathsep + str(venv / "bin")
389+
if not shutil.which("patchelf", path=path):
390+
mx.log(f"{time.strftime('[%H:%M:%S] ')} Building patchelf-venv with {sys.executable}... [patchelf not found on PATH]")
391+
t0 = time.time()
392+
subprocess.check_call([sys.executable, "-m", "venv", str(venv)])
393+
subprocess.check_call([str(venv / "bin" / "pip"), "install", "patchelf"])
394+
mx.log(f"{time.strftime('[%H:%M:%S] ')} Building patchelf-venv with {sys.executable}... [duration: {time.time() - t0}]")
395+
385396
args = [] if ars is None else ars
386397
@dataclass
387398
class TestConfig:
@@ -426,7 +437,8 @@ def __str__(self):
426437
for c in configs:
427438
mx.log(f"Python JUnit tests configuration: {c}")
428439
PythonMxUnittestConfig.useResources = c.useResources
429-
mx_unittest.unittest(c.args, test_report_tags=({"task": f"punittest-{c.identifier}-{'w' if c.useResources else 'wo'}-resources"} if c.reportConfig else None))
440+
with set_env(PATH=path):
441+
mx_unittest.unittest(c.args, test_report_tags=({"task": f"punittest-{c.identifier}-{'w' if c.useResources else 'wo'}-resources"} if c.reportConfig else None))
430442

431443
if skip_leak_tests:
432444
return

0 commit comments

Comments
 (0)