mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-23 12:12:47 +00:00
Add test for GitAnnexBuilder.
This commit is contained in:
parent
5a1ed49959
commit
ce7393ecaa
6 changed files with 86 additions and 7 deletions
1
HACKING
1
HACKING
|
@ -29,6 +29,7 @@ To run all tests, install these packages:
|
|||
* python-nose, python-pep8, and rpm-python
|
||||
* python3-nose, python3-pep8, and rpm-python3
|
||||
* createrepo
|
||||
* git-annex
|
||||
|
||||
Then from the root of the project:
|
||||
|
||||
|
|
|
@ -433,7 +433,7 @@ class Builder(ConfigObject, BuilderBase):
|
|||
debug("Creating %s from git tag: %s..." % (self.tgz_filename,
|
||||
self.git_commit_id))
|
||||
create_tgz(self.git_root, self.tgz_dir, self.git_commit_id,
|
||||
self.relative_project_dir, self.rel_eng_dir,
|
||||
self.relative_project_dir,
|
||||
os.path.join(self.rpmbuild_sourcedir, self.tgz_filename))
|
||||
|
||||
# Extract the source so we can get at the spec file, etc.
|
||||
|
@ -596,7 +596,7 @@ class GemBuilder(NoTgzBuilder):
|
|||
debug("Creating %s from git tag: %s..." % (self.tgz_filename,
|
||||
self.git_commit_id))
|
||||
create_tgz(self.git_root, self.tgz_dir, self.git_commit_id,
|
||||
self.relative_project_dir, self.rel_eng_dir,
|
||||
self.relative_project_dir,
|
||||
os.path.join(self.rpmbuild_sourcedir, self.tgz_filename))
|
||||
|
||||
# Extract the source so we can get at the spec file, etc.
|
||||
|
@ -694,7 +694,7 @@ class UpstreamBuilder(NoTgzBuilder):
|
|||
tgz_fullpath = os.path.join(self.rpmbuild_sourcedir, tgz_filename)
|
||||
print("Creating %s from git tag: %s..." % (tgz_filename, commit))
|
||||
create_tgz(self.git_root, prefix, commit, relative_dir,
|
||||
self.rel_eng_dir, tgz_fullpath)
|
||||
tgz_fullpath)
|
||||
self.ran_tgz = True
|
||||
self.sources.append(tgz_fullpath)
|
||||
|
||||
|
@ -1202,7 +1202,7 @@ class GitAnnexBuilder(NoTgzBuilder):
|
|||
old_cwd = os.getcwd()
|
||||
os.chdir(os.path.join(old_cwd, self.relative_project_dir))
|
||||
|
||||
(status, output) = run_command("which git-annex")
|
||||
(status, output) = getstatusoutput("which git-annex")
|
||||
if status != 0:
|
||||
msg = "Please run 'yum install git-annex' as root."
|
||||
error_out('%s' % msg)
|
||||
|
|
|
@ -512,7 +512,7 @@ def get_commit_timestamp(sha1_or_tag):
|
|||
return output
|
||||
|
||||
|
||||
def create_tgz(git_root, prefix, commit, relative_dir, rel_eng_dir,
|
||||
def create_tgz(git_root, prefix, commit, relative_dir,
|
||||
dest_tgz):
|
||||
"""
|
||||
Create a .tar.gz from a projects source in git.
|
||||
|
@ -545,7 +545,7 @@ def create_tgz(git_root, prefix, commit, relative_dir, rel_eng_dir,
|
|||
git_archive_cmd, timestamp_script,
|
||||
timestamp, commit, dest_tgz))
|
||||
debug(archive_cmd)
|
||||
run_command(archive_cmd)
|
||||
return run_command(archive_cmd)
|
||||
|
||||
|
||||
def get_git_repo_url():
|
||||
|
@ -658,7 +658,6 @@ def find_wrote_in_rpmbuild_output(output):
|
|||
paths = []
|
||||
look_for = "Wrote: "
|
||||
for line in output.split('\n'):
|
||||
print("Checking: %s" % line)
|
||||
if line.startswith(look_for):
|
||||
paths.append(line[len(look_for):])
|
||||
debug("Found wrote line: %s" % paths[-1])
|
||||
|
|
77
test/functional/build_gitannex_tests.py
Normal file
77
test/functional/build_gitannex_tests.py
Normal file
|
@ -0,0 +1,77 @@
|
|||
#
|
||||
# Copyright (c) 2008-2014 Red Hat, Inc.
|
||||
#
|
||||
# This software is licensed to you under the GNU General Public License,
|
||||
# version 2 (GPLv2). There is NO WARRANTY for this software, express or
|
||||
# implied, including the implied warranties of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
|
||||
# along with this software; if not, see
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
||||
#
|
||||
# Red Hat trademarks are not licensed under GPLv2. No permission is
|
||||
# granted to use or replicate Red Hat trademarks that are incorporated
|
||||
# in this software or its documentation.
|
||||
"""
|
||||
Functional Tests for the GitAnnexBuilder.
|
||||
"""
|
||||
|
||||
import os
|
||||
import glob
|
||||
import tempfile
|
||||
import shutil
|
||||
from os.path import join
|
||||
|
||||
from functional.fixture import TitoGitTestFixture, tito
|
||||
|
||||
from tito.compat import *
|
||||
from tito.common import run_command
|
||||
from tito.builder import GitAnnexBuilder
|
||||
|
||||
PKG_NAME = "extsrc"
|
||||
|
||||
|
||||
class GitAnnexBuilderTests(TitoGitTestFixture):
|
||||
|
||||
def setUp(self):
|
||||
TitoGitTestFixture.setUp(self)
|
||||
|
||||
# Setup test config:
|
||||
self.config = RawConfigParser()
|
||||
self.config.add_section("buildconfig")
|
||||
self.config.set("buildconfig", "builder",
|
||||
"tito.builder.GitAnnexBuilder")
|
||||
self.config.set("buildconfig", "offline",
|
||||
"true")
|
||||
|
||||
os.chdir(self.repo_dir)
|
||||
spec = join(os.path.dirname(__file__), "specs/extsrc.spec")
|
||||
self.create_project_from_spec(PKG_NAME, self.config,
|
||||
spec=spec)
|
||||
self.source_filename = 'extsrc-0.0.2.tar.gz'
|
||||
|
||||
# Make a fake source file, do we need something more real?
|
||||
run_command('touch %s' % self.source_filename)
|
||||
print(run_command('git-annex init'))
|
||||
|
||||
self.output_dir = tempfile.mkdtemp("-titotestoutput")
|
||||
|
||||
def tearDown(self):
|
||||
run_command('chmod -R u+rw %s' % self.output_dir)
|
||||
shutil.rmtree(self.output_dir)
|
||||
TitoGitTestFixture.tearDown(self)
|
||||
|
||||
def test_simple_build(self):
|
||||
run_command('git annex add %s' % self.source_filename)
|
||||
run_command('git commit -a -m "Add source."')
|
||||
# This will create 0.0.2:
|
||||
tito('tag --debug --accept-auto-changelog')
|
||||
builder = GitAnnexBuilder(PKG_NAME, None, self.output_dir,
|
||||
self.config, {}, {}, **{'offline': True})
|
||||
builder.rpm()
|
||||
self.assertEquals(1, len(builder.sources))
|
||||
|
||||
self.assertEquals(2, len(builder.artifacts))
|
||||
self.assertEquals(1, len(glob.glob(join(self.output_dir,
|
||||
"extsrc-0.0.2-1.*src.rpm"))))
|
||||
self.assertEquals(1, len(glob.glob(join(self.output_dir, 'noarch',
|
||||
"extsrc-0.0.2-1.*.noarch.rpm"))))
|
|
@ -65,6 +65,7 @@ class FetchBuilderTests(TitoGitTestFixture):
|
|||
|
||||
def tearDown(self):
|
||||
TitoGitTestFixture.tearDown(self)
|
||||
# Git annex restricts permissions, change them before we remove:
|
||||
shutil.rmtree(self.output_dir)
|
||||
|
||||
def test_simple_build_no_tag(self):
|
||||
|
|
|
@ -127,6 +127,7 @@ class TitoGitTestFixture(unittest.TestCase):
|
|||
run_command("git commit -m 'set offline in tito.props'")
|
||||
|
||||
def tearDown(self):
|
||||
run_command('chmod -R u+rw %s' % self.repo_dir)
|
||||
shutil.rmtree(self.repo_dir)
|
||||
pass
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue