From 70df82ace092afa488a9e8b1ddd4eceee8e1c62e Mon Sep 17 00:00:00 2001 From: Harold Zeng Date: Mon, 27 Apr 2020 15:28:50 +0800 Subject: [PATCH] Add option --no-exit-first --- azdev/operations/tests/__init__.py | 6 +++++- azdev/operations/tests/pytest_runner.py | 5 ++++- azdev/params.py | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/azdev/operations/tests/__init__.py b/azdev/operations/tests/__init__.py index 17c76041f..7ca1c8f2e 100644 --- a/azdev/operations/tests/__init__.py +++ b/azdev/operations/tests/__init__.py @@ -32,6 +32,7 @@ # pylint: disable=too-many-statements def run_tests(tests, xml_path=None, discover=False, in_series=False, run_live=False, profile=None, last_failed=False, pytest_args=None, + no_exit_first=False, git_source=None, git_target=None, git_repo=None, cli_ci=False): @@ -105,7 +106,10 @@ def _find_test(index, name): exit_code = 0 with ProfileContext(profile): - runner = get_test_runner(parallel=not in_series, log_path=xml_path, last_failed=last_failed) + runner = get_test_runner(parallel=not in_series, + log_path=xml_path, + last_failed=last_failed, + no_exit_first=no_exit_first) exit_code = runner(test_paths=test_paths, pytest_args=pytest_args) sys.exit(0 if not exit_code else 1) diff --git a/azdev/operations/tests/pytest_runner.py b/azdev/operations/tests/pytest_runner.py index e853a68fd..a98439beb 100644 --- a/azdev/operations/tests/pytest_runner.py +++ b/azdev/operations/tests/pytest_runner.py @@ -11,7 +11,7 @@ from azdev.utilities import call -def get_test_runner(parallel, log_path, last_failed): +def get_test_runner(parallel, log_path, last_failed, no_exit_first): """Create a pytest execution method""" def _run(test_paths, pytest_args): @@ -22,6 +22,9 @@ def _run(test_paths, pytest_args): else: arguments = ['-x', '-v', '-p no:warnings', '--log-level=WARN', '--junit-xml', log_path] + if no_exit_first: + arguments.remove('-x') + arguments.extend(test_paths) if parallel: arguments += ['-n', 'auto'] diff --git a/azdev/params.py b/azdev/params.py index 6d2c90402..0b8447a05 100644 --- a/azdev/params.py +++ b/azdev/params.py @@ -50,6 +50,7 @@ def load_arguments(self, _): c.argument('profile', options_list='--profile', help='Run automation against a specific profile. If omit, the tests will run against current profile.') c.argument('pytest_args', nargs=argparse.REMAINDER, options_list=['--pytest-args', '-a'], help='Denotes the remaining args will be passed to pytest.') c.argument('last_failed', options_list='--lf', action='store_true', help='Re-run the last tests that failed.') + c.argument('no_exit_first', options_list='--no-exitfirst', action='store_true', help='Do not exit on first error or failed test') # CI parameters c.argument('cli_ci',