From 95ee3ecb6425000bb8341f8c3954b81645f4c627 Mon Sep 17 00:00:00 2001 From: crivella Date: Fri, 1 May 2026 17:18:25 +0200 Subject: [PATCH] Allow running julia package tests in a dedicated test_step --- easybuild/easyblocks/generic/juliapackage.py | 45 +++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/easybuild/easyblocks/generic/juliapackage.py b/easybuild/easyblocks/generic/juliapackage.py index a3e641b2178..bf8b5d5c2f4 100644 --- a/easybuild/easyblocks/generic/juliapackage.py +++ b/easybuild/easyblocks/generic/juliapackage.py @@ -31,6 +31,7 @@ import glob import os import re +import tempfile from easybuild.tools import LooseVersion @@ -272,8 +273,47 @@ def build_step(self): pass def test_step(self): - """No separate (standard) test procedure for JuliaPackage.""" - pass + """ + Test the built Julia package. + + :param return_output: return output and exit code of test command + """ + testcmd = None + if isinstance(self.cfg['runtest'], str): + testcmd = self.cfg['runtest'] + + if self.cfg['runtest']: + if testcmd is None: + testcmd = f"julia -e 'using Pkg; Pkg.test(\"{self.name}\")'" + + try: + tmpdir = tempfile.mkdtemp() + except OSError as err: + raise EasyBuildError("Failed to create test install dir: %s", err) + + depot_path = self.get_julia_env("DEPOT_PATH") + load_path = self.get_julia_env("LOAD_PATH") + self.log.info("Original DEPOT_PATH for testing: %s", os.pathsep.join(depot_path)) + self.log.info("Original LOAD_PATH for testing: %s", os.pathsep.join(load_path)) + + depot_path = os.pathsep.join([tmpdir] + depot_path) + + extrapath = " && ".join([ + f"export JULIA_DEPOT_PATH=\"{depot_path}\"", + # Ensure TEST dependencies can be downloaded + # The alternative is to install them as normal dependencies of the package + "export JULIA_PKG_OFFLINE=false", + "" + ]) + + cmd = ' '.join([ + extrapath, + self.cfg['pretestopts'], + testcmd, + self.cfg['testopts'], + ]) + + run_shell_cmd(cmd) def install_step(self): """Prepare installation environment and install Julia package.""" @@ -293,6 +333,7 @@ def install_extension(self): self.prepare_julia_env() self.install_pkg() + self._test_step() def sanity_check_step(self, *args, **kwargs): """Custom sanity check for JuliaPackage"""