validate:launcher: Handle checking bug status for expected failures

This commit is contained in:
Thibault Saunier 2016-11-24 10:29:53 -03:00
parent 7193b04770
commit e132c11a95
2 changed files with 63 additions and 25 deletions

View file

@ -733,7 +733,7 @@ class GstValidateTest(Test):
return value return value
def report_matches_expected_failure(self, report, expected_failure): def report_matches_expected_failure(self, report, expected_failure):
for key in ['bug', 'sometimes']: for key in ['bug', 'bugs', 'sometimes']:
if key in expected_failure: if key in expected_failure:
del expected_failure[key] del expected_failure[key]
for key, value in list(report.items()): for key, value in list(report.items()):
@ -1088,9 +1088,8 @@ class TestsManager(Loggable):
def set_blacklists(self): def set_blacklists(self):
if self.blacklisted_tests: if self.blacklisted_tests:
printc("\nCurrently 'hardcoded' %s blacklisted tests:\n" printc("\nCurrently 'hardcoded' %s blacklisted tests:" %
"--------------------------------------------" % self.name, self.name, Colors.WARNING, title_char='-')
Colors.WARNING)
if self.options.check_bugs_status: if self.options.check_bugs_status:
if not check_bugs_resolution(self.blacklisted_tests): if not check_bugs_resolution(self.blacklisted_tests):
@ -1103,6 +1102,33 @@ class TestsManager(Loggable):
return True return True
def check_expected_failures(self):
if not self.blacklisted_tests:
return True
if self.expected_failures:
printc("\nCurrently known failures in the %s testsuite:"
% self.name, Colors.WARNING, title_char='-')
bugs_definitions = {}
for regex, failures in list(self.expected_failures.items()):
for failure in failures:
bugs = failure.get('bug')
if not bugs:
bugs = failure.get('bugs')
if not bugs:
printc('+ %s:\n --> no bug reported associated with %s\n' % (
regex.pattern, failure), Colors.WARNING)
continue
if not isinstance(bugs, list):
bugs = [bugs]
cbugs = bugs_definitions.get(regex.pattern, [])
bugs.extend([b for b in bugs if b not in cbugs])
bugs_definitions[regex.pattern] = bugs
return check_bugs_resolution(bugs_definitions.items())
def _check_blacklisted(self, test): def _check_blacklisted(self, test):
for pattern in self.blacklisted_tests_patterns: for pattern in self.blacklisted_tests_patterns:
if pattern.findall(test.classname): if pattern.findall(test.classname):
@ -1399,6 +1425,9 @@ class _TestsLauncher(Loggable):
if not tester.set_blacklists(): if not tester.set_blacklists():
return False return False
if not tester.check_expected_failures():
return False
return True return True
def _check_tester_has_other_testsuite(self, testsuite, tester): def _check_tester_has_other_testsuite(self, testsuite, tester):

View file

@ -127,15 +127,19 @@ def get_color_for_result(result):
return color return color
def printc(message, color="", title=False): def printc(message, color="", title=False, title_char=''):
if title: if title or title_char:
length = 0 length = 0
for l in message.split("\n"): for l in message.split("\n"):
if len(l) > length: if len(l) > length:
length = len(l) length = len(l)
if length == 0: if length == 0:
length = len(message) length = len(message)
message = length * '=' + "\n" + str(message) + "\n" + length * '='
if title is True:
message = length * title + "\n" + str(message) + "\n" + length * '='
else:
message = str(message) + "\n" + length * title_char
if hasattr(message, "result") and color == '': if hasattr(message, "result") and color == '':
color = get_color_for_result(message.result) color = get_color_for_result(message.result)
@ -367,8 +371,13 @@ class BackTraceGenerator(Loggable):
def check_bugs_resolution(bugs_definitions): def check_bugs_resolution(bugs_definitions):
bugz = {} bugz = {}
regexes = {} regexes = {}
for regex, bug in bugs_definitions: for regex, bugs in bugs_definitions:
if isinstance(bugs, str):
bugs = [bugs]
for bug in bugs:
url = urllib.parse.urlparse(bug) url = urllib.parse.urlparse(bug)
if "bugzilla" not in url.netloc: if "bugzilla" not in url.netloc:
printc(" + %s \n --> bug: %s\n --> Status: Not a bugzilla report\n" % (regex, bug), printc(" + %s \n --> bug: %s\n --> Status: Not a bugzilla report\n" % (regex, bug),
Colors.WARNING) Colors.WARNING)