show the function producing each validation warning or error

Include the name of the function in addition to the actual warning or
error so that it is easier to debug failures.

Change-Id: I8e2788cc1f07c310dccde7e05db74f0e133ca04a
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann
2018-06-09 12:06:26 -04:00
parent e0bb93609b
commit 172a195470

View File

@@ -1438,6 +1438,7 @@ class ValidationContext(object):
self.cleanup = cleanup
self.filename = None
self._setup_workdir()
self.function_name = 'unknown'
def _setup_workdir(self):
workdir = tempfile.mkdtemp(prefix='releases-')
@@ -1455,13 +1456,18 @@ class ValidationContext(object):
def set_filename(self, filename):
self.filename = filename
def set_function(self, function):
self.function_name = function.__name__
def warning(self, msg):
LOG.warning(msg)
self.warnings.append('{}: {}'.format(self.filename, msg))
self.warnings.append('{}: {}: {}'.format(
self.filename, self.function_name, msg))
def error(self, msg):
LOG.error(msg)
self.errors.append('{}: {}'.format(self.filename, msg))
self.errors.append('{}: {}: {}'.format(
self.filename, self.function_name, msg))
if self.debug:
raise RuntimeError(msg)
@@ -1577,6 +1583,7 @@ def main():
for check in checks:
title = inspect.getdoc(check).splitlines()[0].strip()
header(title)
context.set_function(check)
check(deliv, context)
context.show_summary()