From 62c7dcf32d1043fa939a1fade0610fec7b6b1b3d Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Thu, 23 Feb 2017 04:44:54 +0530 Subject: [PATCH 1/3] mesontest: Use shlex.split for parsing the wrapper Allows people to pass arguments with spaces in them. Do this using argparse itself instead of doing an isinstance later. --- mesontest.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mesontest.py b/mesontest.py index 980fbee2d..ef5cff656 100755 --- a/mesontest.py +++ b/mesontest.py @@ -16,6 +16,7 @@ # A tool to run tests in many different ways. +import shlex import subprocess, sys, os, argparse import pickle from mesonbuild import build @@ -61,7 +62,7 @@ parser.add_argument('--gdb', default=False, dest='gdb', action='store_true', help='Run test under gdb.') parser.add_argument('--list', default=False, dest='list', action='store_true', help='List available tests.') -parser.add_argument('--wrapper', default=None, dest='wrapper', +parser.add_argument('--wrapper', default=None, dest='wrapper', type=shlex.split, help='wrapper to run tests with (e.g. Valgrind)') parser.add_argument('-C', default='.', dest='wd', help='directory to cd into before running') @@ -421,10 +422,7 @@ TIMEOUT: %4d if self.options.repeat > 1: wrap += ['-ex', 'run', '-ex', 'quit'] elif self.options.wrapper: - if isinstance(self.options.wrapper, str): - wrap = self.options.wrapper.split() - else: - wrap = self.options.wrapper + wrap += self.options.wrapper assert(isinstance(wrap, list)) return wrap From 9fffcef290a84e398dc2b9cdbac0bdfcdd60961a Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Thu, 23 Feb 2017 04:47:55 +0530 Subject: [PATCH 2/3] mesontest: Fix --repeat with --gdb It would add --args to `wrap` repeatedly for each re-run, resulting in gdb erroring out with `--args: No such file or directory.` Also don't make --gdb and --wrapper mutually exclusive. Sometimes people want to run under a wrapper *and* run it under gdb. --- mesontest.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mesontest.py b/mesontest.py index ef5cff656..0cccfe29f 100755 --- a/mesontest.py +++ b/mesontest.py @@ -421,7 +421,9 @@ TIMEOUT: %4d wrap = ['gdb', '--quiet', '--nh'] if self.options.repeat > 1: wrap += ['-ex', 'run', '-ex', 'quit'] - elif self.options.wrapper: + # Signal the end of arguments to gdb + wrap += ['--args'] + if self.options.wrapper: wrap += self.options.wrapper assert(isinstance(wrap, list)) return wrap @@ -452,8 +454,6 @@ TIMEOUT: %4d if self.options.gdb: test.timeout = None - if len(test.cmd_args): - wrap.append('--args') if not test.is_parallel or self.options.gdb: self.drain_futures(futures, logfile, jsonlogfile) From f5b43eef1b9b9a82b24fd7fd05e78af257ed7f4d Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Thu, 23 Feb 2017 04:51:10 +0530 Subject: [PATCH 3/3] mesontest: Support passing test arguments at runtime This is especially useful with the glib testing framework where you can select which tests to run within a single test executable by pasing `-p /some/test/path` --- mesontest.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mesontest.py b/mesontest.py index 0cccfe29f..a1708e386 100755 --- a/mesontest.py +++ b/mesontest.py @@ -90,7 +90,10 @@ parser.add_argument('-t', '--timeout-multiplier', type=float, default=None, ' more time to execute.') parser.add_argument('--setup', default=None, dest='setup', help='Which test setup to use.') -parser.add_argument('args', nargs='*') +parser.add_argument('--test-args', default=[], type=shlex.split, + help='Arguments to pass to the specified test(s) or all tests') +parser.add_argument('args', nargs='*', + help='Optional list of tests to run') class TestRun: def __init__(self, res, returncode, should_fail, duration, stdo, stde, cmd, @@ -190,7 +193,7 @@ class TestHarness: stde = None returncode = GNU_SKIP_RETURNCODE else: - cmd = wrap + cmd + test.cmd_args + cmd = wrap + cmd + test.cmd_args + self.options.test_args starttime = time.time() child_env = os.environ.copy() child_env.update(self.options.global_env.get_env(child_env))