summaryrefslogtreecommitdiff
path: root/tools/patman/func_test.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-10-29 21:46:34 -0600
committerSimon Glass <sjg@chromium.org>2020-11-05 09:11:31 -0700
commitbe051c0c7741d67f5093f6b61b64c45eb200235b (patch)
treeedeac766a4773d11556b8092d9d7daa531f9252f /tools/patman/func_test.py
parentb3348522b753450be9e442452bf42aaa032d15d1 (diff)
patman: Detect missing upstream in CountCommitsToBranch
At present if we fail to find the upstream then the error output is piped to wc, resulting in bogus results. Avoid the pipe and check the output directly. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/patman/func_test.py')
-rw-r--r--tools/patman/func_test.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index b39e3f671dc..cce3905c093 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -588,3 +588,22 @@ diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
self.assertEqual(
["Found possible blank line(s) at end of file 'lib/fdtdec.c'"],
pstrm.commit.warn)
+
+ @unittest.skipIf(not HAVE_PYGIT2, 'Missing python3-pygit2')
+ def testNoUpstream(self):
+ """Test CountCommitsToBranch when there is no upstream"""
+ repo = self.make_git_tree()
+ target = repo.lookup_reference('refs/heads/base')
+ self.repo.checkout(target, strategy=pygit2.GIT_CHECKOUT_FORCE)
+
+ # Check that it can detect the current branch
+ try:
+ orig_dir = os.getcwd()
+ os.chdir(self.gitdir)
+ with self.assertRaises(ValueError) as exc:
+ gitutil.CountCommitsToBranch(None)
+ self.assertIn(
+ "Failed to determine upstream: fatal: no upstream configured for branch 'base'",
+ str(exc.exception))
+ finally:
+ os.chdir(orig_dir)