diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2019-07-26 03:13:46 +0530 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2019-07-26 11:56:39 +0300 |
commit | fcecedc10e7c672288de5f9bead0d497673a4204 (patch) | |
tree | 83557c6772b057607019df593fb86cd1ef316c7b /run_unittests.py | |
parent | ab0e65c19677f47243e204054375f84e72dc61ef (diff) | |
download | meson-fcecedc10e7c672288de5f9bead0d497673a4204.zip meson-fcecedc10e7c672288de5f9bead0d497673a4204.tar.gz meson-fcecedc10e7c672288de5f9bead0d497673a4204.tar.bz2 |
unit tests: Convert unittest args to pytest
Allows people to run specific tests and/or enable verbose mode.
Diffstat (limited to 'run_unittests.py')
-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 1ac4c53..0bd2c02 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') |