aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mtest.py
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2018-05-13 10:36:58 -0400
committerXavier Claessens <xavier.claessens@collabora.com>2018-10-04 09:40:21 -0400
commit37067a53c4b3b99982ef8e1f431ba0c9302b66e8 (patch)
tree7d3ebbb24b45bf6cfdb2a76a4dcdabf8808a346c /mesonbuild/mtest.py
parent5af2717e76015b47bfc2b11d4034099d9b62d978 (diff)
downloadmeson-37067a53c4b3b99982ef8e1f431ba0c9302b66e8.zip
meson-37067a53c4b3b99982ef8e1f431ba0c9302b66e8.tar.gz
meson-37067a53c4b3b99982ef8e1f431ba0c9302b66e8.tar.bz2
Use a single ArgumentParser for all subcommands
This has the adventage that "meson --help" shows a list of all commands, making them discoverable. This also reduce the manual parsing of arguments to the strict minimum needed for backward compatibility.
Diffstat (limited to 'mesonbuild/mtest.py')
-rw-r--r--mesonbuild/mtest.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py
index 8d9a585..78f2252 100644
--- a/mesonbuild/mtest.py
+++ b/mesonbuild/mtest.py
@@ -60,8 +60,7 @@ def determine_worker_count():
num_workers = 1
return num_workers
-def buildparser():
- parser = argparse.ArgumentParser(prog='meson test')
+def add_arguments(parser):
parser.add_argument('--repeat', default=1, dest='repeat', type=int,
help='Number of times to run the tests.')
parser.add_argument('--no-rebuild', default=False, action='store_true',
@@ -102,7 +101,6 @@ def buildparser():
help='Arguments to pass to the specified test(s) or all tests')
parser.add_argument('args', nargs='*',
help='Optional list of tests to run')
- return parser
def returncode_to_status(retcode):
@@ -737,9 +735,7 @@ def rebuild_all(wd):
return True
-def run(args):
- options = buildparser().parse_args(args)
-
+def run(options):
if options.benchmark:
options.num_processes = 1
@@ -784,3 +780,9 @@ def run(args):
else:
print(e)
return 1
+
+def run_with_args(args):
+ parser = argparse.ArgumentParser(prog='meson test')
+ add_arguments(parser)
+ options = parser.parse_args(args)
+ return run(options)