]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
patman: Support extra test features
authorSimon Glass <sjg@chromium.org>
Tue, 29 Apr 2025 13:22:10 +0000 (07:22 -0600)
committerSimon Glass <sjg@chromium.org>
Tue, 27 May 2025 09:07:41 +0000 (10:07 +0100)
Provide support for the -X flag, which preserves the working directory
used by tests. Also support -N which shows captured output for tests.

Finally, allow selection of a particular test to run.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/patman/__main__.py
tools/patman/cmdline.py
tools/patman/func_test.py

index 6aadf767eca5a82bc38a55012eb525684a6e95f0..1d1eaa19125d8c3ed03ed7d8fca2a44d5667ed8f 100755 (executable)
@@ -40,8 +40,10 @@ def run_patman():
         from patman import func_test
         from patman import test_checkpatch
 
+        to_run = args.testname if args.testname not in [None, 'test'] else None
         result = test_util.run_test_suites(
-            'patman', False, False, False, False, None, None, None,
+            'patman', False, args.verbose, args.no_capture,
+            args.test_preserve_dirs, None, to_run, None,
             [test_checkpatch.TestPatch, func_test.TestFunctional,
              'settings'])
 
index 562bc823f60ebb1d55b81a2dddd8f7de893bad60..a7327a20665aca731ef6a339fd82d2078bab497d 100644 (file)
@@ -41,6 +41,9 @@ def parse_args():
         help='Commits to skip at end of patch list')
     parser.add_argument('-D', '--debug', action='store_true',
         help='Enabling debugging (provides a full traceback on error)')
+    parser.add_argument(
+        '-N', '--no-capture', action='store_true',
+        help='Disable capturing of console output in tests')
     parser.add_argument('-p', '--project', default=project.detect_project(),
                         help="Project name; affects default option values and "
                         "aliases [default: %(default)s]")
@@ -52,6 +55,9 @@ def parse_args():
     parser.add_argument(
         '-v', '--verbose', action='store_true', dest='verbose', default=False,
         help='Verbose output of errors and warnings')
+    parser.add_argument(
+        '-X', '--test-preserve-dirs', action='store_true',
+        help='Preserve and display test-created directories')
     parser.add_argument(
         '-H', '--full-help', action='store_true', dest='full_help',
         default=False, help='Display the README file')
index 161b5ad428878f2f0eaee4f1a854e24a410c967f..85e7b475d904c14ea54c23fbf6dd5b18f7f141c0 100644 (file)
@@ -53,6 +53,25 @@ class TestFunctional(unittest.TestCase):
     mary = 'Mary Bloggs <mary@napierwallies.co.nz>'
     commits = None
     patches = None
+    verbosity = False
+    preserve_outdirs = False
+
+    @classmethod
+    def setup_test_args(cls, preserve_indir=False, preserve_outdirs=False,
+                        toolpath=None, verbosity=None, no_capture=False):
+        """Accept arguments controlling test execution
+
+        Args:
+            preserve_indir: not used
+            preserve_outdir: Preserve the output directories used by tests.
+                Each test has its own, so this is normally only useful when
+                running a single test.
+            toolpath: not used
+        """
+        cls.preserve_outdirs = preserve_outdirs
+        cls.toolpath = toolpath
+        cls.verbosity = verbosity
+        cls.no_capture = no_capture
 
     def setUp(self):
         self.tmpdir = tempfile.mkdtemp(prefix='patman.')
@@ -60,7 +79,10 @@ class TestFunctional(unittest.TestCase):
         self.repo = None
 
     def tearDown(self):
-        shutil.rmtree(self.tmpdir)
+        if self.preserve_outdirs:
+            print(f'Output dir: {self.tmpdir}')
+        else:
+            shutil.rmtree(self.tmpdir)
         terminal.set_print_test_mode(False)
 
     @staticmethod