Skip to content

Commit 77e077e

Browse files
committed
fix error reporting when test step fails
1 parent 8aaaec2 commit 77e077e

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

easybuild/framework/easyblock.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2736,7 +2736,10 @@ def _test_step(self):
27362736
try:
27372737
self.test_step()
27382738
except RunShellCmdError as err:
2739-
self.report_test_failure(err)
2739+
err.print()
2740+
ec_path = os.path.basename(self.cfg.path)
2741+
error_msg = f"shell command '{err.cmd_name} ...' failed in test step for {ec_path}"
2742+
self.report_test_failure(error_msg)
27402743

27412744
def stage_install_step(self):
27422745
"""

test/framework/toy_build.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4124,6 +4124,22 @@ def test_toy_build_info_msg(self):
41244124
regex = re.compile(pattern, re.M)
41254125
self.assertTrue(regex.search(stdout), "Pattern '%s' should be found in: %s" % (regex.pattern, stdout))
41264126

4127+
def test_toy_failing_test_step(self):
4128+
"""
4129+
Test behaviour when test step fails, using toy easyconfig.
4130+
"""
4131+
test_ecs = os.path.join(os.path.dirname(__file__), 'easyconfigs', 'test_ecs')
4132+
toy_ec = os.path.join(test_ecs, 't', 'toy', 'toy-0.0.eb')
4133+
4134+
test_ec_txt = read_file(toy_ec)
4135+
test_ec_txt += '\nruntest = "false"'
4136+
test_ec = os.path.join(self.test_prefix, 'test.eb')
4137+
write_file(test_ec, test_ec_txt)
4138+
4139+
error_pattern = r"shell command 'false \.\.\.' failed in test step"
4140+
self.assertErrorRegex(EasyBuildError, error_pattern, self.run_test_toy_build_with_output,
4141+
ec_file=test_ec, raise_error=True)
4142+
41274143
def test_eb_crash(self):
41284144
"""
41294145
Test behaviour when EasyBuild crashes, for example due to a buggy hook

0 commit comments

Comments
 (0)