Skip to content

Commit 6e212be

Browse files
authored
Merge pull request #4881 from boegel/fix_ignore_test_fail
also ignore errors raised during test step when `--ignore-test-failure` is used
2 parents 9e9a3aa + 7653e00 commit 6e212be

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

easybuild/framework/easyblock.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3000,6 +3000,8 @@ def _test_step(self):
30003000
"""Run the test_step and handles failures"""
30013001
try:
30023002
self.test_step()
3003+
except EasyBuildError as err:
3004+
self.report_test_failure(f"An error was raised during test step: {err}")
30033005
except RunShellCmdError as err:
30043006
err.print()
30053007
ec_path = os.path.basename(self.cfg.path)

test/framework/sandbox/easybuild/easyblocks/t/toy.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ def build_step(self, name=None, cfg=None):
132132
if res.exit_code:
133133
print_warning("Command '%s' failed, but we'll ignore it..." % cmd)
134134

135+
def test_step(self, *args, **kwargs):
136+
"""Test toy."""
137+
if self.cfg['runtest'] == 'RAISE_ERROR':
138+
raise EasyBuildError("TOY_TEST_FAIL")
139+
else:
140+
super().test_step(*args, **kwargs)
141+
135142
def install_step(self, name=None):
136143
"""Install toy."""
137144
if name is None:

test/framework/toy_build.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4361,6 +4361,9 @@ def test_toy_failing_test_step(self):
43614361
"""
43624362
test_ecs = os.path.join(os.path.dirname(__file__), 'easyconfigs', 'test_ecs')
43634363
toy_ec = os.path.join(test_ecs, 't', 'toy', 'toy-0.0.eb')
4364+
toy_mod_path = os.path.join(self.test_installpath, 'modules', 'all', 'toy', '0.0')
4365+
if get_module_syntax() == 'Lua':
4366+
toy_mod_path += '.lua'
43644367

43654368
test_ec_txt = read_file(toy_ec)
43664369
test_ec_txt += '\nruntest = "false"'
@@ -4370,6 +4373,27 @@ def test_toy_failing_test_step(self):
43704373
error_pattern = r"shell command 'false \.\.\.' failed in test step"
43714374
self.assertErrorRegex(EasyBuildError, error_pattern, self.run_test_toy_build_with_output,
43724375
ec_file=test_ec, raise_error=True)
4376+
self.assertNotExists(toy_mod_path)
4377+
4378+
# make sure that option to ignore test failures works
4379+
self.run_test_toy_build_with_output(ec_file=test_ec, extra_args=['--ignore-test-failure'],
4380+
raise_error=True, verbose=True)
4381+
self.assertExists(toy_mod_path)
4382+
remove_file(toy_mod_path)
4383+
4384+
# ignoring test failure should also work if an EasyBuildError is raises from test step
4385+
test_ec_txt = read_file(toy_ec)
4386+
test_ec_txt += '\nruntest = "RAISE_ERROR"'
4387+
write_file(test_ec, test_ec_txt)
4388+
4389+
error_pattern = r"An error was raised during test step: 'TOY_TEST_FAIL'"
4390+
self.assertErrorRegex(EasyBuildError, error_pattern, self.run_test_toy_build_with_output,
4391+
ec_file=test_ec, raise_error=True)
4392+
4393+
# make sure that option to ignore test failures works
4394+
self.run_test_toy_build_with_output(ec_file=test_ec, extra_args=['--ignore-test-failure'],
4395+
raise_error=True, verbose=True)
4396+
self.assertExists(toy_mod_path)
43734397

43744398
def test_eb_crash(self):
43754399
"""

0 commit comments

Comments
 (0)