Check dependency of --just-phase
JIRA: COMPOSE-4020 Signed-off-by: Haibo Lin <hlin@redhat.com>
This commit is contained in:
parent
3750d6795f
commit
3f111b559f
@ -131,11 +131,12 @@ def check_umask(logger):
|
|||||||
'expect files with broken permissions.', mask)
|
'expect files with broken permissions.', mask)
|
||||||
|
|
||||||
|
|
||||||
def check_skip_phases(logger, skip_phases):
|
def check_skip_phases(logger, skip_phases, just_phases):
|
||||||
"""Check if skipped phases are needed by other phase.
|
"""Check if skipped phases are needed by other phase.
|
||||||
|
|
||||||
:param logger: logger instance for reporting error
|
:param logger: logger instance for reporting error
|
||||||
:param skip_phases: list of skipped phases
|
:param skip_phases: list of skipped phases
|
||||||
|
:param just_phases: list of phases just run
|
||||||
:returns: True if checking passed else False
|
:returns: True if checking passed else False
|
||||||
"""
|
"""
|
||||||
needed_by = {
|
needed_by = {
|
||||||
@ -144,7 +145,9 @@ def check_skip_phases(logger, skip_phases):
|
|||||||
}
|
}
|
||||||
fail = False
|
fail = False
|
||||||
for k, v in needed_by.items():
|
for k, v in needed_by.items():
|
||||||
if k in skip_phases and needed_by[k] not in skip_phases:
|
if (k in skip_phases and needed_by[k] not in skip_phases) or (
|
||||||
|
needed_by[k] in just_phases and k not in just_phases
|
||||||
|
):
|
||||||
fail = True
|
fail = True
|
||||||
logger.error("%s phase is skipped but it's needed by %s phase" % (k, v))
|
logger.error("%s phase is skipped but it's needed by %s phase" % (k, v))
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ def main():
|
|||||||
if not pungi.checks.check(conf):
|
if not pungi.checks.check(conf):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
pungi.checks.check_umask(logger)
|
pungi.checks.check_umask(logger)
|
||||||
if not pungi.checks.check_skip_phases(logger, opts.skip_phase):
|
if not pungi.checks.check_skip_phases(logger, opts.skip_phase, opts.just_phase):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
errors, warnings = pungi.checks.validate(conf)
|
errors, warnings = pungi.checks.validate(conf)
|
||||||
|
|
||||||
|
@ -572,3 +572,31 @@ class TestUmask(unittest.TestCase):
|
|||||||
[mock.call.warning('Unusually strict umask detected (0%03o), '
|
[mock.call.warning('Unusually strict umask detected (0%03o), '
|
||||||
'expect files with broken permissions.', 0o044)]
|
'expect files with broken permissions.', 0o044)]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TestCheckSkipPhases(unittest.TestCase):
|
||||||
|
def test_skip_phase(self):
|
||||||
|
logger = mock.Mock()
|
||||||
|
passed = checks.check_skip_phases(logger, ["gather"], [])
|
||||||
|
self.assertFalse(passed)
|
||||||
|
self.assertEqual(
|
||||||
|
logger.mock_calls,
|
||||||
|
[
|
||||||
|
mock.call.error(
|
||||||
|
"gather phase is skipped but it's needed by createrepo phase"
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_just_phase(self):
|
||||||
|
logger = mock.Mock()
|
||||||
|
passed = checks.check_skip_phases(logger, [], ["gather"])
|
||||||
|
self.assertFalse(passed)
|
||||||
|
self.assertEqual(
|
||||||
|
logger.mock_calls,
|
||||||
|
[
|
||||||
|
mock.call.error(
|
||||||
|
"pkgset phase is skipped but it's needed by gather phase"
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user