diff --git a/easybuild/framework/easyblock.py b/easybuild/framework/easyblock.py index f6077dd5ce..a684b74347 100644 --- a/easybuild/framework/easyblock.py +++ b/easybuild/framework/easyblock.py @@ -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): """ diff --git a/test/framework/toy_build.py b/test/framework/toy_build.py index 6ba47d3587..d6f3f9e7ce 100644 --- a/test/framework/toy_build.py +++ b/test/framework/toy_build.py @@ -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