From: 16:34:04 Tim Janik Date: Thu, 20 Dec 2007 15:35:21 +0000 (+0000) Subject: commented class definitions. moved HTML character escaping out of X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=798aaac34f72ab246a9ae482aeae0f00cc6b2b47;p=dana%2Fcg-glib.git commented class definitions. moved HTML character escaping out of 2007-12-20 16:34:04 Tim Janik * glib/gtester-report: commented class definitions. moved HTML character escaping out of javascript. fixed string->bool conversions. added performance results to test case "Details" window. svn path=/trunk/; revision=6176 --- diff --git a/ChangeLog b/ChangeLog index 6a258bc2..3e308db2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-12-20 16:34:04 Tim Janik + + * glib/gtester-report: commented class definitions. moved HTML character + escaping out of javascript. fixed string->bool conversions. added performance + results to test case "Details" window. + 2007-12-20 Matthias Clasen * glib/gchecksum.[hc] (g_checksum_new): Return NULL when diff --git a/glib/gtester-report b/glib/gtester-report index f426826f..b385094f 100755 --- a/glib/gtester-report +++ b/glib/gtester-report @@ -69,6 +69,7 @@ def html_indent_string (n): string += uncollapsible_space return string +# TestBinary object, instantiated per test binary in the log file class TestBinary: def __init__ (self, name): self.name = name @@ -79,6 +80,7 @@ class TestBinary: self.file = '???' self.random_seed = '' +# base class to handle processing/traversion of XML nodes class TreeProcess: def __init__ (self): self.nest_level = 0 @@ -101,6 +103,7 @@ class TreeProcess: self.trampoline (child) self.nest_level += 1 +# test report reader, this class collects some statistics and merges duplicate test binary runs class ReportReader (TreeProcess): def __init__ (self): TreeProcess.__init__ (self) @@ -117,7 +120,7 @@ class ReportReader (TreeProcess): result = attribute_as_text (node, 'result', 'status') if result == 'success': self.last_binary.success_cases += 1 - if bool (attribute_as_text (node, 'skipped')): + if bool (int (attribute_as_text (node, 'skipped') + '0')): self.last_binary.skipped_cases += 1 def handle_text (self, node): pass @@ -141,6 +144,7 @@ class ReportReader (TreeProcess): self.last_binary.random_seed = node_as_text (rseed) self.process_children (node) +# HTML report generation class class ReportWriter (TreeProcess): # Javascript/CSS snippet to toggle element visibility cssjs = r''' @@ -164,11 +168,8 @@ class ReportWriter (TreeProcess): } } message_array = Array(); - function view_testlog (wname, file, random_seed, tcase, msgid) { + function view_testlog (wname, file, random_seed, tcase, msgtitle, msgid) { txt = message_array[msgid]; - txt = txt.replace (/&/g, "&"); - txt = txt.replace (//g, ">"); var w = window.open ("", // URI wname, "resizable,scrollbars,status,width=790,height=400"); @@ -176,7 +177,7 @@ class ReportWriter (TreeProcess): doc.write ("

File: " + file + "

\n"); doc.write ("

Case: " + tcase + "

\n"); doc.write ("Random Seed: " + random_seed + "

\n"); - doc.write ("Output:
\n"); + doc.write ("" + msgtitle + "
\n"); doc.write ("
");
       doc.write (txt);
       doc.write ("
\n"); @@ -202,7 +203,7 @@ class ReportWriter (TreeProcess): def handle_text (self, node): self.oprint (node.nodeValue) def handle_testcase (self, node, binary): - skipped = bool (attribute_as_text (node, 'skipped')) + skipped = bool (int (attribute_as_text (node, 'skipped') + '0')) if skipped: return # skipped tests are uninteresting for HTML reports path = attribute_as_text (node, 'path') @@ -216,6 +217,7 @@ class ReportWriter (TreeProcess): duration = '-' # ignore bogus durations self.oprint ('\n' % (self.bcounter, self.tcounter, result)) self.oprint ('%s %s %s \n' % (html_indent_string (4), path, duration)) + perflist = list_children (node, 'performance') if result != 'success': rlist = list_children (node, 'error') txt = '' @@ -225,9 +227,29 @@ class ReportWriter (TreeProcess): txt += '\n' txt = re.sub (r'"', r'\\"', txt) txt = re.sub (r'\n', r'\\n', txt) + txt = re.sub (r'&', r'&', txt) + txt = re.sub (r'<', r'<', txt) self.oprint ('\n' % (self.bcounter, self.tcounter, txt)) - self.oprint ('Output\n' % - ('TestOutputWindow', binary.file, binary.random_seed, path, self.bcounter, self.tcounter)) + self.oprint ('Details\n' % + ('TestResultWindow', binary.file, binary.random_seed, path, self.bcounter, self.tcounter)) + elif perflist: + presults = [] + for perf in perflist: + pmin = bool (int (attribute_as_text (perf, 'minimize'))) + pmax = bool (int (attribute_as_text (perf, 'maximize'))) + pval = float (attribute_as_text (perf, 'value')) + txt = node_as_text (perf) + txt = re.sub (r'&', r'&', txt) + txt = re.sub (r'<', r'>', txt) + txt = 'Performace(' + (pmin and 'minimized' or 'maximized') + '): ' + txt.strip() + '
\n' + txt = re.sub (r'"', r'\\"', txt) + txt = re.sub (r'\n', r'\\n', txt) + presults += [ (pval, txt) ] + presults.sort() + ptxt = ''.join ([e[1] for e in presults]) + self.oprint ('\n' % (self.bcounter, self.tcounter, ptxt)) + self.oprint ('Details\n' % + ('TestResultWindow', binary.file, binary.random_seed, path, self.bcounter, self.tcounter)) else: self.oprint ('-\n') self.oprint ('%s\n' % (rcolor, result)) @@ -291,6 +313,7 @@ class ReportWriter (TreeProcess): self.oprint ('\n') self.oprint ('\n') +# main program handling def parse_files_and_args (): from sys import argv, stdin files = []