Skip to content

Commit

Permalink
Merge pull request #3328 from vkarak/bugfix/reruns-exitcode
Browse files Browse the repository at this point in the history
[bugfix] Exit successfully if `--duration` limit is reached
  • Loading branch information
vkarak authored Dec 6, 2024
2 parents ada1dfc + ff2dddf commit 93eef0f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
13 changes: 11 additions & 2 deletions reframe/frontend/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1638,9 +1638,12 @@ def module_unuse(*paths):
if options.max_retries and runner.stats.failed(run=0):
printer.retry_report(report)

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

sys.exit(0)
except errors.RunSessionTimeout as err:
printer.warning(f'run session stopped: {err}')
if not success:
sys.exit(1)
else:
sys.exit(0)
except (Exception, KeyboardInterrupt, errors.ReframeFatalError):
exc_info = sys.exc_info()
tb = ''.join(traceback.format_exception(*exc_info))
Expand Down
7 changes: 7 additions & 0 deletions unittests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,13 @@ def test_reruns_with_duration(run_reframe):
assert returncode == 1


def test_exitcode_timeout(run_reframe):
assert_no_crash(*run_reframe(
more_options=['--duration=5s', '-n^HelloTest'],
checkpath=['unittests/resources/checks/hellocheck.py']
))


@pytest.fixture(params=['name', 'rname', 'uid', 'ruid', 'random'])
def exec_order(request):
return request.param
Expand Down

0 comments on commit 93eef0f

Please sign in to comment.