[glib] gtester-report: cope with binaries with no test cases



commit 03b5db44779c54947c3801609a42b2d2801b5a97
Author: Robert Bragg <robert linux intel com>
Date:   Thu May 6 15:46:00 2010 +0100

    gtester-report: cope with binaries with no test cases
    
    It's possible that a given binary may conditionally decided not to run
    any test cases (e.g. since they are all slow but -m=quick is currently
    in use) In this case the xml may contain <testbinary> nodes with no
    <testcase> children. This was resulting in a divide by zero when
    calculating the green â?? red color interpolation.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=617914

 glib/gtester-report |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/glib/gtester-report b/glib/gtester-report
index c2250e3..54eb5ff 100755
--- a/glib/gtester-report
+++ b/glib/gtester-report
@@ -268,16 +268,21 @@ class ReportWriter (TreeProcess):
       erlink = 'href="javascript:toggle_display (\'ResultTable\', \'tr\', \'b%u_\', \'failed\')"' % self.bcounter
     if binary.success_cases:
       oklink = 'href="javascript:toggle_display (\'ResultTable\', \'tr\', \'b%u_\', \'success\')"' % self.bcounter
-    self.oprint ('<a %s>ER</a>\n' % erlink)
-    self.oprint ('<a %s>OK</a>\n' % oklink)
-    self.oprint ('</td>\n')
-    perc = binary.success_cases * 100.0 / real_cases
-    pcolor = {
-      100 : 'bgcolor="lightgreen"',
-      0   : 'bgcolor="red"',
-    }.get (int (perc), 'bgcolor="yellow"')
-    self.oprint ('<td align="right" %s>%.2f%%</td>\n' % (pcolor, perc))
-    self.oprint ('</tr>\n')
+    if real_cases != 0:
+	self.oprint ('<a %s>ER</a>\n' % erlink)
+	self.oprint ('<a %s>OK</a>\n' % oklink)
+	self.oprint ('</td>\n')
+	perc = binary.success_cases * 100.0 / real_cases
+	pcolor = {
+	  100 : 'bgcolor="lightgreen"',
+	  0   : 'bgcolor="red"',
+	}.get (int (perc), 'bgcolor="yellow"')
+	self.oprint ('<td align="right" %s>%.2f%%</td>\n' % (pcolor, perc))
+	self.oprint ('</tr>\n')
+    else:
+	self.oprint ('Empty\n')
+	self.oprint ('</td>\n')
+	self.oprint ('</tr>\n')
     for tc in binary.testcases:
       self.handle_testcase (tc, binary)
   def handle_totals (self):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]