Bug 454781 - Mochitest doesn't align the names of the testfiles and test results, r=sayrer
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Tue, 21 Apr 2009 14:25:22 +0300
changeset 27565 04cb4a9e893b0c68ddae58ccfa907e3ffc0ac11b
parent 27564 84e3a35c19a6e4b6c57ee082d437c3461a83bd61
child 27566 5ce2bb1c635784572b432f8b633240c752082609
push id6618
push useropettay@mozilla.com
push dateTue, 21 Apr 2009 11:25:46 +0000
treeherdermozilla-central@04cb4a9e893b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssayrer
bugs454781
milestone1.9.2a1pre
Bug 454781 - Mochitest doesn't align the names of the testfiles and test results, r=sayrer
testing/mochitest/harness-overlay.xul
testing/mochitest/server.js
testing/mochitest/tests/SimpleTest/TestRunner.js
--- a/testing/mochitest/harness-overlay.xul
+++ b/testing/mochitest/harness-overlay.xul
@@ -43,21 +43,18 @@
       var srvScope = {};
       scriptLoader.loadSubScript("chrome://mochikit/content/server.js",
                                  srvScope);
 
       // generate our test list
       srvScope.makeTags();
       var url = "chrome://mochikit/content/" + dir + "/";
       var [links, count] = srvScope.list(url, chromeDir, true);
-      var listContent = srvScope.linksToListItems(links);
-      var tableContent = srvScope.linksToTableRows(links);
+      var tableContent = srvScope.linksToTableRows(links, 0);
       function populate() {
-        $("list-holder").setAttribute("rowspan", 1 + count);
-        $("test-list").innerHTML += listContent;
         $("test-table").innerHTML += tableContent;
         $("wrapper").innerHTML += " "; // redraw the table
       }
       gTestList = eval(srvScope.jsonArrayOfTestFiles(links));
       populate();
       hookup();
 
       // if we got passed a test path, just run that single test
@@ -97,19 +94,17 @@
           <br />
         </div>
         <div id="wrapper">
           <table cellpadding="0" cellspacing="0" id="test-table">
             <tr>
               <td>Passed</td>
               <td>Failed</td>
               <td>Todo</td>
-              <td id="list-holder">
-                <ul class="top" id="test-list"><li><b>Test Files</b></li></ul>
-              </td>
+              <td>Test Files</td>
             </tr>
           </table>
         </div>
       </div>
     </body>
   </vbox>
 </window>
 
--- a/testing/mochitest/server.js
+++ b/testing/mochitest/server.js
@@ -409,30 +409,55 @@ function linksToListItems(links)
 
   }
   return response;
 }
 
 /**
  * Transform nested hashtables of paths to a flat table rows.
  */
-function linksToTableRows(links)
+function linksToTableRows(links, recursionLevel)
 {
   var response = "";
   for (var [link, value] in links) {
     var classVal = (!isTest(link) && !(value instanceof Object))
       ? "non-test invisible"
       : "";
+
+    spacer = "padding-left: " + (10 * recursionLevel) + "px";
+
     if (value instanceof Object) {
       response += TR({class: "dir", id: "tr-" + link },
-                     TD({colspan: "3"},"&#160;"));
-      response += linksToTableRows(value);
+                     TD({colspan: "3"}, "&#160;"),
+                     TD({style: spacer},
+                        A({href: link}, link)));
+      response += linksToTableRows(value, recursionLevel + 1);
     } else {
-      response += TR({class: classVal, id: "tr-" + link},
-                     TD("0"), TD("0"), TD("0"));
+      var bug_title = link.match(/test_bug\S+/);
+      var bug_num = null;
+      if (bug_title != null) {
+          bug_num = bug_title[0].match(/\d+/);
+      }
+      if ((bug_title == null) || (bug_num == null)) {
+        response += TR({class: classVal, id: "tr-" + link },
+                       TD("0"),
+                       TD("0"),
+                       TD("0"),
+                       TD({style: spacer},
+                          A({href: link}, link)));
+      } else {
+        var bug_url = "https://bugzilla.mozilla.org/show_bug.cgi?id=" + bug_num;
+        response += TR({class: classVal, id: "tr-" + link },
+                       TD("0"),
+                       TD("0"),
+                       TD("0"),
+                       TD({style: spacer},
+                          A({href: link}, link), " - ",
+                          A({href: bug_url}, "Bug " + bug_num)));
+      }
     }
   }
   return response;
 }
 
 function arrayOfTestFiles(linkArray, fileArray, testPattern) {
   for (var [link, value] in linkArray) {
     if (value instanceof Object) {
@@ -534,25 +559,18 @@ function testListing(metadata, response)
           ),
           DIV({class: "clear"}),
           DIV({class: "toggle"},
             A({href: "#", id: "toggleNonTests"}, "Show Non-Tests"),
             BR()
           ),
     
           TABLE({cellpadding: 0, cellspacing: 0, id: "test-table"},
-            TR(TD("Passed"), TD("Failed"), TD("Todo"), 
-                TD({rowspan: count+1},
-                   UL({class: "top"},
-                      LI(B("Test Files")),        
-                      linksToListItems(links)
-                      )
-                )
-            ),
-            linksToTableRows(links)
+            TR(TD("Passed"), TD("Failed"), TD("Todo"), TD("Test Files")),
+            linksToTableRows(links, 0)
           ),
           DIV({class: "clear"})
         )
       )
     )
   );
 }
 
--- a/testing/mochitest/tests/SimpleTest/TestRunner.js
+++ b/testing/mochitest/tests/SimpleTest/TestRunner.js
@@ -193,17 +193,16 @@ TestRunner.updateUI = function() {
   } else if (passCount > 0) {
     indicator.innerHTML = "Status: Pass";
     indicator.style.backgroundColor = "green";
   }
 
   // Set the table values
   var trID = "tr-" + $('current-test-path').innerHTML;
   var row = $(trID);
-  replaceChildNodes(row,
-    TD({'style':
-        {'backgroundColor': results.notOK > 0 ? "#f00":"#0d0"}}, results.OK),
-    TD({'style':
-        {'backgroundColor': results.notOK > 0 ? "#f00":"#0d0"}}, results.notOK),
-    TD({'style': {'backgroundColor':
-                   results.todo > 0 ? "orange":"#0d0"}}, results.todo)
-  );
+  var tds = row.getElementsByTagName("td");
+  tds[0].style.backgroundColor = results.notOK > 0 ? "#f00" : "#0d0";
+  tds[0].textContent = results.OK;
+  tds[1].style.backgroundColor = results.notOK > 0 ? "#f00" : "#0d0";
+  tds[1].textContent = results.notOK;
+  tds[2].style.backgroundColor = results.todo > 0 ? "orange" : "#0d0";
+  tds[2].textContent = results.todo;
 }