Skip to content

Commit eb768a1

Browse files
committed
fix broken tests due to changes in error handling
1 parent 7d2d537 commit eb768a1

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

test/framework/run.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def test_run_shell_cmd_log(self):
249249
os.close(fd)
250250

251251
regex_start_cmd = re.compile("Running command 'echo hello' in /")
252-
regex_cmd_exit = re.compile("Command 'echo hello' exited with exit code [0-9]* and output:")
252+
regex_cmd_exit = re.compile("Shell command completed successfully \(see output above\): echo hello")
253253

254254
# command output is always logged
255255
init_logging(logfile, silent=True)
@@ -258,8 +258,9 @@ def test_run_shell_cmd_log(self):
258258
stop_logging(logfile)
259259
self.assertEqual(res.exit_code, 0)
260260
self.assertEqual(res.output, 'hello\n')
261-
self.assertEqual(len(regex_start_cmd.findall(read_file(logfile))), 1)
262-
self.assertEqual(len(regex_cmd_exit.findall(read_file(logfile))), 1)
261+
logtxt = read_file(logfile)
262+
self.assertEqual(len(regex_start_cmd.findall(logtxt)), 1)
263+
self.assertEqual(len(regex_cmd_exit.findall(logtxt)), 1)
263264
write_file(logfile, '')
264265

265266
# with debugging enabled, exit code and output of command should only get logged once

test/framework/toy_build.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ def test_toy_buggy_easyblock(self):
374374
'verify': False,
375375
'verbose': False,
376376
}
377-
err_regex = r"Traceback[\S\s]*toy_buggy.py.*build_step[\S\s]*name 'run_cmd' is not defined"
378-
self.assertErrorRegex(EasyBuildError, err_regex, self.run_test_toy_build_with_output, **kwargs)
377+
err_regex = r"name 'run_cmd' is not defined"
378+
self.assertErrorRegex(NameError, err_regex, self.run_test_toy_build_with_output, **kwargs)
379379

380380
def test_toy_build_formatv2(self):
381381
"""Perform a toy build (format v2)."""
@@ -1435,7 +1435,7 @@ def test_toy_extension_extract_cmd(self):
14351435
])
14361436
write_file(test_ec, test_ec_txt)
14371437

1438-
error_pattern = "unzip .*/bar-0.0.tar.gz.* returned non-zero exit status"
1438+
error_pattern = r"shell command 'unzip \.\.\.' failed in extensions step for test.eb"
14391439
with self.mocked_stdout_stderr():
14401440
# for now, we expect subprocess.CalledProcessError, but eventually 'run' function will
14411441
# do proper error reporting
@@ -2642,7 +2642,7 @@ def test_toy_build_enhanced_sanity_check(self):
26422642
test_ec_txt = test_ec_txt + '\nenhance_sanity_check = False'
26432643
write_file(test_ec, test_ec_txt)
26442644

2645-
error_pattern = r" Missing mandatory key 'dirs' in sanity_check_paths."
2645+
error_pattern = r"Missing mandatory key 'dirs' in sanity_check_paths."
26462646
with self.mocked_stdout_stderr():
26472647
self.assertErrorRegex(EasyBuildError, error_pattern, self._test_toy_build, ec_file=test_ec,
26482648
extra_args=eb_args, raise_error=True, verbose=False)

0 commit comments

Comments
 (0)