patman: Add tests for help

Add a few tests to make sure that help is provided when requested.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2025-05-08 06:01:28 +02:00
parent 79addcc904
commit b77a42bc75

View File

@ -18,6 +18,7 @@ import unittest
import pygit2
from u_boot_pylib import command
from u_boot_pylib import gitutil
from u_boot_pylib import terminal
from u_boot_pylib import tools
@ -83,6 +84,8 @@ class TestFunctional(unittest.TestCase):
self.tmpdir = tempfile.mkdtemp(prefix='patman.')
self.gitdir = os.path.join(self.tmpdir, '.git')
self.repo = None
self._patman_pathname = sys.argv[0]
self._patman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
def tearDown(self):
if self.preserve_outdirs:
@ -784,6 +787,28 @@ diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
finally:
os.chdir(orig_dir)
def _RunPatman(self, *args):
all_args = [self._patman_pathname] + list(args)
return command.run_one(*all_args, capture=True, capture_stderr=True)
def testFullHelp(self):
command.TEST_RESULT = None
result = self._RunPatman('-H')
help_file = os.path.join(self._patman_dir, 'README.rst')
# Remove possible extraneous strings
extra = '::::::::::::::\n' + help_file + '\n::::::::::::::\n'
gothelp = result.stdout.replace(extra, '')
self.assertEqual(len(gothelp), os.path.getsize(help_file))
self.assertEqual(0, len(result.stderr))
self.assertEqual(0, result.return_code)
def testHelp(self):
command.TEST_RESULT = None
result = self._RunPatman('-h')
self.assertTrue(len(result.stdout) > 1000)
self.assertEqual(0, len(result.stderr))
self.assertEqual(0, result.return_code)
@staticmethod
def _fake_patchwork(subpath):
"""Fake Patchwork server for the function below