tito/test/functional/builder_tests.py
Dominic Cleal 8d66889981 Fix rpmbuild_options array handling from builder args
3892359 changed builder args to always be arrays, so concatenation of
rpmbuild options with other strings then failed.

    File "/usr/lib/python2.7/site-packages/tito/release/main.py", line 530, in _koji_release
      builder.srpm(dist=disttag)
    File "/usr/lib/python2.7/site-packages/tito/builder/main.py", line 210, in srpm
      rpmbuild_options = self.rpmbuild_options + self._scl_to_rpmbuild_option()
    TypeError: can only concatenate list (not "str") to list

Change builder args to be joined by a single space, allowing multiple
arguments to be passed in.
2015-06-24 14:19:42 +01:00

76 lines
3 KiB
Python

#
# 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.
import os
import tempfile
from tito.builder import Builder
from tito.common import run_command
from tito.compat import RawConfigParser
from functional.fixture import TitoGitTestFixture, tito
PKG_NAME = "titotestpkg"
class BuilderTests(TitoGitTestFixture):
def setUp(self):
TitoGitTestFixture.setUp(self)
os.chdir(self.repo_dir)
self.config = RawConfigParser()
self.output_dir = tempfile.mkdtemp("-titotestoutput")
def test_scl_from_options(self):
self.create_project(PKG_NAME)
builder = Builder(PKG_NAME, None, self.output_dir,
self.config, {}, {'scl': ['ruby193']}, **{'offline': True})
self.assertEqual('ruby193', builder.scl)
def test_scl_from_kwargs(self):
self.create_project(PKG_NAME)
builder = Builder(PKG_NAME, None, self.output_dir,
self.config, {}, {}, **{'offline': True, 'scl': 'ruby193'})
self.assertEqual('ruby193', builder.scl)
def test_rpmbuild_options_from_options(self):
self.create_project(PKG_NAME)
builder = Builder(PKG_NAME, None, self.output_dir,
self.config, {}, {'rpmbuild_options': ['--define "foo bar"',
'--define "bar baz"']}, **{'offline': True})
self.assertEqual('--define "foo bar" --define "bar baz"', builder.rpmbuild_options)
def test_rpmbuild_options_from_kwargs(self):
self.create_project(PKG_NAME)
builder = Builder(PKG_NAME, None, self.output_dir,
self.config, {}, {}, **{'offline': True, 'rpmbuild_options': '--define "foo bar"'})
self.assertEqual('--define "foo bar"', builder.rpmbuild_options)
def test_rpmbuild_options_missing(self):
self.create_project(PKG_NAME)
builder = Builder(PKG_NAME, None, self.output_dir,
self.config, {}, {}, **{'offline': True})
self.assertEqual('', builder.rpmbuild_options)
def test_untagged_test_version(self):
self.create_project(PKG_NAME, tag=False)
self.assertEqual("", run_command("git tag -l").strip())
builder = Builder(PKG_NAME, None, self.output_dir,
self.config, {}, {}, **{'offline': True, 'test': True})
self.assertEqual('0.0.1-1', builder.build_version)
def test_untagged_test_build(self):
self.create_project(PKG_NAME, tag=False)
self.assertEqual("", run_command("git tag -l").strip())
tito('build --srpm --test')