]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
qconfig: Move testing into a separate function
authorSimon Glass <sjg@chromium.org>
Wed, 17 Jul 2024 15:57:01 +0000 (16:57 +0100)
committerSimon Glass <sjg@chromium.org>
Fri, 26 Jul 2024 14:01:06 +0000 (08:01 -0600)
Reduce the size of main() by putting this code into its own function.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/qconfig.py

index a33fb2aa22ba2fcad89099dfcee90b636eb7cefd..0bdabccba073e8997efd3f93ab3a27fa71af0fe1 100755 (executable)
@@ -1521,6 +1521,16 @@ doc/develop/moveconfig.rst for documentation.'''
     return parser, parser.parse_args()
 
 
+def do_tests():
+    """Run doctests and unit tests (so far there are no unit tests)"""
+    sys.argv = [sys.argv[0]]
+    fail, _ = doctest.testmod()
+    if fail:
+        return 1
+    unittest.main()
+    return 0
+
+
 def main():
     """Main program"""
     parser, args = parse_args()
@@ -1535,11 +1545,7 @@ def main():
     args.configs = [prefix_config(cfg) for cfg in args.configs]
 
     if args.test:
-        sys.argv = [sys.argv[0]]
-        fail, _ = doctest.testmod()
-        if fail:
-            return 1
-        unittest.main()
+        return do_tests()
 
     if args.scan_source:
         do_scan_source(os.getcwd(), args.update)