mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-28 20:05:38 +00:00
validate:tools: Print some statistic at the end of the test run
This commit is contained in:
parent
d8fc68479c
commit
c33d10470f
2 changed files with 31 additions and 6 deletions
|
@ -24,7 +24,7 @@ import re
|
|||
import codecs
|
||||
from loggable import Loggable
|
||||
from xml.sax import saxutils
|
||||
from utils import mkdir, Result, printc
|
||||
from utils import mkdir, Result, printc, Colors
|
||||
|
||||
UNICODE_STRINGS = (type(unicode()) == type(str()))
|
||||
|
||||
|
@ -57,7 +57,7 @@ class Reporter(Loggable):
|
|||
self.options = options
|
||||
self.stats = {'timeout': 0,
|
||||
'failures': 0,
|
||||
'passes': 0,
|
||||
'passed': 0,
|
||||
'skipped': 0
|
||||
}
|
||||
self.results = []
|
||||
|
@ -71,7 +71,7 @@ class Reporter(Loggable):
|
|||
self._current_test = test
|
||||
|
||||
def set_failed(self, test):
|
||||
self.stats["failed"] += 1
|
||||
self.stats["failure"] += 1
|
||||
|
||||
def set_passed(self, test):
|
||||
self.stats["passed"] += 1
|
||||
|
@ -94,9 +94,27 @@ class Reporter(Loggable):
|
|||
self._current_test = None
|
||||
|
||||
def final_report(self):
|
||||
print "\n"
|
||||
printc("Final Report:", title=True)
|
||||
for test in self.results:
|
||||
printc(test)
|
||||
|
||||
print "\n"
|
||||
lenstat = (len("Statistics") + 1)
|
||||
printc("Statistics:\n%s" %(lenstat * "-"), Colors.OKBLUE)
|
||||
printc("%sPassed: %d" % (lenstat * " ", self.stats["passed"]), Colors.OKGREEN)
|
||||
printc("%sFailed: %d" % (lenstat * " ", self.stats["failures"]), Colors.FAIL)
|
||||
printc("%s%s" %(lenstat * " ", (len("Failed: 0")) * "-"), Colors.OKBLUE)
|
||||
|
||||
total = self.stats["failures"] + self.stats["passed"]
|
||||
color = Colors.WARNING
|
||||
if total == self.stats["passed"]:
|
||||
color = Colors.OKGREEN
|
||||
elif total == self.stats["failures"]:
|
||||
color = Colors.FAIL
|
||||
|
||||
printc("%sTotal: %d" % (lenstat * " ", total), color)
|
||||
|
||||
|
||||
class XunitReporter(Reporter):
|
||||
"""This reporter provides test results in the standard XUnit XML format."""
|
||||
|
@ -139,7 +157,7 @@ class XunitReporter(Reporter):
|
|||
self.encoding, 'replace')
|
||||
self.stats['encoding'] = self.encoding
|
||||
self.stats['total'] = (self.stats['timeout'] + self.stats['failures']
|
||||
+ self.stats['passes'] + self.stats['skipped'])
|
||||
+ self.stats['passed'] + self.stats['skipped'])
|
||||
self.xml_file.write( u'<?xml version="1.0" encoding="%(encoding)s"?>'
|
||||
u'<testsuite name="gesprojectslauncher" tests="%(total)d" '
|
||||
u'errors="%(timeout)d" failures="%(failures)d" '
|
||||
|
@ -168,7 +186,7 @@ class XunitReporter(Reporter):
|
|||
def set_passed(self, test):
|
||||
"""Add success output to Xunit report.
|
||||
"""
|
||||
self.stats['passes'] += 1
|
||||
self.stats['passed'] += 1
|
||||
self.errorlist.append(
|
||||
'<testcase classname=%(cls)s name=%(name)s '
|
||||
'time="%(taken).3f">%(systemout)s</testcase>' %
|
||||
|
|
|
@ -63,7 +63,14 @@ def mkdir(directory):
|
|||
|
||||
def printc (message, color="", title=False):
|
||||
if title:
|
||||
message = len(message) * '=' + message + len(message) * '='
|
||||
length = 0
|
||||
for l in message.split("\n"):
|
||||
if len(l) > length:
|
||||
length = len(l)
|
||||
if length == 0:
|
||||
length = len(message)
|
||||
message = length * '=' + "\n" + str(message) + "\n" + length * '='
|
||||
|
||||
if hasattr(message, "result") and color == '':
|
||||
if message.result == Result.FAILED:
|
||||
color = Colors.FAIL
|
||||
|
|
Loading…
Reference in a new issue