[extra-files] Skip whole phase if not configured
This checks the configuration in one place rather than doing it for each variant/arch combination. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
b67f6369db
commit
74001d5aa5
@ -22,10 +22,10 @@ import fnmatch
|
|||||||
from pungi.util import get_arch_variant_data, pkg_is_rpm, copy_all
|
from pungi.util import get_arch_variant_data, pkg_is_rpm, copy_all
|
||||||
from pungi.arch import split_name_arch
|
from pungi.arch import split_name_arch
|
||||||
from pungi.wrappers.scm import get_file_from_scm, get_dir_from_scm
|
from pungi.wrappers.scm import get_file_from_scm, get_dir_from_scm
|
||||||
from pungi.phases.base import PhaseBase
|
from pungi.phases.base import ConfigGuardedPhase
|
||||||
|
|
||||||
|
|
||||||
class ExtraFilesPhase(PhaseBase):
|
class ExtraFilesPhase(ConfigGuardedPhase):
|
||||||
"""EXTRA_FILES"""
|
"""EXTRA_FILES"""
|
||||||
name = "extra_files"
|
name = "extra_files"
|
||||||
|
|
||||||
@ -38,8 +38,8 @@ class ExtraFilesPhase(PhaseBase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, compose, pkgset_phase):
|
def __init__(self, compose, pkgset_phase):
|
||||||
PhaseBase.__init__(self, compose)
|
super(ExtraFilesPhase, self).__init__(compose)
|
||||||
# pkgset_phase provides package_sets and path_prefix
|
# pkgset_phase provides package_sets
|
||||||
self.pkgset_phase = pkgset_phase
|
self.pkgset_phase = pkgset_phase
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
@ -49,9 +49,6 @@ class ExtraFilesPhase(PhaseBase):
|
|||||||
|
|
||||||
|
|
||||||
def copy_extra_files(compose, arch, variant, package_sets):
|
def copy_extra_files(compose, arch, variant, package_sets):
|
||||||
if "extra_files" not in compose.conf:
|
|
||||||
return
|
|
||||||
|
|
||||||
var_dict = {
|
var_dict = {
|
||||||
"arch": arch,
|
"arch": arch,
|
||||||
"variant_id": variant.id,
|
"variant_id": variant.id,
|
||||||
|
@ -14,6 +14,14 @@ from tests import helpers
|
|||||||
|
|
||||||
class TestExtraFilePhase(helpers.PungiTestCase):
|
class TestExtraFilePhase(helpers.PungiTestCase):
|
||||||
|
|
||||||
|
@mock.patch('pungi.phases.extra_files.copy_extra_files')
|
||||||
|
def test_skips_unless_has_config(self, copy_extra_files):
|
||||||
|
compose = helpers.DummyCompose(self.topdir, {})
|
||||||
|
compose.just_phases = None
|
||||||
|
compose.skip_phases = []
|
||||||
|
phase = extra_files.ExtraFilesPhase(compose, mock.Mock())
|
||||||
|
self.assertTrue(phase.skip())
|
||||||
|
|
||||||
@mock.patch('pungi.phases.extra_files.copy_extra_files')
|
@mock.patch('pungi.phases.extra_files.copy_extra_files')
|
||||||
def test_runs_copy_files_for_each_variant(self, copy_extra_files):
|
def test_runs_copy_files_for_each_variant(self, copy_extra_files):
|
||||||
cfg = mock.Mock()
|
cfg = mock.Mock()
|
||||||
@ -39,18 +47,6 @@ class TestExtraFilePhase(helpers.PungiTestCase):
|
|||||||
|
|
||||||
class TestCopyFiles(helpers.PungiTestCase):
|
class TestCopyFiles(helpers.PungiTestCase):
|
||||||
|
|
||||||
@mock.patch('pungi.phases.extra_files.copy_all')
|
|
||||||
@mock.patch('pungi.phases.extra_files.get_file_from_scm')
|
|
||||||
@mock.patch('pungi.phases.extra_files.get_dir_from_scm')
|
|
||||||
def test_run_without_config(self, get_dir_from_scm, get_file_from_scm, copy_all):
|
|
||||||
compose = helpers.DummyCompose(self.topdir, {})
|
|
||||||
|
|
||||||
extra_files.copy_extra_files(compose, 'x86_64', compose.variants['Server'], mock.Mock())
|
|
||||||
|
|
||||||
self.assertEqual(copy_all.call_args_list, [])
|
|
||||||
self.assertEqual(get_file_from_scm.call_args_list, [])
|
|
||||||
self.assertEqual(get_dir_from_scm.call_args_list, [])
|
|
||||||
|
|
||||||
def test_copy_local_file(self):
|
def test_copy_local_file(self):
|
||||||
tgt = os.path.join(self.topdir, 'file')
|
tgt = os.path.join(self.topdir, 'file')
|
||||||
helpers.touch(tgt)
|
helpers.touch(tgt)
|
||||||
|
Loading…
Reference in New Issue
Block a user