diff options
author | Guido Günther <agx@sigxcpu.org> | 2017-11-16 08:38:02 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2017-11-16 08:38:02 +0100 |
commit | ab5e0d3aa01db7443fa26401e935ebe9e101c7f2 (patch) | |
tree | 5050d8789ef62d5e288e77d1db26f0fa62322756 /tests | |
parent | 6b1751c8368045dff30af81c394b6fb805b33616 (diff) |
tests: let _check_repostate check repo cleaniness as well
This will point out any unintended leftovers.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/component/__init__.py | 5 | ||||
-rw-r--r-- | tests/component/deb/test_buildpackage.py | 32 | ||||
-rw-r--r-- | tests/component/deb/test_clone.py | 4 | ||||
-rw-r--r-- | tests/component/deb/test_import_orig.py | 12 | ||||
-rw-r--r-- | tests/component/rpm/test_import_orig_rpm.py | 4 | ||||
-rw-r--r-- | tests/component/rpm/test_pq_rpm.py | 14 |
6 files changed, 37 insertions, 34 deletions
diff --git a/tests/component/__init__.py b/tests/component/__init__.py index 0dbbd95e..84acf6a6 100644 --- a/tests/component/__init__.py +++ b/tests/component/__init__.py @@ -159,7 +159,7 @@ class ComponentTestBase(unittest.TestCase, GbpLogTester): @classmethod def _check_repo_state(cls, repo, current_branch, branches, files=None, - dirs=None, tags=None): + dirs=None, tags=None, clean=True): """ Check that repository is clean and given branches, tags, files and dirs exist @@ -192,6 +192,9 @@ class ComponentTestBase(unittest.TestCase, GbpLogTester): cls.check_files(dirs, local_d) if tags is not None: cls.check_tags(repo, tags) + if clean: + clean, files = repo.is_clean() + ok_(clean, "Repo has uncommitted files %s" % files) @classmethod def rem_refs(cls, repo, refs): diff --git a/tests/component/deb/test_buildpackage.py b/tests/component/deb/test_buildpackage.py index d068d451..72b7181b 100644 --- a/tests/component/deb/test_buildpackage.py +++ b/tests/component/deb/test_buildpackage.py @@ -47,8 +47,8 @@ class TestBuildpackage(ComponentTestBase): '%s_%s.dsc' % (pkg, version)) def _test_buildpackage(self, repo, opts=[]): - prebuild_out = os.path.join(repo.path, 'prebuild.out') - postbuild_out = os.path.join(repo.path, 'postbuild.out') + prebuild_out = os.path.join(repo.path, '..', 'prebuild.out') + postbuild_out = os.path.join(repo.path, '..', 'postbuild.out') args = ['arg0', '--git-prebuild=printenv > %s' % prebuild_out, '--git-postbuild=printenv > %s' % postbuild_out, @@ -60,14 +60,14 @@ class TestBuildpackage(ComponentTestBase): eq_(os.path.exists(prebuild_out), True) eq_(os.path.exists(postbuild_out), True) - self.check_hook_vars('prebuild', ["GBP_BUILD_DIR", - "GBP_GIT_DIR", - "GBP_BUILD_DIR"]) + self.check_hook_vars('../prebuild', ["GBP_BUILD_DIR", + "GBP_GIT_DIR", + "GBP_BUILD_DIR"]) - self.check_hook_vars('postbuild', ["GBP_CHANGES_FILE", - "GBP_BUILD_DIR", - "GBP_CHANGES_FILE", - "GBP_BUILD_DIR"]) + self.check_hook_vars('../postbuild', ["GBP_CHANGES_FILE", + "GBP_BUILD_DIR", + "GBP_CHANGES_FILE", + "GBP_BUILD_DIR"]) @RepoFixtures.native() def test_debian_buildpackage(self, repo): @@ -85,15 +85,15 @@ class TestBuildpackage(ComponentTestBase): repo.delete_tag('debian/0.4.14') # make sure we can tag again ret = buildpackage(['arg0', '--git-tag-only', - '--git-posttag=printenv > posttag.out', - '--git-builder=touch builder-run.stamp', + '--git-posttag=printenv > ../posttag.out', + '--git-builder=touch ../builder-run.stamp', '--git-cleaner=/bin/true']) ok_(ret == 0, "Building the package failed") - eq_(os.path.exists('posttag.out'), True) - eq_(os.path.exists('builder-run.stamp'), False) - self.check_hook_vars('posttag', [("GBP_TAG", "debian/0.4.14"), - ("GBP_BRANCH", "master"), - "GBP_SHA1"]) + eq_(os.path.exists('../posttag.out'), True) + eq_(os.path.exists('../builder-run.stamp'), False) + self.check_hook_vars('../posttag', [("GBP_TAG", "debian/0.4.14"), + ("GBP_BRANCH", "master"), + "GBP_SHA1"]) def test_component_generation(self): """Test that generating tarball and additional tarball works without pristine-tar""" diff --git a/tests/component/deb/test_clone.py b/tests/component/deb/test_clone.py index d0d00dc8..db5e2f96 100644 --- a/tests/component/deb/test_clone.py +++ b/tests/component/deb/test_clone.py @@ -49,12 +49,12 @@ class TestClone(ComponentTestBase): dest = os.path.join(self._tmpdir, 'cloned_repo') clone(['arg0', - '--postclone=printenv > postclone.out', + '--postclone=printenv > ../postclone.out', repo.path, dest]) cloned = ComponentTestGitRepository(dest) self._check_repo_state(cloned, 'master', ['master']) assert len(cloned.get_commits()) == 1 - self.check_hook_vars('postclone', ["GBP_GIT_DIR"]) + self.check_hook_vars('../postclone', ["GBP_GIT_DIR"]) @skipUnless(os.getenv("GBP_NETWORK_TESTS"), "network tests disabled") def test_clone_vcsgit_ok(self): diff --git a/tests/component/deb/test_import_orig.py b/tests/component/deb/test_import_orig.py index a5bf0995..58b72c5b 100644 --- a/tests/component/deb/test_import_orig.py +++ b/tests/component/deb/test_import_orig.py @@ -99,16 +99,16 @@ class TestImportOrig(ComponentTestBase): """ orig = self._orig('2.8') ok_(import_orig(['arg0', - '--postimport=printenv > postimport.out', + '--postimport=printenv > ../postimport.out', '--no-interactive', '--pristine-tar', orig]) == 0) self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'], tags=['debian/2.6-2', 'upstream/2.6', 'upstream/2.8']) ok_(os.path.exists('debian/changelog')) - ok_(os.path.exists('postimport.out')) - self.check_hook_vars('postimport', [("GBP_BRANCH", "master"), - ("GBP_TAG", "upstream/2.8"), - ("GBP_UPSTREAM_VERSION", "2.8"), - ("GBP_DEBIAN_VERSION", "2.8-1")]) + ok_(os.path.exists('../postimport.out')) + self.check_hook_vars('../postimport', [("GBP_BRANCH", "master"), + ("GBP_TAG", "upstream/2.8"), + ("GBP_UPSTREAM_VERSION", "2.8"), + ("GBP_DEBIAN_VERSION", "2.8-1")]) @RepoFixtures.quilt30(DEFAULT_DSC, opts=['--pristine-tar']) def test_update_component_tarballs(self, repo): diff --git a/tests/component/rpm/test_import_orig_rpm.py b/tests/component/rpm/test_import_orig_rpm.py index a13e2cd2..c27601db 100644 --- a/tests/component/rpm/test_import_orig_rpm.py +++ b/tests/component/rpm/test_import_orig_rpm.py @@ -264,11 +264,11 @@ class TestImportOrig(ImportOrigTestBase): repo = ComponentTestGitRepository.create('.') orig = os.path.join(DATA_DIR, 'gbp-test-1.0.tar.bz2') - script = ("echo -n branch: $GBP_BRANCH > hook.txt") + script = ("echo -n branch: $GBP_BRANCH > ../hook.txt") eq_(mock_import(['--postimport', script, '--merge', orig]), 0) self._check_repo_state(repo, 'master', ['master', 'upstream']) eq_(repo.get_tags(), ['upstream/1.0']) - with open('hook.txt', 'r') as hookout: + with open('../hook.txt', 'r') as hookout: data = hookout.read() eq_(data, 'branch: master') diff --git a/tests/component/rpm/test_pq_rpm.py b/tests/component/rpm/test_pq_rpm.py index 683852d7..57f74d9f 100644 --- a/tests/component/rpm/test_pq_rpm.py +++ b/tests/component/rpm/test_pq_rpm.py @@ -91,14 +91,14 @@ class TestPqRpm(RpmRepoTestBase): eq_(mock_pq(['export', '--upstream-tag', 'upstream/%(version)s']), 0) files = ['.gbp.conf', '.gitignore', 'bar.tar.gz', 'foo.txt', 'gbp-test.spec'] + patches - self._check_repo_state(repo, 'master', branches, files) + self._check_repo_state(repo, 'master', branches, files, clean=False) eq_(repo.status()[' M'], [b'gbp-test.spec']) self._has_patches('gbp-test.spec', patches) # Another export after removing some patches os.unlink('0001-my-gz.patch') eq_(mock_pq(['export']), 0) - self._check_repo_state(repo, 'master', branches, files) + self._check_repo_state(repo, 'master', branches, files, clean=False) self._has_patches('gbp-test.spec', patches) def test_import_export2(self): @@ -116,7 +116,7 @@ class TestPqRpm(RpmRepoTestBase): # Test export eq_(mock_pq(['export', '--upstream-tag', 'upstream/%(version)s', '--spec-file', 'packaging/gbp-test2.spec']), 0) - self._check_repo_state(repo, 'master-orphan', branches) + self._check_repo_state(repo, 'master-orphan', branches, clean=False) eq_(repo.status()[' M'], [b'packaging/gbp-test2.spec']) self._has_patches('packaging/gbp-test2.spec', patches) @@ -264,7 +264,7 @@ class TestPqRpm(RpmRepoTestBase): patches = ['my-gz.patch', 'my-bzip2.patch', 'my2.patch', 'my.patch'] files = ['.gbp.conf', '.gitignore', 'bar.tar.gz', 'foo.txt', 'gbp-test.spec'] + patches - self._check_repo_state(repo, 'master', branches, files) + self._check_repo_state(repo, 'master', branches, files, clean=False) self._has_patches('gbp-test.spec', patches) def test_option_tmp_dir(self): @@ -343,7 +343,7 @@ class TestPqRpm(RpmRepoTestBase): '%s-to-%s.diff' % (upstr_rev, merge_rev), '0002-my2.patch'] files = ['.gbp.conf', '.gitignore', 'bar.tar.gz', 'foo.txt', 'gbp-test.spec'] + patches - self._check_repo_state(repo, 'master', branches, files) + self._check_repo_state(repo, 'master', branches, files, clean=False) self._has_patches('gbp-test.spec', patches) def test_import_unapplicable_patch(self): @@ -355,11 +355,11 @@ class TestPqRpm(RpmRepoTestBase): patch_file.write('-this-does\n+not-apply\n') eq_(mock_pq(['import']), 1) self._check_log(-2, "Please commit your changes or stash them") - self._check_repo_state(repo, 'master', branches) + self._check_repo_state(repo, 'master', branches, clean=False) # Now commit the changes to the patch and try again repo.add_files(['my2.patch'], force=True) repo.commit_files(['my2.patch'], msg="Mangle patch") eq_(mock_pq(['import']), 1) self._check_log(-1, "gbp:error: Import failed: Error running git apply") - self._check_repo_state(repo, 'master', branches) + self._check_repo_state(repo, 'master', branches, clean=False) |