|
52 | 52 | from easybuild.tools.build_log import EasyBuildError, init_logging, stop_logging |
53 | 53 | from easybuild.tools.config import update_build_option |
54 | 54 | from easybuild.tools.filetools import adjust_permissions, change_dir, mkdir, read_file, remove_dir, write_file |
| 55 | +from easybuild.tools.modules import EnvironmentModules, Lmod |
55 | 56 | from easybuild.tools.run import RunShellCmdResult, RunShellCmdError, check_async_cmd, check_log_for_errors |
56 | 57 | from easybuild.tools.run import complete_cmd, fileprefix_from_cmd, get_output_from_process, parse_log_for_error |
57 | 58 | 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): |
233 | 234 | pwd = res[0].strip()[5:] |
234 | 235 | self.assertTrue(os.path.samefile(pwd, self.test_prefix)) |
235 | 236 |
|
| 237 | + cmd = f"{cmd_script} -c 'module --version'" |
| 238 | + with self.mocked_stdout_stderr(): |
| 239 | + res = run_shell_cmd(cmd, fail_on_error=False) |
| 240 | + self.assertEqual(res.exit_code, 0) |
| 241 | + |
| 242 | + if isinstance(self.modtool, Lmod): |
| 243 | + regex = re.compile("^Modules based on Lua: Version [0-9]", re.M) |
| 244 | + elif isinstance(self.modtool, EnvironmentModules): |
| 245 | + regex = re.compile("^Modules Release [0-9]", re.M) |
| 246 | + else: |
| 247 | + self.fail("Unknown modules tool used!") |
| 248 | + |
| 249 | + self.assertTrue(regex.search(res.output), f"Pattern '{regex.pattern}' should be found in {res.output}") |
| 250 | + |
236 | 251 | # test running command that emits non-UTF-8 characters |
237 | 252 | # this is constructed to reproduce errors like: |
238 | 253 | # UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 |
|
0 commit comments