From: Simon Glass Date: Sat, 10 May 2025 11:05:09 +0000 (+0200) Subject: patman: Support returning the parsers to use X-Git-Tag: v2025.10-rc1~118^2~69^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dff62ec8b4034ff97e21739e6c2eb8f2b4312b5f;p=thirdparty%2Fu-boot.git patman: Support returning the parsers to use The parsing tests need to be able to try invalid arguments to make sure that these are handled correctly. Provide a way to return the parsers being used, as well as to pass in the parsers to use. This feature is needed in test_series_no_subcmd(), for example. Signed-off-by: Simon Glass --- diff --git a/tools/patman/cmdline.py b/tools/patman/cmdline.py index e34cf126556..1b2a32c99f7 100644 --- a/tools/patman/cmdline.py +++ b/tools/patman/cmdline.py @@ -209,10 +209,13 @@ def setup_parser(): test_parser.add_argument('testname', type=str, default=None, nargs='?', help="Specify the test to run") - return parser + parsers = { + 'main': parser, + } + return parsers -def parse_args(argv=None, config_fname=None, parser=None): +def parse_args(argv=None, config_fname=None, parsers=None): """Parse command line arguments from sys.argv[] Args: @@ -225,8 +228,9 @@ def parse_args(argv=None, config_fname=None, parser=None): options: command line options args: command lin arguments """ - if not parser: - parser = setup_parser() + if not parsers: + parsers = setup_parser() + parser = parsers['main'] # Parse options twice: first to get the project and second to handle # defaults properly (which depends on project)