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>
diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index 9f3ab50..00aed87 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -18,6 +18,7 @@
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 @@
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 @@
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