diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2019-07-26 03:13:46 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2019-07-26 03:13:46 +0530 |
commit | 55082764943bd1689a50e6cb584f528b902aa1d3 (patch) | |
tree | 83557c6772b057607019df593fb86cd1ef316c7b | |
parent | ab0e65c19677f47243e204054375f84e72dc61ef (diff) | |
download | meson-nirbheek/unittest-arg-convert.tar.gz |
unit tests: Convert unittest args to pytestnirbheek/unittest-arg-convert
Allows people to run specific tests and/or enable verbose mode.
-rwxr-xr-x | run_unittests.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/run_unittests.py b/run_unittests.py index 1ac4c5335..0bd2c027b 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -6605,6 +6605,21 @@ def unset_envs(): if v in os.environ: del os.environ[v] +def convert_args(argv): + # If we got passed a list of tests, pass it on + pytest_args = ['-v'] if '-v' in argv else [] + test_list = [] + for arg in argv: + if arg.startswith('-'): + continue + # ClassName.test_name => 'ClassName and test_name' + if '.' in arg: + arg = ' and '.join(arg.split('.')) + test_list.append(arg) + if test_list: + pytest_args += ['-k', ' or '.join(test_list)] + return pytest_args + def main(): unset_envs() try: @@ -6612,6 +6627,7 @@ def main(): # Need pytest-xdist for `-n` arg import xdist # noqa: F401 pytest_args = ['-n', 'auto', './run_unittests.py'] + pytest_args += convert_args(sys.argv[1:]) return subprocess.run(python_command + ['-m', 'pytest'] + pytest_args).returncode except ImportError: print('pytest-xdist not found, using unittest instead') |