Skip to content
This repository has been archived by the owner on Feb 4, 2020. It is now read-only.

add --ignore-return-codes option to ament test #141

Merged
merged 2 commits into from
Mar 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions ament_tools/verbs/test_pkg/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ def prepare_arguments(parser, args, skip_build_pkg_arguments=False):
type=int, default=0, metavar='N',
help='Rerun failing tests up to N times',
)
parser.add_argument(
'--ignore-return-codes',
action='store_true',
default=False,
help='Ignore return codes from testing packages',
)
return parser


Expand Down Expand Up @@ -75,18 +81,21 @@ def main(opts):
return
try:
handle_build_action(on_test_ret, context)
except SystemExit:
except SystemExit as e:
# check if tests should be rerun
if opts.retest_until_pass > context.test_iteration:
context.test_iteration += 1
print("+++ Testing '%s' again (retry #%d of %d)" %
(pkg_name, context.test_iteration, opts.retest_until_pass))
continue
# there is no way to distinguish why the test returned non zero
# the test invocation itself could have failed:
# return e.code
# but it could have also run successful and only failed some tests:
return
# Automated systems can use --ignore-return-codes to allow them to react to
# a failure to *run* a test but not a failure generated by a test that ran as
# intended. Otherwise, we'll combine the two cases to help users to notice
# when anything went wrong during a test run.
if opts.ignore_return_codes:
return
else:
return e.code
# check if tests should be rerun
if opts.retest_until_fail > context.test_iteration:
context.test_iteration += 1
Expand Down