From 5f4013b16807bf4f6e607be2e6c60be5df688655 Mon Sep 17 00:00:00 2001
From: Sean Dague <sdague@linux.vnet.ibm.com>
Date: Tue, 22 Jan 2013 07:13:57 -0500
Subject: [PATCH] make html less jumpy

clean up the html in the subunit2html style so that when you
open up sections the whole thing doesn't jump around on you
(i.e. column widths change, hot links drop around.)

Do this by shrinking the desc (don't repeat class name)

For table to 100% width, but shrink first column to 40%

Shrink all the number columns to 40px, and add an 8th colum to take
up the slack that happens when the results are shown.

Make the results div overflow-x: scroll, to ensure the page doesn't
get wider than the browser.

Change-Id: I9346d703778287fa7f1c72e2de077f225af070fb
Reviewed-on: https://review.openstack.org/20223
Reviewed-by: James E. Blair <corvus@inaugust.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Approved: Clark Boylan <clark.boylan@gmail.com>
Tested-by: Jenkins
---
 .../files/slave_scripts/subunit2html.py       | 42 +++++++++++--------
 1 file changed, 24 insertions(+), 18 deletions(-)

diff --git a/modules/jenkins/files/slave_scripts/subunit2html.py b/modules/jenkins/files/slave_scripts/subunit2html.py
index 0fd9d7bb07..b8737ed010 100755
--- a/modules/jenkins/files/slave_scripts/subunit2html.py
+++ b/modules/jenkins/files/slave_scripts/subunit2html.py
@@ -228,8 +228,8 @@ function showOutput(id, name) {
 <style type="text/css" media="screen">
 body        { font-family: verdana, arial, helvetica, sans-serif;
     font-size: 80%; }
-table       { font-size: 100%; }
-pre         { }
+table       { font-size: 100%; width: 100%;}
+pre         { font-size: 80%; }
 
 /* -- heading -------------------------------------------------------------- */
 h1 {
@@ -261,16 +261,13 @@ a.popup_link:hover {
 
 .popup_window {
     display: none;
-    position: relative;
-    left: 0px;
-    top: 0px;
+    overflow-x: scroll;
     /*border: solid #627173 1px; */
     padding: 10px;
     background-color: #E6E6D6;
-    font-family: "Lucida Console", "Courier New", Courier, monospace;
+    font-family: "Ubuntu Mono", "Lucida Console", "Courier New", monospace;
     text-align: left;
     font-size: 8pt;
-    width: 90%;
 }
 
 }
@@ -280,7 +277,7 @@ a.popup_link:hover {
     margin-bottom: 1ex;
 }
 #result_table {
-    width: 80%;
+    width: 100%;
     border-collapse: collapse;
     border: 1px solid #777;
 }
@@ -302,7 +299,8 @@ a.popup_link:hover {
 .errorCase  { color: #c00; font-weight: bold; }
 .hiddenRow  { display: none; }
 .testcase   { margin-left: 2em; }
-
+td.testname {width: 40%}
+td.small {width: 40px}
 
 /* -- ending --------------------------------------------------------------- */
 #ending {
@@ -346,6 +344,7 @@ a.popup_link:hover {
 <col align='right' />
 <col align='right' />
 <col align='right' />
+<col align='right' />
 </colgroup>
 <tr id='header_row'>
     <td>Test Group/Test case</td>
@@ -355,6 +354,7 @@ a.popup_link:hover {
     <td>Error</td>
     <td>Skip</td>
     <td>View</td>
+    <td> </td>
 </tr>
 %(test_list)s
 <tr id='total_row'>
@@ -365,27 +365,29 @@ a.popup_link:hover {
     <td>%(error)s</td>
     <td>%(skip)s</td>
     <td>&nbsp;</td>
+    <td>&nbsp;</td>
 </tr>
 </table>
 """  # variables: (test_list, count, Pass, fail, error)
 
     REPORT_CLASS_TMPL = r"""
 <tr class='%(style)s'>
-    <td>%(desc)s</td>
-    <td>%(count)s</td>
-    <td>%(Pass)s</td>
-    <td>%(fail)s</td>
-    <td>%(error)s</td>
-    <td>%(skip)s</td>
-    <td><a href="javascript:showClassDetail('%(cid)s',%(count)s)"
+    <td class="testname">%(desc)s</td>
+    <td class="small">%(count)s</td>
+    <td class="small">%(Pass)s</td>
+    <td class="small">%(fail)s</td>
+    <td class="small">%(error)s</td>
+    <td class="small">%(skip)s</td>
+    <td class="small"><a href="javascript:showClassDetail('%(cid)s',%(count)s)"
 >Detail</a></td>
+    <td> </td>
 </tr>
 """  # variables: (style, desc, count, Pass, fail, error, cid)
 
     REPORT_TEST_WITH_OUTPUT_TMPL = r"""
 <tr id='%(tid)s' class='%(Class)s'>
     <td class='%(style)s'><div class='testcase'>%(desc)s</div></td>
-    <td colspan='6' align='center'>
+    <td colspan='7' align='left'>
 
     <!--css div popup start-->
     <a class="popup_link" onfocus='this.blur();'
@@ -632,7 +634,11 @@ class HtmlOutput(unittest.TestResult):
         tid = ((n == 0 or n == 3) and
                'p' or 'f') + 't%s.%s' % (cid + 1, tid + 1)
         name = t.id().split('.')[-1]
-        doc = t.shortDescription() or ""
+        # if shortDescription is not the function name, use it
+        if t.shortDescription().find(name) == -1:
+            doc = t.shortDescription()
+        else:
+            doc = None
         desc = doc and ('%s: %s' % (name, doc)) or name
         tmpl = (has_output and TemplateData.REPORT_TEST_WITH_OUTPUT_TMPL
                 or TemplateData.REPORT_TEST_NO_OUTPUT_TMPL)