summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2013-12-10 15:25:32 +0200
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>2014-12-16 09:55:14 +0200
commit16d8ac4d7a78f9a62eecae6f8dc521201a0678fc (patch)
tree74820657a6dd1cee8809beea9917a3749d0fc3c1 /tests
parent13a3087d5afcfcee308595b2c224ffe5cdc12c94 (diff)
pq-rpm: implement '--import-files' command line option
The new option can be used to "copy" files from the packaging branch to the patch-queue branch when doing pq import. The files defined with this option will appear as new files in one monolithic commit in the development/patch-queue branch. By default, the local gbp conf files are imported in order to try to ensure that gbp sees the same settings on the patch-queue branch as on the packaging branch. NOTE: This option does not affect the importing (i.e. apply and commit) of patches. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/component/rpm/test_pq_rpm.py46
1 files changed, 32 insertions, 14 deletions
diff --git a/tests/component/rpm/test_pq_rpm.py b/tests/component/rpm/test_pq_rpm.py
index f0dac8d..78143fe 100644
--- a/tests/component/rpm/test_pq_rpm.py
+++ b/tests/component/rpm/test_pq_rpm.py
@@ -78,7 +78,7 @@ class TestPqRpm(RpmRepoTestBase):
# Test import
eq_(mock_pq(['import']), 0)
files = ['AUTHORS', 'dummy.sh', 'Makefile', 'NEWS', 'README',
- 'mydir/myfile.txt']
+ 'mydir/myfile.txt', '.gbp.conf']
branches.append('patch-queue/master')
self._check_repo_state(repo, 'patch-queue/master', branches, files)
eq_(repo.get_merge_base('upstream', 'patch-queue/master'),
@@ -87,8 +87,7 @@ class TestPqRpm(RpmRepoTestBase):
len(repo.get_commits('', 'patch-queue/master')))
# Test export
- eq_(mock_pq(['export', '--upstream-tag',
- 'srcdata/gbp-test/upstream/%(version)s']), 0)
+ eq_(mock_pq(['export']), 0)
files = ['.gbp.conf', '.gitignore', 'bar.tar.gz', 'foo.txt',
'gbp-test.spec', '0001-my-gz.patch', '0002-my-bzip2.patch',
'0003-my2.patch', 'my.patch']
@@ -107,14 +106,13 @@ class TestPqRpm(RpmRepoTestBase):
repo.set_branch('master-orphan')
# Import
eq_(mock_pq(['import']), 0)
- files = ['dummy.sh', 'Makefile', 'README', 'mydir/myfile.txt']
+ files = ['dummy.sh', 'Makefile', 'README', 'mydir/myfile.txt',
+ '.gbp.conf']
self._check_repo_state(repo, 'patch-queue/master-orphan', branches,
files)
# Test export
- eq_(mock_pq(['export', '--upstream-tag',
- 'srcdata/gbp-test2/upstream/%(version)s', '--spec-file',
- 'packaging/gbp-test2.spec']), 0)
+ eq_(mock_pq(['export']), 0)
self._check_repo_state(repo, 'master-orphan', branches)
eq_(repo.status()[' M'], ['packaging/gbp-test2.spec'])
@@ -198,8 +196,6 @@ class TestPqRpm(RpmRepoTestBase):
repo.force_head('master', hard=True)
self._check_repo_state(repo, 'patch-queue/master', branches, pkg_files)
eq_(mock_pq(['import', '--force']), 0)
- # .gbp.conf won't get imported by pq
- pq_files.remove('.gbp.conf')
self._check_repo_state(repo, 'patch-queue/master', branches, pq_files)
# Switch back to master
@@ -286,9 +282,7 @@ class TestPqRpm(RpmRepoTestBase):
eq_(mock_pq(['import', '--spec-file=gbp-test.spec']), 0)
# Force import on top to test parsing spec from another branch
- eq_(mock_pq(['import', '--spec-file=gbp-test.spec', '--force',
- '--upstream-tag',
- 'srcdata/gbp-test/upstream/%(version)s']), 0)
+ eq_(mock_pq(['import', '--spec-file=gbp-test.spec', '--force']), 0)
# Test with export, too
eq_(mock_pq(['export', '--spec-file=foo.spec']), 1)
@@ -306,8 +300,7 @@ class TestPqRpm(RpmRepoTestBase):
eq_(mock_pq(['import', '--packaging-dir=.']), 0)
# Test with export, --spec-file option should override packaging dir
- eq_(mock_pq(['export', '--packaging-dir=foo', '--upstream-tag',
- 'srcdata/gbp-test/upstream/%(version)s',
+ eq_(mock_pq(['export', '--packaging-dir=foo',
'--spec-file=gbp-test.spec']), 0)
def test_export_with_merges(self):
@@ -334,6 +327,31 @@ class TestPqRpm(RpmRepoTestBase):
'%s-to-%s.diff' % (upstr_rev, merge_rev), '0002-my2.patch']
self._check_repo_state(repo, 'master', branches, files)
+ def test_option_import_files(self):
+ """Test the --import-files cmdline option"""
+ repo = self.init_test_repo('gbp-test')
+
+ # Import with default settings (should import gbp conf files)
+ branches = repo.get_local_branches() + ['patch-queue/master']
+ eq_(mock_pq(['import']), 0)
+ self._check_repo_state(repo, 'patch-queue/master', branches)
+ ok_('.gbp.conf' in repo.list_files())
+
+ # Re-import with user-defined files
+ eq_(mock_pq(['import', '--force', '--import-files',
+ 'foo.txt,my.patch']), 0)
+ self._check_repo_state(repo, 'patch-queue/master', branches)
+ ok_('foo.txt' in repo.list_files())
+ ok_('my.patch' in repo.list_files())
+
+ # Drop and re-import with no files
+ eq_(mock_pq(['switch']), 0)
+ eq_(mock_pq(['drop']), 0)
+ eq_(mock_pq(['import', '--import-files=']), 0)
+ self._check_repo_state(repo, 'patch-queue/master', branches)
+ ok_('debian/gbp.conf' not in repo.list_files())
+ ok_('.gbp.conf' not in repo.list_files())
+
def test_import_unapplicable_patch(self):
"""Test import when a patch does not apply"""
repo = self.init_test_repo('gbp-test')