From 00e41eb0fffd56b0b39d2a221d40b68ed885078d Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Thu, 16 Jun 2022 02:02:21 +0200 Subject: [PATCH] test-runner: Fix parsing for some arguments Currently the parameter values reach run-tests by first being parsed by runner.py's RunnerArgParser, then the resulting object members being encoded as a commandline string, then as environment variables, then the environment being converted to a python string list and passed to RunnerCoreArgParser again. Where argument names (like --sub-tests) had dashes, the object members had underscores (.sub_tests), this wasn't taken into account when building the python string list from environment variables so convert all underscores to dashes and hope that all the names match now. Additionally some arguments used nargs='1' or nargs='*' which resulted in their python values becoming lists. They were converted back to command line arguments such as: --sub_tests ['static_test.py'], and when parsed by RunnerCoreArgParser again, the values ended up being lists of lists. In all three cases it seems the actual user of the parsed value actually expects a single string with comma-separated substrings in it so just drop the nargs= uses. --- tools/runner.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tools/runner.py b/tools/runner.py index 2ce26de0..b018a0ad 100644 --- a/tools/runner.py +++ b/tools/runner.py @@ -108,7 +108,7 @@ class RunnerCoreArgParse(ArgumentParser): help='Enables iwmon output to file') self.add_argument('--sub-tests', '-S', metavar='', - type=str, nargs=1, help='List of subtests to run', + type=str, help='List of subtests to run', default=None, dest='sub_tests') self.add_argument('--result', '-e', type=os.path.abspath, @@ -131,8 +131,6 @@ class RunnerCoreArgParse(ArgumentParser): auto_unit_group.add_argument('--unit-tests', '-U', metavar='', type=str, - nargs='?', - const='*', help='List of unit tests to run', dest='unit_tests') @@ -141,7 +139,6 @@ class RunnerCoreArgParse(ArgumentParser): valgrind_gdb_group.add_argument('--gdb', '-g', metavar='', type=str, - nargs=1, help='Run gdb on specified executable', dest='gdb') valgrind_gdb_group.add_argument('--valgrind', '-V', @@ -156,7 +153,7 @@ class RunnerCoreArgParse(ArgumentParser): options = [] for k, v in os.environ.items(): - options.append('--' + k) + options.append('--' + k.replace('_', '-')) options.append(v) return self.parse_known_args(args=options, namespace=RunnerNamespace())[0]