summaryrefslogtreecommitdiff
path: root/tests
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-03-27 20:33:28 +0100
commit15d87fb04cba371885d57bb6fd899f79380f1c2e (patch)
tree10907ccb9ceff0286c5ff946bfc55a502909645a /tests
parent5dd598fb8f2a9109189fad6cf631811f12ce2130 (diff)
downloadgit-buildpackage-15d87fb04cba371885d57bb6fd899f79380f1c2e.tar.gz
git-buildpackage-15d87fb04cba371885d57bb6fd899f79380f1c2e.tar.bz2
git-buildpackage-15d87fb04cba371885d57bb6fd899f79380f1c2e.zip
tests: more robust check for the default urgency level of dch
The dch tool might not report it's version if it is incorrectly compiled. Create a dummy changelog and parse it "manually" to determine the default urgency level. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/testutils.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/tests/testutils.py b/tests/testutils.py
index 0b935b7c..d04f5fe9 100644
--- a/tests/testutils.py
+++ b/tests/testutils.py
@@ -91,17 +91,22 @@ class MockedChangeLog(ChangeLog):
def get_dch_default_urgency():
"""Determine the default urgency level used by dch"""
+ urgency='medium'
+ tmp_dch_name = '__test_dch'
try:
- popen = subprocess.Popen(['dch', '--version'], stdout=subprocess.PIPE)
- out, _err = popen.communicate()
+ dch_cmd = ['dch', '--create', '--empty', '--changelog', tmp_dch_name,
+ '--package=foo', '--newversion=1',
+ '--distribution=UNRELEASED']
+ ret = subprocess.Popen(dch_cmd).wait()
except OSError:
- urgency='medium'
+ pass
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'
+ if ret == 0:
+ with open(tmp_dch_name) as dchfile:
+ header = dchfile.readline().strip()
+ urgency = header.split()[-1].replace('urgency=', '')
+ finally:
+ if os.path.isfile(tmp_dch_name):
+ os.unlink(tmp_dch_name)
return urgency