Skip to content

Commit 93eef0f

Browse files
authored
Merge pull request #3328 from vkarak/bugfix/reruns-exitcode
[bugfix] Exit successfully if `--duration` limit is reached
2 parents ada1dfc + ff2dddf commit 93eef0f

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

reframe/frontend/cli.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,9 +1638,12 @@ def module_unuse(*paths):
16381638
if options.max_retries and runner.stats.failed(run=0):
16391639
printer.retry_report(report)
16401640

1641-
# Print a failure report if we had failures in the last run
1641+
# Print a failure report in case of failures.
1642+
# If `--duration` or `--reruns` is used then take into account
1643+
# all runs, else (i.e., `--max-retries`) only the last run.
16421644
success = True
1643-
if runner.stats.failed():
1645+
runid = None if options.duration or options.reruns else -1
1646+
if runner.stats.failed(run=runid):
16441647
success = False
16451648
printer.failure_report(
16461649
report,
@@ -1734,6 +1737,12 @@ def module_unuse(*paths):
17341737
sys.exit(1)
17351738

17361739
sys.exit(0)
1740+
except errors.RunSessionTimeout as err:
1741+
printer.warning(f'run session stopped: {err}')
1742+
if not success:
1743+
sys.exit(1)
1744+
else:
1745+
sys.exit(0)
17371746
except (Exception, KeyboardInterrupt, errors.ReframeFatalError):
17381747
exc_info = sys.exc_info()
17391748
tb = ''.join(traceback.format_exception(*exc_info))

unittests/test_cli.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,13 @@ def test_reruns_with_duration(run_reframe):
10761076
assert returncode == 1
10771077

10781078

1079+
def test_exitcode_timeout(run_reframe):
1080+
assert_no_crash(*run_reframe(
1081+
more_options=['--duration=5s', '-n^HelloTest'],
1082+
checkpath=['unittests/resources/checks/hellocheck.py']
1083+
))
1084+
1085+
10791086
@pytest.fixture(params=['name', 'rname', 'uid', 'ruid', 'random'])
10801087
def exec_order(request):
10811088
return request.param

0 commit comments

Comments
 (0)