aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2017-05-22 08:37:18 +0200
committerGuido Günther <agx@sigxcpu.org>2017-05-22 08:43:19 +0200
commit8ea5d6f4e48687ba4ce195c41bbc27684e092f10 (patch)
tree98f9bbc6b0186ab91cf3b914dea03cc06d10c9a9
parent2f806bc7b9ed792d172c201bf0ae14dec76ccf45 (diff)
Don't fail tests on older git versions
There are some nuances in reflog handling. Thanks: jean-christophe manciot for reporting this
-rw-r--r--tests/component/deb/test_import_dsc.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/tests/component/deb/test_import_dsc.py b/tests/component/deb/test_import_dsc.py
index e892cea..a0b5bfa 100644
--- a/tests/component/deb/test_import_dsc.py
+++ b/tests/component/deb/test_import_dsc.py
@@ -34,6 +34,22 @@ from gbp.deb.dscfile import DscFile
class TestImportDsc(ComponentTestBase):
"""Test importing of debian source packages"""
+ def _check_reflog(self, repo):
+ reflog, ret = repo._git_getoutput('reflog')
+ # Recent (>= 2.10) git versions create a reflog entry for "git
+ # update-ref HEAD HEAD" while older ones (2.9.4) don't so
+ # reflog[0] is either there or not.
+ if len(reflog) == 3:
+ ok_("gbp: Import Debian changes" in reflog[1])
+ ok_("gbp: Import Upstream version 2.6" in reflog[2])
+ elif len(reflog) == 2:
+ # Furthermore some older git versions (<2.10) fail to set
+ # the reflog correctly on the initial commit so only check
+ # the second
+ ok_("gbp: Import Debian changes" in reflog[0])
+ else:
+ assert ok_(len(reflog) in [2, 3])
+
def test_import_debian_native(self):
"""Test that importing of debian native packages works"""
def _dsc(version):
@@ -112,9 +128,7 @@ class TestImportDsc(ComponentTestBase):
repo = ComponentTestGitRepository('hello-debhelper')
os.chdir('hello-debhelper')
assert len(repo.get_commits()) == 2
- reflog, ret = repo._git_getoutput('reflog')
- ok_("gbp: Import Debian changes" in reflog[1])
- ok_("gbp: Import Upstream version 2.6" in reflog[2])
+ self._check_reflog(repo)
self._check_repo_state(repo, 'master', ['master', 'pristine-tar', 'upstream'])
dsc = _dsc('2.8-1')
assert import_dsc(['arg0',
@@ -239,9 +253,7 @@ class TestImportDsc(ComponentTestBase):
repo = ComponentTestGitRepository('hello-debhelper')
os.chdir('hello-debhelper')
assert len(repo.get_commits()) == 2
- reflog, ret = repo._git_getoutput('reflog')
- ok_("gbp: Import Debian changes" in reflog[1])
- ok_("gbp: Import Upstream version 2.6" in reflog[2])
+ self._check_reflog(repo)
self._check_repo_state(repo, 'master', ['master', 'pristine-tar', 'upstream'])
commitmsg = repo.get_commit_info('HEAD')['body']
ok_("hello-debhelper (2.6-2) unstable; urgency=medium" in commitmsg)