gather: Report error if there is no input
Running depsolving with no requested inputs will only lead to a hard to decipher error. We should instead explicitly tell the user that there is a problem. Unit tests are added to add to test this functionality. Relates: #585 Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
b5efb67ff1
commit
0168388492
@ -37,13 +37,18 @@ class GatherMethodDeps(pungi.phases.gather.method.GatherMethodBase):
|
||||
# "debuginfo": [],
|
||||
# }
|
||||
|
||||
write_pungi_config(self.compose, arch, variant, packages, groups, filter_packages, multilib_whitelist, multilib_blacklist, package_set=package_sets[arch], fulltree_excludes=fulltree_excludes, prepopulate=prepopulate)
|
||||
write_pungi_config(self.compose, arch, variant, packages, groups, filter_packages,
|
||||
multilib_whitelist, multilib_blacklist, package_set=package_sets[arch],
|
||||
fulltree_excludes=fulltree_excludes, prepopulate=prepopulate)
|
||||
result = resolve_deps(self.compose, arch, variant)
|
||||
check_deps(self.compose, arch, variant)
|
||||
return result
|
||||
|
||||
|
||||
def write_pungi_config(compose, arch, variant, packages, groups, filter_packages, multilib_whitelist, multilib_blacklist, repos=None, comps_repo=None, package_set=None, fulltree_excludes=None, prepopulate=None):
|
||||
def write_pungi_config(compose, arch, variant, packages, groups, filter_packages,
|
||||
multilib_whitelist, multilib_blacklist, repos=None,
|
||||
comps_repo=None, package_set=None, fulltree_excludes=None,
|
||||
prepopulate=None):
|
||||
"""write pungi config (kickstart) for arch/variant"""
|
||||
pungi_wrapper = PungiWrapper()
|
||||
pungi_cfg = compose.paths.work.pungi_conf(variant=variant, arch=arch)
|
||||
@ -77,7 +82,17 @@ def write_pungi_config(compose, arch, variant, packages, groups, filter_packages
|
||||
else:
|
||||
filter_packages_str.append(pkg_name)
|
||||
|
||||
pungi_wrapper.write_kickstart(ks_path=pungi_cfg, repos=repos, groups=groups, packages=packages_str, exclude_packages=filter_packages_str, comps_repo=comps_repo, lookaside_repos=lookaside_repos, fulltree_excludes=fulltree_excludes, multilib_whitelist=multilib_whitelist, multilib_blacklist=multilib_blacklist, prepopulate=prepopulate)
|
||||
if not groups and not packages_str and not prepopulate:
|
||||
raise RuntimeError(
|
||||
'No packages included in %s.%s (no comps groups, no input packages, no prepopulate)'
|
||||
% (variant.uid, arch))
|
||||
|
||||
pungi_wrapper.write_kickstart(
|
||||
ks_path=pungi_cfg, repos=repos, groups=groups, packages=packages_str,
|
||||
exclude_packages=filter_packages_str, comps_repo=comps_repo,
|
||||
lookaside_repos=lookaside_repos, fulltree_excludes=fulltree_excludes,
|
||||
multilib_whitelist=multilib_whitelist, multilib_blacklist=multilib_blacklist,
|
||||
prepopulate=prepopulate)
|
||||
|
||||
|
||||
def resolve_deps(compose, arch, variant):
|
||||
|
71
tests/test_gather_method_deps.py
Normal file
71
tests/test_gather_method_deps.py
Normal file
@ -0,0 +1,71 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import mock
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
||||
|
||||
from pungi.phases.gather.methods import method_deps as deps
|
||||
from tests import helpers
|
||||
|
||||
|
||||
class TestWritePungiConfig(helpers.PungiTestCase):
|
||||
def setUp(self):
|
||||
super(TestWritePungiConfig, self).setUp()
|
||||
self.compose = helpers.DummyCompose(self.topdir, {})
|
||||
self.compose.DEBUG = False
|
||||
|
||||
def assertWritten(self, PungiWrapper, **kwargs):
|
||||
wrapper = PungiWrapper.return_value
|
||||
self.assertEqual(wrapper.mock_calls,
|
||||
[mock.call.write_kickstart(**kwargs)])
|
||||
|
||||
@mock.patch('pungi.phases.gather.methods.method_deps.PungiWrapper')
|
||||
def test_correct(self, PungiWrapper):
|
||||
pkgs = [('pkg1', None), ('pkg2', 'x86_64')]
|
||||
grps = ['grp1']
|
||||
filter = [('pkg3', None), ('pkg4', 'x86_64')]
|
||||
white = mock.Mock()
|
||||
black = mock.Mock()
|
||||
comps_repo = mock.Mock()
|
||||
prepopulate = mock.Mock()
|
||||
fulltree = mock.Mock()
|
||||
deps.write_pungi_config(self.compose, 'x86_64', self.compose.variants['Server'],
|
||||
pkgs, grps, filter, white, black, comps_repo=comps_repo,
|
||||
prepopulate=prepopulate, fulltree_excludes=fulltree)
|
||||
self.assertWritten(PungiWrapper, packages=['pkg1', 'pkg2.x86_64'],
|
||||
ks_path=self.topdir + '/work/x86_64/pungi/Server.x86_64.conf',
|
||||
lookaside_repos={}, multilib_whitelist=white, multilib_blacklist=black,
|
||||
groups=['grp1'], prepopulate=prepopulate,
|
||||
repos={'pungi-repo': self.topdir + '/work/x86_64/repo'},
|
||||
exclude_packages=['pkg3', 'pkg4.x86_64'],
|
||||
fulltree_excludes=fulltree,
|
||||
comps_repo=comps_repo)
|
||||
|
||||
@mock.patch('pungi.phases.gather.get_lookaside_repos')
|
||||
@mock.patch('pungi.phases.gather.methods.method_deps.PungiWrapper')
|
||||
def test_with_lookaside(self, PungiWrapper, glr):
|
||||
glr.return_value = ['http://example.com/repo']
|
||||
pkgs = [('pkg1', None)]
|
||||
deps.write_pungi_config(self.compose, 'x86_64', self.compose.variants['Server'],
|
||||
pkgs, [], [], [], [])
|
||||
self.assertWritten(PungiWrapper, packages=['pkg1'],
|
||||
ks_path=self.topdir + '/work/x86_64/pungi/Server.x86_64.conf',
|
||||
lookaside_repos={'lookaside-repo-0': 'http://example.com/repo'},
|
||||
multilib_whitelist=[], multilib_blacklist=[],
|
||||
groups=[], prepopulate=None,
|
||||
repos={'pungi-repo': self.topdir + '/work/x86_64/repo'},
|
||||
exclude_packages=[], fulltree_excludes=None, comps_repo=None)
|
||||
self.assertEqual(glr.call_args_list,
|
||||
[mock.call(self.compose, 'x86_64', self.compose.variants['Server'])])
|
||||
|
||||
@mock.patch('pungi.phases.gather.methods.method_deps.PungiWrapper')
|
||||
def test_without_input(self, PungiWrapper):
|
||||
with self.assertRaises(RuntimeError) as ctx:
|
||||
deps.write_pungi_config(self.compose, 'x86_64', self.compose.variants['Server'],
|
||||
[], [], [], [], [])
|
||||
self.assertEqual(
|
||||
str(ctx.exception),
|
||||
'No packages included in Server.x86_64 (no comps groups, no input packages, no prepopulate)')
|
||||
self.assertEqual(PungiWrapper.return_value.mock_calls, [])
|
Loading…
Reference in New Issue
Block a user