[PATCH 13/30] patman: Support extra test features
Simon Glass
sjg at chromium.org
Tue Apr 29 15:22:10 CEST 2025
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 at chromium.org>
---
tools/patman/__main__.py | 4 +++-
tools/patman/cmdline.py | 6 ++++++
tools/patman/func_test.py | 24 +++++++++++++++++++++++-
3 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/tools/patman/__main__.py b/tools/patman/__main__.py
index 6aadf767eca..1d1eaa19125 100755
--- a/tools/patman/__main__.py
+++ b/tools/patman/__main__.py
@@ -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'])
diff --git a/tools/patman/cmdline.py b/tools/patman/cmdline.py
index 562bc823f60..a7327a20665 100644
--- a/tools/patman/cmdline.py
+++ b/tools/patman/cmdline.py
@@ -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')
diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index 161b5ad4288..85e7b475d90 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -53,6 +53,25 @@ class TestFunctional(unittest.TestCase):
mary = 'Mary Bloggs <mary at 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
--
2.43.0
More information about the U-Boot
mailing list