summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2013-08-21 19:21:41 +0200
committerGuido Günther <agx@sigxcpu.org>2013-08-21 21:38:16 +0200
commit938e4cd25d47a0b9230a14e55724a5c3912e2359 (patch)
treeae45670b5ff12fe2467f1562458cac746d7eba7e /tests
parent7a29e4286ceccf8b4c6f132d781a4041e333fc4e (diff)
downloadgit-buildpackage-938e4cd25d47a0b9230a14e55724a5c3912e2359.tar.gz
git-buildpackage-938e4cd25d47a0b9230a14e55724a5c3912e2359.tar.bz2
git-buildpackage-938e4cd25d47a0b9230a14e55724a5c3912e2359.zip
dch: make automatic adding of new sections more robust
This code that determined if we found a snapshot header was obuscated by the code that determines the commits to add. Split those and better document their purpose. Also always return the commit to start from so we don't need to repeat the logic in the uper levels.
Diffstat (limited to 'tests')
-rw-r--r--tests/17_test_dch_guess_documented_commit.py73
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/17_test_dch_guess_documented_commit.py b/tests/17_test_dch_guess_documented_commit.py
new file mode 100644
index 00000000..89eba2d3
--- /dev/null
+++ b/tests/17_test_dch_guess_documented_commit.py
@@ -0,0 +1,73 @@
+# vim: set fileencoding=utf-8 :
+
+"""Test L{Changelog}'s guess_version_from_upstream"""
+
+from . import context
+
+import testutils
+
+from gbp.scripts import dch
+
+class TestGuessDocumentedCommit(testutils.DebianGitTestRepo):
+ def setUp(self):
+ self.version = '1.0-1'
+ self.tagformat = 'debian/%(version)s'
+
+ testutils.DebianGitTestRepo.setUp(self)
+
+ def test_01_from_snapshot_banner(self):
+ """
+ Guess the commit to start from from the snapshot banner
+ """
+ cp = testutils.MockedChangeLog(self.version,
+ "*** SNAPSHOT build @12345 ***")
+ guessed_commit = dch.guess_documented_commit(cp, None, None)
+ self.assertEqual(guessed_commit, '12345')
+
+ def test_02_from_tag(self):
+ """
+ Guess the commit to start from from the tag matching
+ the topmost version in the changelog
+ """
+ cp = testutils.MockedChangeLog(self.version)
+
+ self.add_file('doesnot', 'matter')
+ tag = self.repo.version_to_tag(self.tagformat,
+ self.version)
+ self.repo.create_tag(name=tag,
+ msg="Debian release %s" % self.version,
+ sign=False)
+ commit = self.repo.rev_parse('%s^0' % tag)
+ guessed_commit = dch.guess_documented_commit(cp,
+ self.repo,
+ self.tagformat)
+ self.assertEqual(guessed_commit, commit)
+
+ def test_03_from_changelog_commit(self):
+ """
+ Guess the commit to start from from the commit that
+ last touched the changelog
+ """
+ cp = testutils.MockedChangeLog(self.version)
+
+ self.add_file('debian/changelog', 'foo')
+ commit = self.repo.head
+ self.add_file('doesnot', 'matter')
+ guessed_commit = dch.guess_documented_commit(cp,
+ self.repo,
+ self.tagformat)
+ self.assertEqual(guessed_commit, commit)
+
+ def test_04_not_touched(self):
+ """
+ None of the above matched so we want to start from
+ the beginning of history
+ """
+ cp = testutils.MockedChangeLog(self.version)
+
+ self.add_file('doesnot', 'matter')
+ self.add_file('doesnot', 'mattereither')
+ guessed_commit = dch.guess_documented_commit(cp,
+ self.repo,
+ self.tagformat)
+ self.assertIsNone(guessed_commit)