config: Report variants validity issues

If the variants file is invalid, we want to report the errors. If we
fail to load the file at all, that is fine.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2018-06-12 12:48:58 +02:00
parent 4a61de1e8a
commit 04f68a018f

View File

@ -22,7 +22,7 @@ import pungi.paths
import pungi.phases import pungi.phases
import pungi.wrappers.scm import pungi.wrappers.scm
import pungi.util import pungi.util
from pungi.wrappers.variants import VariantsXmlParser from pungi.wrappers.variants import VariantsXmlParser, VariantsValidationError
class ValidationCompose(pungi.compose.Compose): class ValidationCompose(pungi.compose.Compose):
@ -87,9 +87,12 @@ def run(config, topdir, has_old):
print(error) print(error)
sys.exit(1) sys.exit(1)
errors = []
compose = ValidationCompose(conf, has_old, topdir) compose = ValidationCompose(conf, has_old, topdir)
try: try:
read_variants(compose, config) read_variants(compose, config)
except VariantsValidationError as exc:
errors.extend(str(exc).splitlines())
except: except:
# Failed to read variants, no big deal. # Failed to read variants, no big deal.
pass pass
@ -115,7 +118,6 @@ def run(config, topdir, has_old):
pungi.phases.TestPhase(compose), pungi.phases.TestPhase(compose),
] ]
errors = []
for phase in phases: for phase in phases:
if phase.skip(): if phase.skip():
continue continue