Skip to content

Commit d2de1fd

Browse files
committed
Exit successfully if --duration limit is reached
1 parent 2e3dee8 commit d2de1fd

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
@@ -1637,9 +1637,12 @@ def module_unuse(*paths):
16371637
if options.max_retries and runner.stats.failed(run=0):
16381638
printer.retry_report(report)
16391639

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

17351738
sys.exit(0)
1739+
except errors.RunSessionTimeout as err:
1740+
printer.warning(f'run session stopped: {err}')
1741+
if not success:
1742+
sys.exit(1)
1743+
else:
1744+
sys.exit(0)
17361745
except (Exception, KeyboardInterrupt, errors.ReframeFatalError):
17371746
exc_info = sys.exc_info()
17381747
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)