aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2017-09-14 14:35:39 +0200
committerGuido Günther <agx@sigxcpu.org>2017-09-14 18:32:12 +0200
commitdb5c6700943706aa5f68e67769144b3a1efca8c5 (patch)
tree0bd3e8003718bcf192e09e1dd4d13b184f0f7aaa /tests
parent23b334c511e80a7f9dc30e1b54993a62966fe138 (diff)
Add tag command
by splitting out the code from buildpackage This is shorter than running gbp buildpackage --git-tag-only Closes: #797086
Diffstat (limited to 'tests')
-rw-r--r--tests/component/deb/test_tag.py77
1 files changed, 77 insertions, 0 deletions
diff --git a/tests/component/deb/test_tag.py b/tests/component/deb/test_tag.py
new file mode 100644
index 00000000..f56dabb3
--- /dev/null
+++ b/tests/component/deb/test_tag.py
@@ -0,0 +1,77 @@
+# vim: set fileencoding=utf-8 :
+#
+# (C) 2015-2017 Guido Günther <agx@sigxcpu.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, please see
+# <http://www.gnu.org/licenses/>
+
+import os
+
+from tests.component import ComponentTestBase
+from tests.component.deb import DEB_TEST_DATA_DIR
+from tests.component.deb.fixtures import RepoFixtures
+
+from nose.tools import ok_, eq_
+
+from gbp.scripts.tag import main as tag
+from gbp.scripts.pq import main as pq
+
+
+class TestTag(ComponentTestBase):
+ """Test tagging a debian package"""
+
+ @staticmethod
+ def _dsc_name(pkg, version, dir):
+ return os.path.join(DEB_TEST_DATA_DIR,
+ dir,
+ '%s_%s.dsc' % (pkg, version))
+
+ @RepoFixtures.native()
+ def test_tag(self, repo):
+ """Test that tagging a native debian package works"""
+ repo.delete_tag('debian/0.4.14') # make sure we can tag again
+ eq_(repo.has_tag('debian/0.4.14'), False)
+ ret = tag(['arg0',
+ '--posttag=printenv > posttag.out'])
+ ok_(ret == 0, "Tagging the package failed")
+ eq_(os.path.exists('posttag.out'), True)
+ self.check_hook_vars('posttag', [("GBP_TAG", "debian/0.4.14"),
+ ("GBP_BRANCH", "master"),
+ "GBP_SHA1"])
+ eq_(repo.head, repo.rev_parse('debian/0.4.14^{}'))
+
+ @RepoFixtures.quilt30()
+ def test_tag_pq_branch(self, repo):
+ ret = pq(['argv0', 'import'])
+ eq_(repo.rev_parse('master'), repo.rev_parse('debian/2.8-1^{}'))
+ eq_(ret, 0)
+ eq_(repo.branch, 'patch-queue/master')
+ self.add_file(repo, 'foo.txt')
+ ret = tag(['argv0', '--retag', '--ignore-branch'])
+ eq_(ret, 0)
+ eq_(repo.branch, 'patch-queue/master')
+ eq_(repo.rev_parse('patch-queue/master^{}^'), repo.rev_parse('debian/2.8-1^{}'))
+
+ @RepoFixtures.quilt30()
+ def test_tag_detached_head(self, repo):
+ """
+ Test that tagging works with an detached head (#863167)
+ """
+ eq_(repo.rev_parse('master^{}'), repo.rev_parse('debian/2.8-1^{}'))
+ self.add_file(repo, 'debian/foo.txt')
+ repo.checkout("HEAD~")
+ ret = tag(['argv0', '--retag', '--ignore-branch'])
+ eq_(ret, 0)
+ repo.checkout("master")
+ eq_(repo.rev_parse('master~^{}'), repo.rev_parse('debian/2.8-1^{}'))