Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cli] [test] Add some useful pytest arguments #1465

Merged
merged 2 commits into from
Jul 12, 2020
Merged
Changes from 1 commit
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
36 changes: 36 additions & 0 deletions python/taichi/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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 matched the keys')
archibate marked this conversation as resolved.
Show resolved Hide resolved
parser.add_argument('-m',
'--marks',
required=False,
default=None,
dest='marks',
type=str,
help='Only run tests with specific marks')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What're marks?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g.:

@pytest.mark.xumingkuan
def test_hello():
  ...
ti test -m xumingkuan

I'll add a doc later clarify the test infrastructure.

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 first failed test')
archibate marked this conversation as resolved.
Show resolved Hide resolved
parser.add_argument('-C',
'--coverage',
required=False,
Expand Down