summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2013-01-11 16:41:38 +0200
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>2014-01-14 13:48:23 +0200
commit7ce9a7c9df5193395f9e98642e4c847d3e5f43c6 (patch)
tree8f0d92a642f6cba15902b78895a03ba9a4831367 /tests
parent2d685c8fd8ee21c4a5e8581866a0b39dad4d74e4 (diff)
downloadgit-buildpackage-7ce9a7c9df5193395f9e98642e4c847d3e5f43c6.tar.gz
git-buildpackage-7ce9a7c9df5193395f9e98642e4c847d3e5f43c6.tar.bz2
git-buildpackage-7ce9a7c9df5193395f9e98642e4c847d3e5f43c6.zip
rpm.SpecFile: drop the internal 'patches' structure
To get rid of duplicate data tracking. Also, add test for testing the macro expansion of patch and source names. Also add tests for SpecFile.patchseries. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_rpm.py23
-rw-r--r--tests/test_rpm_data/specs/gbp-test-tags.spec7
2 files changed, 27 insertions, 3 deletions
diff --git a/tests/test_rpm.py b/tests/test_rpm.py
index 01d8b277..830e4506 100644
--- a/tests/test_rpm.py
+++ b/tests/test_rpm.py
@@ -199,6 +199,7 @@ class TestSpecFile(object):
spec.protected('_delete_tag')('source', 0)
spec.protected('_delete_tag')('patch', 0)
spec.protected('_delete_tag')('patch', -1)
+ assert spec.protected('_patches')() == {}
prev = spec.protected('_delete_tag')('invalidtag', None)
with assert_raises(GbpError):
@@ -248,8 +249,28 @@ class TestSpecFile(object):
assert val['value'] == rval, ("'%s:' is '%s', expecting '%s'" %
(name, val['value'], rval))
assert spec.ignorepatches == []
+ # Check patch numbers and patch filenames
+ patches = {patch['num']: patch['linevalue'] for patch in
+ spec.protected('_tags')['patch']['lines']}
+ assert patches == {0: 'my_patch0', -1: 'my_patch'}
- assert spec.patches.keys() == [0, -1]
+ def test_patch_series(self):
+ """Test the getting the patches as a patchseries"""
+ spec_filepath = os.path.join(SPEC_DIR, 'gbp-test-native.spec')
+ spec = SpecFileTester(spec_filepath)
+
+ assert len(spec.patchseries()) == 0
+ spec.update_patches(['1.patch', '2.patch', '3.patch'])
+ assert len(spec.patchseries()) == 3
+ spec.protected('_gbp_tags')['ignore-patches'].append({'args': "0"})
+ spec.update_patches(['4.patch'])
+ assert len(spec.patchseries()) == 1
+ assert len(spec.patchseries(ignored=True)) == 2
+ spec.protected('_delete_special_macro')('patch', 0)
+ assert len(spec.patchseries(ignored=True)) == 1
+ series = spec.patchseries(unapplied=True, ignored=True)
+ assert len(series) == 2
+ assert os.path.basename(series[-1].path) == '4.patch'
class TestUtilityFunctions(object):
diff --git a/tests/test_rpm_data/specs/gbp-test-tags.spec b/tests/test_rpm_data/specs/gbp-test-tags.spec
index 47421a9d..ee4c2b94 100644
--- a/tests/test_rpm_data/specs/gbp-test-tags.spec
+++ b/tests/test_rpm_data/specs/gbp-test-tags.spec
@@ -9,6 +9,9 @@
%define test_arch_os_tags %(test -n "$GBP_SKIP_ARCH_OS_TAGS" && echo 0 || echo 1)
+%define source_fn_base source
+%define patch_fn_base patch
+
# Gbp-Undefined-Tag: foobar
# Test that we accept different cases
@@ -27,8 +30,8 @@ Packager: my_packager
Url: my_url
Vcs: my_vcs
Source: my_source
-Patch: my_patch
-Patch0: my_patch0
+Patch: my_%patch_fn_base
+Patch0: my_%{patch_fn_base}0
Nosource: 0
Nopatch: 0
#Icon: my_icon