summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2013-02-25 12:11:14 +0200
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>2014-01-14 13:48:23 +0200
commit4281c1c9ec42d54437cb4f5ee5b7d4960d058c81 (patch)
treebf4a074ba58a6ca88a9ad3778410abc6cc92bb51 /tests
parent5e7fab7b2f6899347f26eda288ca3ee1e579c5b7 (diff)
downloadgit-buildpackage-4281c1c9ec42d54437cb4f5ee5b7d4960d058c81.tar.gz
git-buildpackage-4281c1c9ec42d54437cb4f5ee5b7d4960d058c81.tar.bz2
git-buildpackage-4281c1c9ec42d54437cb4f5ee5b7d4960d058c81.zip
rpm: support conditionals in patch-export
One can now define conditional patches that are enclosed in '%if' or '%ifarch' when the spec file is updated. One can do this by defining 'Gbp-Rpm-If: <conditional>' and 'Gbp-Rpm-IfArch: <conditional>' in the commit message. Only one conditional per patch is supported, i.e. you cannot define 'IfArch' and 'If' for the same patch. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_rpm.py14
-rw-r--r--tests/test_rpm_data/specs/gbp-test2-reference.spec2
-rw-r--r--tests/test_rpm_data/specs/gbp-test2-reference2.spec11
3 files changed, 19 insertions, 8 deletions
diff --git a/tests/test_rpm.py b/tests/test_rpm.py
index f6469c4b..3a6e6ceb 100644
--- a/tests/test_rpm.py
+++ b/tests/test_rpm.py
@@ -156,7 +156,7 @@ class TestSpecFile(object):
reference_spec = os.path.join(SPEC_DIR, 'gbp-test-reference.spec')
spec = SpecFile(tmp_spec)
- spec.update_patches(['new.patch'])
+ spec.update_patches(['new.patch'], {})
spec.write_spec_file()
assert filecmp.cmp(tmp_spec, reference_spec) is True
@@ -173,14 +173,16 @@ class TestSpecFile(object):
reference_spec = os.path.join(SPEC_DIR, 'gbp-test2-reference2.spec')
spec = SpecFile(tmp_spec)
- spec.update_patches(['1.patch', '2.patch'])
+ spec.update_patches(['1.patch', '2.patch'],
+ {'1.patch': {'if': 'true'},
+ '2.patch': {'ifarch': '%ix86'}})
spec.set_tag('VCS', None, 'myvcstag')
- spec.update_patches(['new.patch'])
spec.write_spec_file()
assert filecmp.cmp(tmp_spec, reference_spec) is True
- # Test removing the VCS tag
+ # Test updating patches again and removing the VCS tag
reference_spec = os.path.join(SPEC_DIR, 'gbp-test2-reference.spec')
+ spec.update_patches(['new.patch'], {'new.patch': {'if': '1'}})
spec.set_tag('VCS', None, '')
spec.write_spec_file()
assert filecmp.cmp(tmp_spec, reference_spec) is True
@@ -261,10 +263,10 @@ class TestSpecFile(object):
spec = SpecFileTester(spec_filepath)
assert len(spec.patchseries()) == 0
- spec.update_patches(['1.patch', '2.patch', '3.patch'])
+ 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'])
+ spec.update_patches(['4.patch'], {})
assert len(spec.patchseries()) == 1
assert len(spec.patchseries(ignored=True)) == 2
spec.protected('_delete_special_macro')('patch', 0)
diff --git a/tests/test_rpm_data/specs/gbp-test2-reference.spec b/tests/test_rpm_data/specs/gbp-test2-reference.spec
index e31930d7..dfd4b91f 100644
--- a/tests/test_rpm_data/specs/gbp-test2-reference.spec
+++ b/tests/test_rpm_data/specs/gbp-test2-reference.spec
@@ -27,7 +27,9 @@ echo "Do things"
# Gbp-Patch-Macros
# new.patch
+%if 1
%patch0 -p1
+%endif
%build
make
diff --git a/tests/test_rpm_data/specs/gbp-test2-reference2.spec b/tests/test_rpm_data/specs/gbp-test2-reference2.spec
index 095600d3..0b93f0fa 100644
--- a/tests/test_rpm_data/specs/gbp-test2-reference2.spec
+++ b/tests/test_rpm_data/specs/gbp-test2-reference2.spec
@@ -11,7 +11,8 @@ Source20: bar.tar.gz
# Gbp-Ignore-Patches: -1
Patch: my.patch
# Patches auto-generated by git-buildpackage:
-Patch0: new.patch
+Patch0: 1.patch
+Patch1: 2.patch
Packager: Markus Lehtonen <markus.lehtonen@linux.intel.com>
VCS: myvcstag
@@ -27,8 +28,14 @@ Package for testing the RPM functionality of git-buildpackage.
echo "Do things"
# Gbp-Patch-Macros
-# new.patch
+# 1.patch
+%if true
%patch0 -p1
+%endif
+# 2.patch
+%ifarch %ix86
+%patch1 -p1
+%endif
%build
make