patman: Support extra test features
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>
This commit is contained in:
@@ -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'])
|
||||
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user