diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 0bcbf3a466..e0c572e6ad 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -152,7 +152,9 @@ jobs: cd $HOME # initialize environment for modules tool if [ -f $HOME/moduleshome ]; then export MODULESHOME=$(cat $HOME/moduleshome); fi - source $(cat $HOME/mod_init); type module + source $(cat $HOME/mod_init) + type module + module --version # make sure 'eb' is available via $PATH, and that $PYTHONPATH is set (some tests expect that); # also pick up changes to $PATH set by sourcing $MOD_INIT export PREFIX=/tmp/$USER/$GITHUB_SHA diff --git a/test/framework/run.py b/test/framework/run.py index e26373f6e6..0e137ccb75 100644 --- a/test/framework/run.py +++ b/test/framework/run.py @@ -52,6 +52,7 @@ from easybuild.tools.build_log import EasyBuildError, init_logging, stop_logging from easybuild.tools.config import update_build_option from easybuild.tools.filetools import adjust_permissions, change_dir, mkdir, read_file, remove_dir, write_file +from easybuild.tools.modules import EnvironmentModules, Lmod from easybuild.tools.run import RunShellCmdResult, RunShellCmdError, check_async_cmd, check_log_for_errors from easybuild.tools.run import complete_cmd, fileprefix_from_cmd, get_output_from_process, parse_log_for_error from easybuild.tools.run import run_cmd, run_cmd_qa, run_shell_cmd, subprocess_terminate @@ -233,6 +234,20 @@ def test_run_shell_cmd_basic(self): pwd = res[0].strip()[5:] self.assertTrue(os.path.samefile(pwd, self.test_prefix)) + cmd = f"{cmd_script} -c 'module --version'" + with self.mocked_stdout_stderr(): + res = run_shell_cmd(cmd, fail_on_error=False) + self.assertEqual(res.exit_code, 0) + + if isinstance(self.modtool, Lmod): + regex = re.compile("^Modules based on Lua", re.M) + elif isinstance(self.modtool, EnvironmentModules): + regex = re.compile("xxx", re.M) + else: + regex = re.compile("", re.M) + + self.assertTrue(regex.search(res.output), f"Pattern '{regex.pattern}' should be found in {res.output}") + # test running command that emits non-UTF-8 characters # this is constructed to reproduce errors like: # UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2