* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/output/
@ 2011-08-05 19:54 Michał Górny
0 siblings, 0 replies; 14+ messages in thread
From: Michał Górny @ 2011-08-05 19:54 UTC (permalink / raw
To: gentoo-commits
commit: 6c21f8b452e8454fc56a0eda654b54a299f29e9c
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 5 19:55:12 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Aug 5 19:55:12 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=6c21f8b4
Add the HTML output module.
---
pmstestsuite/output/__init__.py | 3 +-
pmstestsuite/output/html.py | 182 +++++++++++++++++++++++++++++++++++++++
2 files changed, 184 insertions(+), 1 deletions(-)
diff --git a/pmstestsuite/output/__init__.py b/pmstestsuite/output/__init__.py
index cef7ab8..0c7c8be 100644
--- a/pmstestsuite/output/__init__.py
+++ b/pmstestsuite/output/__init__.py
@@ -83,5 +83,6 @@ def get_output_modules():
"""
from pmstestsuite.output.cli import CLIOutput
+ from pmstestsuite.output.html import HTMLOutput
- return (CLIOutput,)
+ return (CLIOutput, HTMLOutput)
diff --git a/pmstestsuite/output/html.py b/pmstestsuite/output/html.py
new file mode 100644
index 0000000..5842eb9
--- /dev/null
+++ b/pmstestsuite/output/html.py
@@ -0,0 +1,182 @@
+# vim:fileencoding=utf-8
+# (c) 2011 Michał Górny <mgorny@gentoo.org>
+# Released under the terms of the 2-clause BSD license.
+
+from collections import defaultdict
+
+from pmstestsuite.output import OutputModule
+
+class HTMLOutput(OutputModule):
+ name = 'html'
+
+ def __init__(self, path = None):
+ if path is None:
+ path = 'pms-test-suite-output.html'
+ self._path = path
+
+ _htmlheader = '''<?xml version="1.0" encoding="utf-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>PMS Test Suite test results</title>
+ <style type="text/css">
+ table {
+ margin: 0 auto;
+ border: 1px solid;
+ }
+
+ th, td {
+ padding: .1em 1em;
+ border: 1px solid;
+ }
+
+ .value {
+ font-family: monospace;
+ text-align: center;
+ }
+
+ .good {
+ background: #88e888;
+ }
+
+ .bad {
+ background: #e88888;
+ }
+ </style>
+ </head>
+ <body>
+ <table>'''
+
+ _htmlfooter = '''
+ </table>
+ </body>
+</html>'''
+
+ def __call__(self, allresults, verbose = False):
+ mypms = []
+
+ def _results_by_test(allresults):
+ ret = defaultdict(lambda: defaultdict(lambda: None))
+ for pm, results in allresults.items():
+ mypms.append(pm)
+ for t, r in results.items():
+ ret[t][pm] = r
+ return ret
+
+ def _results_by_class(reorderedresults):
+ ret = defaultdict(dict)
+ for t, r in reorderedresults.items():
+ ret[t.__class__.__name__][t] = r
+ return ret
+
+ def _sorted_pms(pms):
+ for pm in sorted(pms, key = lambda pm: mypms.index(pm)):
+ yield (pm, pms[pm])
+
+ class HTMLElem(object):
+ _elem = 'td'
+
+ def __init__(self, text):
+ self._attrs = []
+ self._text = text
+
+ def set_rowspan(self, rowspan):
+ if rowspan != 1:
+ self._attrs.append('rowspan="%d"' % rowspan)
+
+ def __str__(self):
+ return '<%s>%s</%s>' % (' '.join([self._elem] + self._attrs),
+ self._text, self._elem)
+
+ class TH(HTMLElem):
+ _elem = 'th'
+
+ def __init__(self, text, colspan = 1):
+ HTMLElem.__init__(self, text)
+ self._colspan = colspan
+ if colspan != 1:
+ self._attrs.append('colspan="%d"' % colspan)
+
+ class ValCell(HTMLElem):
+ _color_class = ''
+
+ def __init__(self, text):
+ HTMLElem.__init__(self, text)
+ self._attrs.append('class="value %s"' % self._color_class)
+
+ class ColorValCell(ValCell):
+ def __init__(self, text, cond):
+ self._color_class = 'good' if cond else 'bad'
+ ValCell.__init__(self, text)
+
+ class BoolCell(ValCell):
+ def __init__(self, cond):
+ self._color_class = 'good' if cond else 'bad'
+ ValCell.__init__(self, 'OK' if cond else 'FAIL')
+
+ class NoCell(HTMLElem):
+ def __init__(self):
+ pass
+
+ def __str__(self):
+ return ''
+
+ ret = True
+ results = _results_by_test(allresults)
+ table = defaultdict(lambda: defaultdict(lambda: None))
+
+ table[0][0] = TH('Test name')
+ table[0][1] = TH('EAPI')
+ table[0][2] = TH('Assertion')
+ table[0][3] = TH('Expected')
+ for i, pm in enumerate(mypms):
+ table[0][4 + i*3] = TH(pm.name, colspan = 3)
+ table[0][5 + i*3] = NoCell()
+ table[1][4 + i*3] = TH('Actual')
+ table[1][5 + i*3] = TH('Result')
+ maxcol = 6 + i*3
+
+ row = 2
+ for cl, tests in _results_by_class(results).items():
+ table[row][0] = cl
+ for t, pms in tests.items():
+ table[row][1] = t.eapi
+ test_asserts = []
+ col = 4
+ for pm, r in _sorted_pms(pms):
+ table[row][col+1] = BoolCell(r)
+ for a in r.assertions:
+ if a.name not in test_asserts:
+ test_asserts.append(a.name)
+ crow = row + test_asserts.index(a.name)
+ table[crow][2] = a.name
+ table[crow][3] = ValCell(a.expected)
+ else:
+ crow = row + test_asserts.index(a.name)
+
+ table[crow][col] = ColorValCell(a.actual, a)
+ col += 2
+ row += len(test_asserts)
+
+ f = open(self._path, 'w')
+ f.write(self._htmlheader)
+ for y in range(0, row):
+ f.write('<tr>')
+ for x in range(0, maxcol):
+ cell = table[y][x]
+ if cell is not None:
+ rowspan = 1
+ for y2 in range(y + 1, row):
+ if table[y2][x] is None:
+ rowspan += 1
+ else:
+ break
+
+ if not isinstance(cell, HTMLElem):
+ cell = HTMLElem(cell)
+ cell.set_rowspan(rowspan)
+ f.write(str(cell))
+ f.write('</tr>')
+ f.write(self._htmlfooter)
+ f.close()
+
+ return ret
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/output/
@ 2011-08-05 21:36 Michał Górny
0 siblings, 0 replies; 14+ messages in thread
From: Michał Górny @ 2011-08-05 21:36 UTC (permalink / raw
To: gentoo-commits
commit: a3069eea0a4cf48f510cf2eb12e57d6a4156967c
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 5 20:32:59 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Aug 5 20:32:59 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=a3069eea
Fix HTML table misalignment.
---
pmstestsuite/output/html.py | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/pmstestsuite/output/html.py b/pmstestsuite/output/html.py
index 5842eb9..8a464ab 100644
--- a/pmstestsuite/output/html.py
+++ b/pmstestsuite/output/html.py
@@ -129,11 +129,11 @@ class HTMLOutput(OutputModule):
table[0][2] = TH('Assertion')
table[0][3] = TH('Expected')
for i, pm in enumerate(mypms):
- table[0][4 + i*3] = TH(pm.name, colspan = 3)
- table[0][5 + i*3] = NoCell()
- table[1][4 + i*3] = TH('Actual')
- table[1][5 + i*3] = TH('Result')
- maxcol = 6 + i*3
+ table[0][4 + i*2] = TH(pm.name, colspan = 2)
+ table[0][5 + i*2] = NoCell()
+ table[1][4 + i*2] = TH('Actual')
+ table[1][5 + i*2] = TH('Result')
+ maxcol = 6 + i*2
row = 2
for cl, tests in _results_by_class(results).items():
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/output/
@ 2011-08-05 21:36 Michał Górny
0 siblings, 0 replies; 14+ messages in thread
From: Michał Górny @ 2011-08-05 21:36 UTC (permalink / raw
To: gentoo-commits
commit: 9992ea7d4bc14fd5620500b87cb657e41958adec
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 5 21:12:34 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Aug 5 21:12:34 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=9992ea7d
Sort test results by EAPI.
---
pmstestsuite/output/html.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/pmstestsuite/output/html.py b/pmstestsuite/output/html.py
index 8a464ab..af3e10c 100644
--- a/pmstestsuite/output/html.py
+++ b/pmstestsuite/output/html.py
@@ -138,11 +138,11 @@ class HTMLOutput(OutputModule):
row = 2
for cl, tests in _results_by_class(results).items():
table[row][0] = cl
- for t, pms in tests.items():
+ for t in sorted(tests, key = lambda t: t.eapi):
table[row][1] = t.eapi
test_asserts = []
col = 4
- for pm, r in _sorted_pms(pms):
+ for pm, r in _sorted_pms(tests[t]):
table[row][col+1] = BoolCell(r)
for a in r.assertions:
if a.name not in test_asserts:
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/output/
@ 2011-08-06 8:31 Michał Górny
0 siblings, 0 replies; 14+ messages in thread
From: Michał Górny @ 2011-08-06 8:31 UTC (permalink / raw
To: gentoo-commits
commit: 29f9cdba1a8fd6bf34187022e57660f8c7d7b04d
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 6 08:31:52 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Aug 6 08:31:52 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=29f9cdba
Mark not reached assertions as 'unknown'.
Rather than rowspanning them.
---
pmstestsuite/output/html.py | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/pmstestsuite/output/html.py b/pmstestsuite/output/html.py
index af3e10c..519209a 100644
--- a/pmstestsuite/output/html.py
+++ b/pmstestsuite/output/html.py
@@ -41,6 +41,10 @@ class HTMLOutput(OutputModule):
.bad {
background: #e88888;
}
+
+ .unknown {
+ background: #b8b8b8;
+ }
</style>
</head>
<body>
@@ -113,6 +117,11 @@ class HTMLOutput(OutputModule):
self._color_class = 'good' if cond else 'bad'
ValCell.__init__(self, 'OK' if cond else 'FAIL')
+ class UnknownValCell(ValCell):
+ _color_class = 'unknown'
+ def __init__(self):
+ ValCell.__init__(self, '?')
+
class NoCell(HTMLElem):
def __init__(self):
pass
@@ -150,6 +159,8 @@ class HTMLOutput(OutputModule):
crow = row + test_asserts.index(a.name)
table[crow][2] = a.name
table[crow][3] = ValCell(a.expected)
+ for c in range(4, maxcol, 2):
+ table[crow][c] = UnknownValCell()
else:
crow = row + test_asserts.index(a.name)
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/output/
@ 2011-08-06 14:25 Michał Górny
0 siblings, 0 replies; 14+ messages in thread
From: Michał Górny @ 2011-08-06 14:25 UTC (permalink / raw
To: gentoo-commits
commit: 1f4aa469ccd35106aedfea309b1951e05aa65251
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 6 13:59:31 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Aug 6 13:59:31 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=1f4aa469
Clearly distinguish undefined results.
---
pmstestsuite/output/html.py | 27 ++++++++++++++++++++++-----
1 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/pmstestsuite/output/html.py b/pmstestsuite/output/html.py
index 6de16f0..45c7398 100644
--- a/pmstestsuite/output/html.py
+++ b/pmstestsuite/output/html.py
@@ -45,6 +45,16 @@ class HTMLOutput(OutputModule):
.unknown {
background: #b8b8b8;
}
+
+ .unk-good {
+ background: #b8b8b8;
+ color: #008800;
+ }
+
+ .unk-bad {
+ background: #b8b8b8;
+ color: #880000;
+ }
</style>
</head>
<body>
@@ -109,14 +119,21 @@ class HTMLOutput(OutputModule):
class ColorValCell(ValCell):
def __init__(self, text, a):
- self._color_class = 'unknown' if a.undefined \
- else 'good' if a else 'bad'
+ if a.undefined:
+ self._color_class = 'unk-good' if a else 'unk-bad'
+ else:
+ self._color_class = 'good' if a else 'bad'
ValCell.__init__(self, text)
class BoolCell(ValCell):
- def __init__(self, cond):
- self._color_class = 'good' if cond else 'bad'
- ValCell.__init__(self, 'OK' if cond else 'FAIL')
+ def __init__(self, r):
+ if filter(lambda a: not a.undefined, r.assertions):
+ self._color_class = 'good' if r else 'bad'
+ ValCell.__init__(self, 'OK' if r else 'FAIL')
+ else: # undefined result
+ self._color_class = 'unk-good' if r else 'unk-bad'
+ ValCell.__init__(self, 'n/a (but OK)' if r \
+ else 'n/a (but FAIL)')
class UnknownValCell(ValCell):
_color_class = 'unknown'
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/output/
@ 2011-08-06 14:25 Michał Górny
0 siblings, 0 replies; 14+ messages in thread
From: Michał Górny @ 2011-08-06 14:25 UTC (permalink / raw
To: gentoo-commits
commit: 485b1213bd5780b7343353985f5d4074aa800033
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 6 14:04:06 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Aug 6 14:04:06 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=485b1213
Support undefined in CLI output backend too.
---
pmstestsuite/output/__init__.py | 4 ++++
pmstestsuite/output/cli.py | 9 ++++++---
pmstestsuite/output/html.py | 2 +-
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/pmstestsuite/output/__init__.py b/pmstestsuite/output/__init__.py
index 0c7c8be..341fcd8 100644
--- a/pmstestsuite/output/__init__.py
+++ b/pmstestsuite/output/__init__.py
@@ -45,6 +45,10 @@ class TestResult(BoolCompat):
return self._exc
return None
+ @property
+ def undefined(self):
+ return not filter(lambda a: not a.undefined, self.assertions)
+
class OutputModule(ABCObject):
""" A module handling test results output. """
diff --git a/pmstestsuite/output/cli.py b/pmstestsuite/output/cli.py
index 9c664ab..318eb8f 100644
--- a/pmstestsuite/output/cli.py
+++ b/pmstestsuite/output/cli.py
@@ -20,10 +20,13 @@ class CLIOutput(OutputModule):
len(results), len(failed)))
tl = failed if not verbose else results.items()
for t, r in tl:
- print('- %s [%s]' % (t, 'OK' if r else 'FAILED'))
+ print('- %s [%s%s]' % (t,
+ 'OK' if r else 'FAILED',
+ '/UNDEF' if r.undefined else ''))
for a in r.assertions:
- print('-> %s: %s [%s]' % (a.name, str(a),
- 'OK' if a else 'FAILED'))
+ print('-> %s: %s [%s%s]' % (a.name, str(a),
+ 'OK' if a else 'FAILED',
+ '/UNDEF' if a.undefined else ''))
ret &= bool(failed)
return ret
diff --git a/pmstestsuite/output/html.py b/pmstestsuite/output/html.py
index 45c7398..f766ffe 100644
--- a/pmstestsuite/output/html.py
+++ b/pmstestsuite/output/html.py
@@ -127,7 +127,7 @@ class HTMLOutput(OutputModule):
class BoolCell(ValCell):
def __init__(self, r):
- if filter(lambda a: not a.undefined, r.assertions):
+ if not r.undefined:
self._color_class = 'good' if r else 'bad'
ValCell.__init__(self, 'OK' if r else 'FAIL')
else: # undefined result
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/output/
@ 2011-08-11 8:53 Michał Górny
0 siblings, 0 replies; 14+ messages in thread
From: Michał Górny @ 2011-08-11 8:53 UTC (permalink / raw
To: gentoo-commits
commit: d9b77dcd10b5314528b32858f1e6108280f0960c
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 11 08:48:45 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Aug 11 08:48:59 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=d9b77dcd
Use short test names in HTML output (instead of direct classes).
---
pmstestsuite/output/html.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/pmstestsuite/output/html.py b/pmstestsuite/output/html.py
index f766ffe..749f95e 100644
--- a/pmstestsuite/output/html.py
+++ b/pmstestsuite/output/html.py
@@ -79,7 +79,7 @@ class HTMLOutput(OutputModule):
def _results_by_class(reorderedresults):
ret = defaultdict(dict)
for t, r in reorderedresults.items():
- ret[t.__class__.__name__][t] = r
+ ret[t.short_name][t] = r
return ret
def _sorted_pms(pms):
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/output/
@ 2011-08-11 8:53 Michał Górny
0 siblings, 0 replies; 14+ messages in thread
From: Michał Górny @ 2011-08-11 8:53 UTC (permalink / raw
To: gentoo-commits
commit: 6cd3f23af97c0b0c15463702288a1d5a644c607c
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 11 08:54:27 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Aug 11 08:54:27 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=6cd3f23a
HTML: order tests by short name.
---
pmstestsuite/output/html.py | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/pmstestsuite/output/html.py b/pmstestsuite/output/html.py
index 749f95e..78599db 100644
--- a/pmstestsuite/output/html.py
+++ b/pmstestsuite/output/html.py
@@ -80,7 +80,8 @@ class HTMLOutput(OutputModule):
ret = defaultdict(dict)
for t, r in reorderedresults.items():
ret[t.short_name][t] = r
- return ret
+ for cl in sorted(ret):
+ yield cl, ret[cl]
def _sorted_pms(pms):
for pm in sorted(pms, key = lambda pm: mypms.index(pm)):
@@ -163,7 +164,7 @@ class HTMLOutput(OutputModule):
maxcol = 6 + i*2
row = 2
- for cl, tests in _results_by_class(results).items():
+ for cl, tests in _results_by_class(results):
table[row][0] = cl
for t in sorted(tests, key = lambda t: t.eapi):
table[row][1] = t.eapi
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/output/
@ 2011-08-11 22:09 Michał Górny
0 siblings, 0 replies; 14+ messages in thread
From: Michał Górny @ 2011-08-11 22:09 UTC (permalink / raw
To: gentoo-commits
commit: 150922e396994a0c595cab38af54927474543f57
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 11 22:06:39 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Aug 11 22:06:39 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=150922e3
HTML output: split assertion names into (prefix, realname).
---
pmstestsuite/output/html.py | 62 +++++++++++++++++++++++++++----------------
1 files changed, 39 insertions(+), 23 deletions(-)
diff --git a/pmstestsuite/output/html.py b/pmstestsuite/output/html.py
index 78599db..abcd5af 100644
--- a/pmstestsuite/output/html.py
+++ b/pmstestsuite/output/html.py
@@ -3,6 +3,8 @@
# Released under the terms of the 2-clause BSD license.
from collections import defaultdict
+from gentoopm.util import ABCObject
+from abc import abstractmethod
from pmstestsuite.output import OutputModule
@@ -87,12 +89,24 @@ class HTMLOutput(OutputModule):
for pm in sorted(pms, key = lambda pm: mypms.index(pm)):
yield (pm, pms[pm])
- class HTMLElem(object):
+ class HTMLElem(ABCObject):
+ @abstractmethod
+ def set_rowspan(self, rowspan):
+ pass
+
+ @abstractmethod
+ def __str__(self):
+ pass
+
+ class TD(HTMLElem):
_elem = 'td'
- def __init__(self, text):
+ def __init__(self, text, colspan = 1):
self._attrs = []
self._text = text
+ self._colspan = colspan
+ if colspan != 1:
+ self._attrs.append('colspan="%d"' % colspan)
def set_rowspan(self, rowspan):
if rowspan != 1:
@@ -102,20 +116,14 @@ class HTMLOutput(OutputModule):
return '<%s>%s</%s>' % (' '.join([self._elem] + self._attrs),
self._text, self._elem)
- class TH(HTMLElem):
+ class TH(TD):
_elem = 'th'
- def __init__(self, text, colspan = 1):
- HTMLElem.__init__(self, text)
- self._colspan = colspan
- if colspan != 1:
- self._attrs.append('colspan="%d"' % colspan)
-
- class ValCell(HTMLElem):
+ class ValCell(TD):
_color_class = ''
def __init__(self, text):
- HTMLElem.__init__(self, text)
+ TD.__init__(self, text)
self._attrs.append('class="value %s"' % self._color_class)
class ColorValCell(ValCell):
@@ -145,6 +153,9 @@ class HTMLOutput(OutputModule):
def __init__(self):
pass
+ def set_rowspan(self, rowspan):
+ pass
+
def __str__(self):
return ''
@@ -154,14 +165,14 @@ class HTMLOutput(OutputModule):
table[0][0] = TH('Test name')
table[0][1] = TH('EAPI')
- table[0][2] = TH('Assertion')
- table[0][3] = TH('Expected')
+ table[0][2] = TH('Assertion', colspan = 2)
+ table[0][4] = TH('Expected')
for i, pm in enumerate(mypms):
- table[0][4 + i*2] = TH(pm.name, colspan = 2)
- table[0][5 + i*2] = NoCell()
- table[1][4 + i*2] = TH('Actual')
- table[1][5 + i*2] = TH('Result')
- maxcol = 6 + i*2
+ table[0][5 + i*2] = TH(pm.name, colspan = 2)
+ table[0][6 + i*2] = NoCell()
+ table[1][5 + i*2] = TH('Actual')
+ table[1][6 + i*2] = TH('Result')
+ maxcol = 7 + i*2
row = 2
for cl, tests in _results_by_class(results):
@@ -169,16 +180,21 @@ class HTMLOutput(OutputModule):
for t in sorted(tests, key = lambda t: t.eapi):
table[row][1] = t.eapi
test_asserts = []
- col = 4
+ col = 5
for pm, r in _sorted_pms(tests[t]):
table[row][col+1] = BoolCell(r)
for a in r.assertions:
if a.name not in test_asserts:
test_asserts.append(a.name)
crow = row + test_asserts.index(a.name)
- table[crow][2] = a.name
- table[crow][3] = ValCell(a.expected)
- for c in range(4, maxcol, 2):
+ if a.prefix is not None:
+ table[crow][2] = a.prefix
+ table[crow][3] = a.unprefixed_name
+ else:
+ table[crow][2] = TD(a.name, colspan = 2)
+ table[crow][3] = NoCell()
+ table[crow][4] = ValCell(a.expected)
+ for c in range(5, maxcol, 2):
table[crow][c] = UnknownValCell()
else:
crow = row + test_asserts.index(a.name)
@@ -202,7 +218,7 @@ class HTMLOutput(OutputModule):
break
if not isinstance(cell, HTMLElem):
- cell = HTMLElem(cell)
+ cell = TD(cell)
cell.set_rowspan(rowspan)
f.write(str(cell))
f.write('</tr>')
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/output/
@ 2011-08-11 22:09 Michał Górny
0 siblings, 0 replies; 14+ messages in thread
From: Michał Górny @ 2011-08-11 22:09 UTC (permalink / raw
To: gentoo-commits
commit: a90ac95ab4bc14e0646ac23793799429166dd18b
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 11 22:10:20 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Aug 11 22:10:20 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=a90ac95a
HTML output: let assertion prefixes rowspan.
---
pmstestsuite/output/html.py | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/pmstestsuite/output/html.py b/pmstestsuite/output/html.py
index abcd5af..f423d8f 100644
--- a/pmstestsuite/output/html.py
+++ b/pmstestsuite/output/html.py
@@ -183,12 +183,13 @@ class HTMLOutput(OutputModule):
col = 5
for pm, r in _sorted_pms(tests[t]):
table[row][col+1] = BoolCell(r)
- for a in r.assertions:
+ for ai, a in enumerate(r.assertions):
if a.name not in test_asserts:
test_asserts.append(a.name)
crow = row + test_asserts.index(a.name)
if a.prefix is not None:
- table[crow][2] = a.prefix
+ if ai == 0 or table[crow-1][2] != a.prefix:
+ table[crow][2] = a.prefix
table[crow][3] = a.unprefixed_name
else:
table[crow][2] = TD(a.name, colspan = 2)
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/output/
@ 2011-08-12 9:35 Michał Górny
0 siblings, 0 replies; 14+ messages in thread
From: Michał Górny @ 2011-08-12 9:35 UTC (permalink / raw
To: gentoo-commits
commit: 3a4f945b68d90eb9d9bc7b05273361928b29837b
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 12 09:33:07 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Aug 12 09:33:24 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=3a4f945b
HTML output: include PM version as well.
---
pmstestsuite/output/html.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/pmstestsuite/output/html.py b/pmstestsuite/output/html.py
index f423d8f..d5e0676 100644
--- a/pmstestsuite/output/html.py
+++ b/pmstestsuite/output/html.py
@@ -168,7 +168,7 @@ class HTMLOutput(OutputModule):
table[0][2] = TH('Assertion', colspan = 2)
table[0][4] = TH('Expected')
for i, pm in enumerate(mypms):
- table[0][5 + i*2] = TH(pm.name, colspan = 2)
+ table[0][5 + i*2] = TH('%s %s' % (pm.name, pm.version), colspan = 2)
table[0][6 + i*2] = NoCell()
table[1][5 + i*2] = TH('Actual')
table[1][6 + i*2] = TH('Result')
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/output/
@ 2011-08-15 18:06 Michał Górny
0 siblings, 0 replies; 14+ messages in thread
From: Michał Górny @ 2011-08-15 18:06 UTC (permalink / raw
To: gentoo-commits
commit: 7f66b2880e45436f17648dcba89aaaca82194869
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 15 17:05:50 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Aug 15 18:07:34 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=7f66b288
Clean up whitespace in HTML output.
---
pmstestsuite/output/html.py | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/pmstestsuite/output/html.py b/pmstestsuite/output/html.py
index 71ea2ac..20e5805 100644
--- a/pmstestsuite/output/html.py
+++ b/pmstestsuite/output/html.py
@@ -62,12 +62,13 @@ class HTMLOutput(OutputModule):
</style>
</head>
<body>
- <table>'''
+ <table>
+'''
- _htmlfooter = '''
- </table>
+ _htmlfooter = ''' </table>
</body>
-</html>'''
+</html>
+'''
def __call__(self, allresults, verbose = False):
mypms = []
@@ -209,7 +210,7 @@ class HTMLOutput(OutputModule):
f = open(self._path, 'w')
f.write(self._htmlheader)
for y in range(0, row):
- f.write('<tr>')
+ f.write('\t\t\t<tr>')
for x in range(0, maxcol):
cell = table[y][x]
if cell is not None:
@@ -224,7 +225,7 @@ class HTMLOutput(OutputModule):
cell = TD(cell)
cell.set_rowspan(rowspan)
f.write(str(cell))
- f.write('</tr>')
+ f.write('</tr>\n')
f.write(self._htmlfooter)
f.close()
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/output/
@ 2012-01-03 15:52 Michał Górny
0 siblings, 0 replies; 14+ messages in thread
From: Michał Górny @ 2012-01-03 15:52 UTC (permalink / raw
To: gentoo-commits
commit: 4f39764c49369c219abc8412eeb9e0b77c137e2e
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 3 12:02:37 2012 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Jan 3 12:02:37 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=4f39764c
Fix CLI output exit status.
---
pmstestsuite/output/cli.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/pmstestsuite/output/cli.py b/pmstestsuite/output/cli.py
index d07fbfa..540abaf 100644
--- a/pmstestsuite/output/cli.py
+++ b/pmstestsuite/output/cli.py
@@ -29,6 +29,6 @@ class CLIOutput(OutputModule):
print('-> %s: %s [%s%s]' % (a.name, str(a),
'OK' if a else 'FAILED',
'/UNDEF' if a.undefined else ''))
- ret &= bool(failed)
+ ret &= not bool(failed)
return ret
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/output/
@ 2013-08-09 23:01 Michał Górny
0 siblings, 0 replies; 14+ messages in thread
From: Michał Górny @ 2013-08-09 23:01 UTC (permalink / raw
To: gentoo-commits
commit: 937c6ffa48527d5898fa9fab3ca97010aca0d1a1
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 9 23:00:48 2013 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Aug 9 23:01:08 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=937c6ffa
Add a wiki output backend.
---
pmstestsuite/output/__init__.py | 3 +-
pmstestsuite/output/wiki.py | 187 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 189 insertions(+), 1 deletion(-)
diff --git a/pmstestsuite/output/__init__.py b/pmstestsuite/output/__init__.py
index fcfd27e..7736b45 100644
--- a/pmstestsuite/output/__init__.py
+++ b/pmstestsuite/output/__init__.py
@@ -90,5 +90,6 @@ def get_output_modules():
from pmstestsuite.output.cli import CLIOutput
from pmstestsuite.output.html import HTMLOutput
+ from pmstestsuite.output.wiki import WikiOutput
- return (CLIOutput, HTMLOutput)
+ return (CLIOutput, HTMLOutput, WikiOutput)
diff --git a/pmstestsuite/output/wiki.py b/pmstestsuite/output/wiki.py
new file mode 100644
index 0000000..23b7178
--- /dev/null
+++ b/pmstestsuite/output/wiki.py
@@ -0,0 +1,187 @@
+# vim:fileencoding=utf-8
+# (c) 2011 Michał Górny <mgorny@gentoo.org>
+# Released under the terms of the 2-clause BSD license.
+
+from collections import defaultdict
+from gentoopm.util import ABCObject
+from abc import abstractmethod
+
+from . import OutputModule
+
+class WikiOutput(OutputModule):
+ """ Gentoo Wiki markup output module. """
+
+ name = 'wiki'
+
+ def __init__(self, path = None):
+ if path is None:
+ path = 'pms-test-suite-output.txt'
+ self._path = path
+
+ def __call__(self, allresults, verbose = False):
+ mypms = []
+
+ def _results_by_test(allresults):
+ ret = defaultdict(lambda: defaultdict(lambda: None))
+ for pm, results in allresults.items():
+ mypms.append(pm)
+ for t, r in results.items():
+ ret[t][pm] = r
+ return ret
+
+ def _results_by_class(reorderedresults):
+ ret = defaultdict(dict)
+ for t, r in reorderedresults.items():
+ ret[t.short_name][t] = r
+ for cl in sorted(ret):
+ yield cl, ret[cl]
+
+ def _sorted_pms(pms):
+ for pm in sorted(pms, key = lambda pm: mypms.index(pm)):
+ yield (pm, pms[pm])
+
+ class HTMLElem(ABCObject):
+ @abstractmethod
+ def set_rowspan(self, rowspan):
+ pass
+
+ @abstractmethod
+ def __str__(self):
+ pass
+
+ class TD(HTMLElem):
+ _elem = '|'
+
+ def __init__(self, text, colspan = 1):
+ self._attrs = []
+ self._text = text
+ self._colspan = colspan
+ if colspan != 1:
+ self._attrs.append('colspan="%d"' % colspan)
+
+ def set_rowspan(self, rowspan):
+ if rowspan != 1:
+ self._attrs.append('rowspan="%d"' % rowspan)
+
+ def __str__(self):
+ out = self._text
+ if self._attrs:
+ out = '%s | %s' % (' '.join(self._attrs), out)
+ return '| %s\n' % out
+
+ class TH(TD):
+ _elem = '!'
+
+ class ValCell(TD):
+ _color_class = ''
+
+ def __init__(self, text):
+ text = '<tt><nowiki>%s</nowiki></tt>' % text
+ TD.__init__(self, text)
+ if self._color_class:
+ self._attrs.append('style="%s"' % self._color_class)
+
+ style_good = 'background: #88e888;'
+ style_bad = 'background: #e88888;'
+ style_unk_good = 'color: #008800;'
+ style_unk_bad = 'color: #880000;'
+
+ class ColorValCell(ValCell):
+ def __init__(self, text, a):
+ if a.undefined:
+ self._color_class = style_unk_good if a else style_unk_bad
+ else:
+ self._color_class = style_good if a else style_bad
+ ValCell.__init__(self, text)
+
+ class BoolCell(ValCell):
+ def __init__(self, r):
+ if not r.undefined:
+ self._color_class = style_good if r else style_bad
+ ValCell.__init__(self, 'OK' if r else 'FAIL')
+ else: # undefined result
+ self._color_class = style_unk_good if r else style_unk_bad
+ ValCell.__init__(self, 'n/a (but OK)' if r \
+ else 'n/a (but FAIL)')
+
+ class UnknownValCell(ValCell):
+ def __init__(self):
+ ValCell.__init__(self, '?')
+
+ class NoCell(HTMLElem):
+ def __init__(self):
+ pass
+
+ def set_rowspan(self, rowspan):
+ pass
+
+ def __str__(self):
+ return ''
+
+ ret = True
+ results = _results_by_test(allresults)
+ table = defaultdict(lambda: defaultdict(lambda: None))
+
+ table[0][0] = TH('Test name')
+ table[0][1] = TH('EAPI')
+ table[0][2] = TH('Assertion', colspan = 2)
+ table[0][4] = TH('Expected')
+ for i, pm in enumerate(mypms):
+ table[0][5 + i*2] = TH('%s %s' % (pm.name, pm.version), colspan = 2)
+ table[0][6 + i*2] = NoCell()
+ table[1][5 + i*2] = TH('Actual')
+ table[1][6 + i*2] = TH('Result')
+ maxcol = 7 + i*2
+
+ row = 2
+ for cl, tests in _results_by_class(results):
+ table[row][0] = cl
+ for t in sorted(tests, key = lambda t: t.eapi):
+ table[row][1] = t.eapi
+ test_asserts = []
+ col = 5
+ for pm, r in _sorted_pms(tests[t]):
+ table[row][col+1] = BoolCell(r)
+ for ai, a in enumerate(r.assertions):
+ if a.name not in test_asserts:
+ test_asserts.append(a.name)
+ crow = row + test_asserts.index(a.name)
+ if a.prefix is not None:
+ if ai == 0 or table[crow-1][2] != a.prefix:
+ table[crow][2] = a.prefix
+ table[crow][3] = a.unprefixed_name
+ else:
+ table[crow][2] = TD(a.name, colspan = 2)
+ table[crow][3] = NoCell()
+ table[crow][4] = ValCell(a.expected)
+ for c in range(5, maxcol, 2):
+ table[crow][c] = UnknownValCell()
+ else:
+ crow = row + test_asserts.index(a.name)
+
+ table[crow][col] = ColorValCell(a.actual, a)
+ col += 2
+ row += len(test_asserts)
+
+ f = open(self._path, 'w')
+ f.write('{| class="wikitable"\n')
+ for y in range(0, row):
+ f.write('|-\n')
+ for x in range(0, maxcol):
+ cell = table[y][x]
+ if cell is not None:
+ rowspan = 1
+ for y2 in range(y + 1, row):
+ if table[y2][x] is None:
+ rowspan += 1
+ else:
+ break
+
+ if not isinstance(cell, HTMLElem):
+ cell = TD(cell)
+ cell.set_rowspan(rowspan)
+ f.write(str(cell))
+ f.write('|}\n')
+ f.close()
+
+ return ret
^ permalink raw reply related [flat|nested] 14+ messages in thread
end of thread, other threads:[~2013-08-09 23:01 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-05 21:36 [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/output/ Michał Górny
-- strict thread matches above, loose matches on Subject: below --
2013-08-09 23:01 Michał Górny
2012-01-03 15:52 Michał Górny
2011-08-15 18:06 Michał Górny
2011-08-12 9:35 Michał Górny
2011-08-11 22:09 Michał Górny
2011-08-11 22:09 Michał Górny
2011-08-11 8:53 Michał Górny
2011-08-11 8:53 Michał Górny
2011-08-06 14:25 Michał Górny
2011-08-06 14:25 Michał Górny
2011-08-06 8:31 Michał Górny
2011-08-05 21:36 Michał Górny
2011-08-05 19:54 Michał Górny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox