Commit 0043cc59 authored by Mathieu Giraud's avatar Mathieu Giraud

Merge branch 'feature/35-colors' into 'dev'

Feature/35 colors

Closes #35

See merge request !12
parents 9e77bd0c 5ffa6b7d
Pipeline #611 passed with stages
in 12 seconds
......@@ -14,12 +14,12 @@ $ Do not launch any 'a' test
./should --only-f demo/cal.should
$ Launch only the two 'f' tests
r:Summary.* TODO:2
r:Summary.* total:2
r:Summary.*TODO:2
r:Summary.*total:2
./should --only-a demo/cal.should
$ Launch only the unique 'a' test
r:Summary.* failed-but-ALLOW:1
r:Summary.* total:1
r:Summary.*failed-but-ALLOW:1
r:Summary.*total:1
......@@ -2,7 +2,7 @@
!EXIT_CODE: 1
$ Report failing test
r:Summary.* failed:1
r:Summary.*failed:1
$ Report failing test
r:Summary.* TODO-but-ok:1
r:Summary.*TODO-but-ok:1
......@@ -2,7 +2,7 @@
!EXIT_CODE: 1
$ Launch only one test
r:Summary.* total:1 test
r:Summary.*total:1 test
$ Report failing test
r:Summary.* TODO-but-ok:1
r:Summary.*TODO-but-ok:1
......@@ -173,16 +173,16 @@ class ANSI:
def color(col, text, colorize = True):
if not colorize:
return text
return CSIm % ANSI.BRIGHT + CSIm % col + text + CSIm % ANSI.RESET
return CSIm % col + text + CSIm % ANSI.RESET
STATUS_COLORS = {
None: ANSI.BLUE,
None: ANSI.CYAN,
False: ANSI.RED,
True: ANSI.GREEN,
SKIP: ANSI.BLUE,
TODO: ANSI.BLUE,
SKIP: ANSI.CYAN,
TODO: ANSI.CYAN,
TODO_PASSED: ANSI.RED,
ALLOW_FAILED: ANSI.BLUE,
ALLOW_FAILED: ANSI.CYAN,
}
# Modifier parser
......@@ -403,6 +403,12 @@ class Stats():
def items(self):
return self.stats.items()
def __iter__(self):
'''Ordered according to STATUS_ORDER'''
for key in STATUS_ORDER[::-1]:
if key in self.keys():
yield (key, self[key])
def values(self):
return self.stats.values()
......@@ -420,10 +426,15 @@ class Stats():
s = '==> '
s += STATUS[status]
s += ' - '
s += ' '.join(['%s:%d' % (STATUS[key], len(val)) for (key, val) in self.items()] + ['total:%s' % self.total()])
s = color(STATUS_COLORS[status], s, colorize)
s += ' '.join([color(STATUS_COLORS[key], '%s:%d', colorize) % (STATUS[key], len(val)) for (key, val) in self])
nb_items = '- total:%s' % self.total()
if self.item:
s += ' ' + self.item + ('s' if self.total() > 1 else '')
return color(STATUS_COLORS[status], s, colorize)
nb_items += ' ' + self.item + ('s' if self.total() > 1 else '')
s += ' ' + color(STATUS_COLORS[status], nb_items, colorize)
return s
......@@ -670,7 +681,7 @@ class TestSuite():
True
>>> s2.str_status(colorize = False)
'==> ok - ok:2 total:2 tests'
'==> ok - ok:2 - total:2 tests'
>>> print(s2.tap()) # doctest: +NORMALIZE_WHITESPACE
1..2
......@@ -1036,10 +1047,12 @@ class FileSet():
if output and OUT_XML in output:
self.xml().write(OUT_XML)
print()
print('Summary', end=' ')
print(self.stats.str_status(self.status))
print('Summary', end=' ')
print(self.stats_tests.str_status(self.status))
print()
for sta in self.stats.keys():
if sta == True:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment