self.time = time.gmtime()
self.datetime = time.strftime("%Y-%m-%d %H:%M:%S +0000", self.time)
self.filename = "results-"+time.strftime("%Y%m%d-%H%M%S", self.time)+".html"
+ self.stats = None
+
+ def genStats(self):
+ self.stats = Stats(self)
def toHtml(self):
s="""
<title>OMK test report %(datetime)s</title>
</head>
<body>
-<h2>Summary</h2>TODO
+<h2>Summary</h2>
""" % self.__dict__
+ s+=self.stats.toHtml()
s+="""
<h2>Chart</h2>
<table cellpadding='2' border='1'>
<pre>%(stderr)s</pre>""" % vals
return s
+class RulesStat:
+ def __init__(self, rules):
+ self.rules = rules
+ self.tests = 0
+ self.success = 0
+ self.errors = 0
+ self.canttest = 0
+ self.unknown = 0
+ def update(self, testCaseResult):
+ try:
+ resultEntry = testCaseResult[self.rules]
+ self.tests+=1
+ if resultEntry.exitcode == 0: self.success+=1
+ elif resultEntry.exitcode == 1: self.errors+=1
+ elif resultEntry.exitcode == 2: self.canttest+=1
+ else: self.unknown+=1
+ except KeyError:
+ pass
+ def toHtml(self):
+ if self.errors == 0 and self.canttest == 0: self.color=''
+ elif self.errors != 0: self.color=' bgcolor="red"'
+ elif self.canttest != 0: self.color=' bgcolor="yellow"'
+ else: self.color = ' bgcolor="gray"'
+ s="""
+ <tr%(color)s>
+ <td>%(rules)s</td>
+ <td>%(tests)d</td>
+ <td>%(success)d</td>
+ <td>%(errors)d</td>
+ <td>%(canttest)d</td>
+ <td>%(unknown)d</td>
+ </tr>
+ """ % self.__dict__
+ return s
+
+class Stats(dict):
+ def __init__(self, results):
+ rules = rulesdef.rules.keys()
+ for rule in rules:
+ rulesStat = RulesStat(rule)
+ self[rule]=rulesStat
+ for resultEntry in results.values():
+ rulesStat.update(resultEntry)
+
+ def toHtml(self):
+ s="""
+<table cellpadding='2' border='1'>
+<col />
+<col span='5' align='right' />
+<thead><tr>
+ <td>Rules</td>
+ <td>Total</td>
+ <td>Success</td>
+ <td>Errors</td>
+ <td>Can't test</td>
+ <td>Unknown</td>
+</tr></thead>
+<tbody>
+ """
+ rules = sorted(self.keys())
+ for r in rules:
+ s+=self[r].toHtml()
+ s+="""
+</tbody></table>"""
+ return s;
+
class TestCase:
def __init__(self, directory, executable):
self.directory = directory # Absolute directory
results[t.name] = t.results
os.chdir(invokeDir)
+results.genStats()
results.save()
# Local Variables:
-# compile-command: "python runtests.py"
+# compile-command: "python tester.py"
# End: