From 96ab837d1a3e513b8ec36489636ddb9645a233d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E4=BA=8E=E6=96=8C?= <1931127624@qq.com> Date: Sun, 12 Jul 2020 12:38:00 +0800 Subject: [PATCH] [cli] [test] Add some useful pytest arguments (#1465) * [cli] [test] Add some useful pytest arguments * Apply suggestions from code review Co-authored-by: xumingkuan Co-authored-by: xumingkuan --- python/taichi/main.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/python/taichi/main.py b/python/taichi/main.py index 2ba83fdc2b2b3..36f53cb1cd971 100644 --- a/python/taichi/main.py +++ b/python/taichi/main.py @@ -702,6 +702,14 @@ def _test_python(args): pytest_args += ['-s', '-v'] if args.rerun: pytest_args += ['--reruns', args.rerun] + if args.keys: + pytest_args += ['-k', args.keys] + if args.marks: + pytest_args += ['-m', args.marks] + if args.failed_first: + pytest_args += ['--failed-first'] + if args.fail_fast: + pytest_args += ['--exitfirst'] try: if args.coverage: pytest_args += ['--cov-branch', '--cov=python/taichi'] @@ -815,6 +823,34 @@ def test(self, arguments: list = sys.argv[2:]): dest='rerun', type=str, help='Rerun failed tests for given times') + parser.add_argument('-k', + '--keys', + required=False, + default=None, + dest='keys', + type=str, + help='Only run tests that match the keys') + parser.add_argument('-m', + '--marks', + required=False, + default=None, + dest='marks', + type=str, + help='Only run tests with specific marks') + parser.add_argument('-f', + '--failed-first', + required=False, + default=None, + dest='failed_first', + action='store_true', + help='Run the previously failed test first') + parser.add_argument('-x', + '--fail-fast', + required=False, + default=None, + dest='fail_fast', + action='store_true', + help='Exit instantly on the first failed test') parser.add_argument('-C', '--coverage', required=False,