2014-01-13 14:40:28 -04:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
"""
|
2014-01-15 16:17:02 -04:00
|
|
|
Functional Tests for the FetchBuilder.
|
2014-01-13 14:40:28 -04:00
|
|
|
"""
|
|
|
|
|
2014-01-15 16:17:02 -04:00
|
|
|
import ConfigParser
|
2014-01-13 14:40:28 -04:00
|
|
|
import os
|
2014-01-15 16:17:02 -04:00
|
|
|
import shutil
|
2014-01-13 14:40:28 -04:00
|
|
|
import tempfile
|
|
|
|
|
2014-02-03 15:59:26 -04:00
|
|
|
from os.path import join
|
|
|
|
|
2014-01-13 14:40:28 -04:00
|
|
|
from tito.common import run_command
|
|
|
|
from fixture import TitoGitTestFixture, tito
|
|
|
|
|
|
|
|
EXT_SRC_PKG = "extsrc"
|
|
|
|
|
2014-02-03 15:59:26 -04:00
|
|
|
RELEASER_CONF = """
|
|
|
|
[yum-test]
|
|
|
|
releaser = tito.release.YumRepoReleaser
|
|
|
|
builder = tito.builder.FetchBuilder
|
|
|
|
rsync = %s
|
|
|
|
"""
|
|
|
|
|
2014-01-15 16:17:02 -04:00
|
|
|
class FetchBuilderTests(TitoGitTestFixture):
|
2014-01-13 14:40:28 -04:00
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
TitoGitTestFixture.setUp(self)
|
2014-02-03 15:59:26 -04:00
|
|
|
self.pkg_dir = join(self.repo_dir, EXT_SRC_PKG)
|
|
|
|
spec = join(os.path.dirname(__file__), "specs/extsrc.spec")
|
2014-01-13 16:29:38 -04:00
|
|
|
|
|
|
|
# Setup test config:
|
|
|
|
self.config = ConfigParser.RawConfigParser()
|
|
|
|
self.config.add_section("buildconfig")
|
|
|
|
self.config.set("buildconfig", "builder",
|
2014-01-15 16:17:02 -04:00
|
|
|
"tito.builder.FetchBuilder")
|
2014-01-13 16:29:38 -04:00
|
|
|
|
2014-01-15 16:17:02 -04:00
|
|
|
self.config.add_section('builder')
|
|
|
|
self.config.set('builder', 'fetch_strategy',
|
2014-02-03 15:59:26 -04:00
|
|
|
'tito.builder.fetch.ArgSourceStrategy')
|
2014-01-13 16:29:38 -04:00
|
|
|
|
|
|
|
self.create_project_from_spec(EXT_SRC_PKG, self.config,
|
|
|
|
pkg_dir=self.pkg_dir, spec=spec)
|
2014-01-13 14:40:28 -04:00
|
|
|
self.source_filename = 'extsrc-0.0.2.tar.gz'
|
|
|
|
os.chdir(self.pkg_dir)
|
|
|
|
|
|
|
|
# Make a fake source file, do we need something more real?
|
|
|
|
run_command('touch %s' % self.source_filename)
|
|
|
|
|
|
|
|
self.output_dir = tempfile.mkdtemp("-titotestoutput")
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
TitoGitTestFixture.tearDown(self)
|
2014-01-15 16:17:02 -04:00
|
|
|
shutil.rmtree(self.output_dir)
|
2014-01-13 14:40:28 -04:00
|
|
|
|
2014-02-26 14:52:56 -04:00
|
|
|
def _setup_fetchbuilder_releaser(self):
|
|
|
|
self.write_file(join(self.repo_dir, 'rel-eng/releasers.conf'),
|
|
|
|
RELEASER_CONF)
|
|
|
|
|
2014-01-13 14:40:28 -04:00
|
|
|
def test_simple_build_no_tag(self):
|
|
|
|
# We have not tagged here. Build --rpm should just work:
|
|
|
|
self.assertFalse(os.path.exists(
|
2014-02-03 15:59:26 -04:00
|
|
|
join(self.pkg_dir, 'rel-eng/packages/extsrc')))
|
2014-01-16 14:52:55 -04:00
|
|
|
|
|
|
|
tito('build --rpm --output=%s --no-cleanup --debug --arg=source=%s ' %
|
2014-01-13 14:40:28 -04:00
|
|
|
(self.output_dir, self.source_filename))
|
|
|
|
self.assertTrue(os.path.exists(
|
2014-02-03 15:59:26 -04:00
|
|
|
join(self.output_dir, 'extsrc-0.0.2-1.fc20.src.rpm')))
|
2014-01-13 14:40:28 -04:00
|
|
|
self.assertTrue(os.path.exists(
|
2014-02-03 15:59:26 -04:00
|
|
|
join(self.output_dir, 'noarch/extsrc-0.0.2-1.fc20.noarch.rpm')))
|
2014-01-13 14:40:28 -04:00
|
|
|
|
|
|
|
def test_tag_rejected(self):
|
|
|
|
self.assertRaises(SystemExit, tito,
|
2014-01-16 14:52:55 -04:00
|
|
|
'build --tag=extsrc-0.0.1-1 --rpm --output=%s --arg=source=%s ' %
|
2014-01-13 14:40:28 -04:00
|
|
|
(self.output_dir, self.source_filename))
|
|
|
|
|
2014-02-03 15:59:26 -04:00
|
|
|
def test_with_releaser(self):
|
|
|
|
self._setup_fetchbuilder_releaser()
|
|
|
|
tito('release --debug yum-test --arg source=%s' %
|
|
|
|
self.source_filename)
|
|
|
|
|
2014-01-13 14:40:28 -04:00
|
|
|
|
|
|
|
|