Skip to content

Commit

Permalink
fix error reporting when test step fails
Browse files Browse the repository at this point in the history
  • Loading branch information
boegel committed Jan 19, 2024
1 parent 8aaaec2 commit fe0a520
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion easybuild/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -2736,7 +2736,10 @@ def _test_step(self):
try:
self.test_step()
except RunShellCmdError as err:
self.report_test_failure(err)
err.print()
ec_path = os.path.basename(self.cfg.path)
error_msg = f"shell command '{err.cmd_name} ...' failed in test step for {ec_path}"
self.report_test_failure(error_msg)

def stage_install_step(self):
"""
Expand Down
16 changes: 16 additions & 0 deletions test/framework/toy_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4124,6 +4124,22 @@ def test_toy_build_info_msg(self):
regex = re.compile(pattern, re.M)
self.assertTrue(regex.search(stdout), "Pattern '%s' should be found in: %s" % (regex.pattern, stdout))

def test_toy_failing_test_step(self):
"""
Test behaviour when test step fails, using toy easyconfig.
"""
test_ecs = os.path.join(os.path.dirname(__file__), 'easyconfigs', 'test_ecs')
toy_ec = os.path.join(test_ecs, 't', 'toy', 'toy-0.0.eb')

test_ec_txt = read_file(toy_ec)
test_ec_txt += '\nruntest = "false"'
test_ec = os.path.join(self.test_prefix, 'test.eb')
write_file(test_ec, test_ec_txt)

error_pattern = "shell command 'false \.\.\.' failed in test step"
self.assertErrorRegex(EasyBuildError, error_pattern, self.run_test_toy_build_with_output,
ec_file=test_ec, raise_error=True)

def test_eb_crash(self):
"""
Test behaviour when EasyBuild crashes, for example due to a buggy hook
Expand Down

0 comments on commit fe0a520

Please sign in to comment.