aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2014-01-07 16:10:03 +0200
committerGuido G√ľnther <agx@sigxcpu.org>2014-01-07 17:34:18 +0100
commite876beb4461a35f1a1647bb1f24611e2016353a6 (patch)
tree6617751f4ce481fd42d73f2476dd31b46a053f28
parent49f0e44ac45a77faca1e78d8ce77f73a0d62ddbc (diff)
tests: adapt dch tests for older devscripts
Determine the default urgency level by determining the version number of the dch tool from command line. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rw-r--r--tests/11_test_dch_main.py38
-rw-r--r--tests/testutils.py18
2 files changed, 39 insertions, 17 deletions
diff --git a/tests/11_test_dch_main.py b/tests/11_test_dch_main.py
index e7de1c43..dbfc25cd 100644
--- a/tests/11_test_dch_main.py
+++ b/tests/11_test_dch_main.py
@@ -6,42 +6,46 @@ from . import context
import unittest
-from tests.testutils import DebianGitTestRepo, OsReleaseFile
+from tests.testutils import (DebianGitTestRepo, OsReleaseFile,
+ get_dch_default_urgency)
from gbp.scripts import dch
import os
import re
+# Older dch compatibility
+default_urgency = get_dch_default_urgency()
+
# For Ubuntu compatibility
os_release = OsReleaseFile('/etc/lsb-release')
# OS release codename and snapshot of version 0.9-2~1
if os_release['DISTRIB_ID'] == 'Ubuntu':
os_codename = os_release['DISTRIB_CODENAME']
- snap_header_0_9 = r'^test-package\s\(0.9-1ubuntu1~1\.gbp([0-9a-f]{6})\)\sUNRELEASED;\surgency=medium'
+ snap_header_0_9 = r'^test-package\s\(0.9-1ubuntu1~1\.gbp([0-9a-f]{6})\)\sUNRELEASED;\surgency=%s' % default_urgency
new_version_0_9 = '0.9-1ubuntu1'
else:
os_codename = 'unstable'
- snap_header_0_9 = r'^test-package\s\(0.9-2~1\.gbp([0-9a-f]{6})\)\sUNRELEASED;\surgency=medium'
+ snap_header_0_9 = r'^test-package\s\(0.9-2~1\.gbp([0-9a-f]{6})\)\sUNRELEASED;\surgency=%s' % default_urgency
new_version_0_9 = '0.9-2'
# Snapshot of version 1.0-1~1
-snap_header_1 = r'^test-package\s\(1.0-1~1\.gbp([0-9a-f]{6})\)\sUNRELEASED;\surgency=medium'
+snap_header_1 = r'^test-package\s\(1.0-1~1\.gbp([0-9a-f]{6})\)\sUNRELEASED;\surgency=%s' % default_urgency
# Snapshot of version 1.0-1~2
-snap_header_1_2 = r'^test-package\s\(1.0-1~2\.gbp([0-9a-f]{6})\)\sUNRELEASED;\surgency=medium'
+snap_header_1_2 = r'^test-package\s\(1.0-1~2\.gbp([0-9a-f]{6})\)\sUNRELEASED;\surgency=%s' % default_urgency
snap_mark = r'\s{2}\*{2}\sSNAPSHOT\sbuild\s@'
deb_tag = "debian/0.9-1"
deb_tag_msg = "Pre stable release version 0.9-1"
-cl_debian = """test-package (0.9-1) unstable; urgency=medium
+cl_debian = """test-package (0.9-1) unstable; urgency=%s
[ Debian Maintainer ]
* New pre stable upstream release
-- Debian Maintainer <maint@debian.org> Mon, 17 Oct 2011 10:15:22 +0200
-"""
+""" % default_urgency
@unittest.skipIf(not os.path.exists('/usr/bin/dch'), "Dch not found")
@@ -85,7 +89,7 @@ class TestScriptDch(DebianGitTestRepo):
def test_dch_main_new_upstream_version(self):
"""Test dch.py like git-dch script does: new upstream version"""
lines = self.run_dch()
- self.assertEqual("test-package (1.0-1) UNRELEASED; urgency=medium\n", lines[0])
+ self.assertEqual("test-package (1.0-1) UNRELEASED; urgency=%s\n" % default_urgency, lines[0])
self.assertIn(""" * added debian/control\n""", lines)
@@ -93,7 +97,7 @@ class TestScriptDch(DebianGitTestRepo):
"""Test dch.py like git-dch script does: new upstream version - release"""
options = ["--release"]
lines = self.run_dch(options)
- self.assertEqual("test-package (1.0-1) %s; urgency=medium\n" % os_codename, lines[0])
+ self.assertEqual("test-package (1.0-1) %s; urgency=%s\n" % (os_codename, default_urgency), lines[0])
self.assertIn(""" * added debian/control\n""", lines)
@@ -101,7 +105,7 @@ class TestScriptDch(DebianGitTestRepo):
"""Test dch.py like git-dch script does: new upstream version - guess last commit"""
options = ["--auto"]
lines = self.run_dch(options)
- self.assertEqual("test-package (1.0-1) UNRELEASED; urgency=medium\n", lines[0])
+ self.assertEqual("test-package (1.0-1) UNRELEASED; urgency=%s\n" % default_urgency, lines[0])
self.assertIn(""" * added debian/control\n""", lines)
@@ -170,7 +174,7 @@ class TestScriptDch(DebianGitTestRepo):
"""Test dch.py like git-dch script does: new upstream version - auto - release"""
options = ["--auto", "--release"]
lines = self.run_dch(options)
- self.assertEqual("test-package (1.0-1) %s; urgency=medium\n" % os_codename, lines[0])
+ self.assertEqual("test-package (1.0-1) %s; urgency=%s\n" % (os_codename, default_urgency), lines[0])
self.assertIn(""" * added debian/control\n""", lines)
@@ -196,7 +200,7 @@ class TestScriptDch(DebianGitTestRepo):
"""Test dch.py like git-dch script does: new upstream version - set distribution"""
options = ["--distribution=testing", "--force-distribution"]
lines = self.run_dch(options)
- self.assertEqual("test-package (1.0-1) testing; urgency=medium\n", lines[0])
+ self.assertEqual("test-package (1.0-1) testing; urgency=%s\n" % default_urgency, lines[0])
self.assertIn(""" * added debian/control\n""", lines)
@@ -204,7 +208,7 @@ class TestScriptDch(DebianGitTestRepo):
"""Test dch.py like git-dch script does: new upstream version - release - set distribution"""
options = ["--release", "--distribution=testing", "--force-distribution"]
lines = self.run_dch(options)
- self.assertEqual("test-package (1.0-1) testing; urgency=medium\n", lines[0])
+ self.assertEqual("test-package (1.0-1) testing; urgency=%s\n" % default_urgency, lines[0])
self.assertIn(""" * added debian/control\n""", lines)
@@ -306,7 +310,7 @@ class TestScriptDch(DebianGitTestRepo):
self.repo.create_tag("debian/0.9-1", msg="Pre stable release version 0.9-1", commit="HEAD~2")
self.repo.delete_tag("upstream/1.0")
lines = self.run_dch()
- self.assertEqual("test-package (%s) UNRELEASED; urgency=medium\n" % new_version_0_9, lines[0])
+ self.assertEqual("test-package (%s) UNRELEASED; urgency=%s\n" % (new_version_0_9, default_urgency), lines[0])
self.assertIn(""" * added debian/control\n""", lines)
@@ -315,7 +319,7 @@ class TestScriptDch(DebianGitTestRepo):
self.repo.delete_tag("upstream/1.0")
options = ["--release"]
lines = self.run_dch(options)
- self.assertEqual("test-package (%s) %s; urgency=medium\n" % (new_version_0_9, os_codename), lines[0])
+ self.assertEqual("test-package (%s) %s; urgency=%s\n" % (new_version_0_9, os_codename, default_urgency), lines[0])
self.assertIn(""" * added debian/control\n""", lines)
@@ -324,7 +328,7 @@ class TestScriptDch(DebianGitTestRepo):
self.repo.delete_tag("upstream/1.0")
options = ["--auto"]
lines = self.run_dch(options)
- self.assertEqual("test-package (%s) UNRELEASED; urgency=medium\n" % new_version_0_9, lines[0])
+ self.assertEqual("test-package (%s) UNRELEASED; urgency=%s\n" % (new_version_0_9, default_urgency), lines[0])
self.assertIn(""" * added debian/control\n""", lines)
@@ -345,7 +349,7 @@ class TestScriptDch(DebianGitTestRepo):
self.repo.delete_tag("upstream/1.0")
options = ["--auto", "--release"]
lines = self.run_dch(options)
- self.assertEqual("test-package (%s) %s; urgency=medium\n" % (new_version_0_9, os_codename), lines[0])
+ self.assertEqual("test-package (%s) %s; urgency=%s\n" % (new_version_0_9, os_codename, default_urgency), lines[0])
self.assertIn(""" * added debian/control\n""", lines)
diff --git a/tests/testutils.py b/tests/testutils.py
index c8631955..0b935b7c 100644
--- a/tests/testutils.py
+++ b/tests/testutils.py
@@ -3,6 +3,7 @@
from . import context
import os
+import subprocess
import unittest
import gbp.log
@@ -87,3 +88,20 @@ class MockedChangeLog(ChangeLog):
ChangeLog.__init__(self,
contents=self.contents % (version, changes))
+
+def get_dch_default_urgency():
+ """Determine the default urgency level used by dch"""
+ try:
+ popen = subprocess.Popen(['dch', '--version'], stdout=subprocess.PIPE)
+ out, _err = popen.communicate()
+ except OSError:
+ urgency='medium'
+ else:
+ verstr = out.splitlines()[0].split()[-1]
+ major, minor = verstr.split('.')[0:2]
+ if int(major) <= 2 and int(minor) <= 12:
+ urgency = 'low'
+ else:
+ urgency = 'medium'
+ return urgency
+