[PATCH 16/25] patman: Support returning the parsers to use

Simon Glass sjg at chromium.org
Sat May 10 13:05:09 CEST 2025


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 <sjg at chromium.org>
---

 tools/patman/cmdline.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

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)
-- 
2.43.0



More information about the U-Boot mailing list