From f1038816751f3bcaa6e6846b4b110d7a8db83f37 Mon Sep 17 00:00:00 2001 From: Christian Holler Date: Wed, 19 Sep 2012 01:28:39 +0200 Subject: [PATCH] Bug 787916 - Hide Mochitest test table with --close-when-done option. r=jmaher --- testing/mochitest/runtests.py | 6 ++++-- testing/mochitest/server.js | 17 +++++++++++++---- .../mochitest/tests/SimpleTest/TestRunner.js | 18 +++++++++++------- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/testing/mochitest/runtests.py b/testing/mochitest/runtests.py index 86ab1bc7300..202ebb821ae 100644 --- a/testing/mochitest/runtests.py +++ b/testing/mochitest/runtests.py @@ -390,8 +390,10 @@ class MochitestServer: args = ["-g", self._xrePath, "-v", "170", "-f", "./" + "httpd.js", - "-e", "const _PROFILE_PATH = '%(profile)s';const _SERVER_PORT = '%(port)s'; const _SERVER_ADDR = '%(server)s'; const _TEST_PREFIX = %(testPrefix)s;" % - {"profile" : self._profileDir.replace('\\', '\\\\'), "port" : self.httpPort, "server" : self.webServer, "testPrefix" : self.testPrefix }, + "-e", """const _PROFILE_PATH = '%(profile)s';const _SERVER_PORT = '%(port)s'; const _SERVER_ADDR = '%(server)s'; + const _TEST_PREFIX = %(testPrefix)s; const _DISPLAY_RESULTS = %(displayResults)s;""" % + {"profile" : self._profileDir.replace('\\', '\\\\'), "port" : self.httpPort, "server" : self.webServer, + "testPrefix" : self.testPrefix, "displayResults" : str(not self._closeWhenDone).lower() }, "-f", "./" + "server.js"] xpcshell = os.path.join(self._utilityPath, diff --git a/testing/mochitest/server.js b/testing/mochitest/server.js index 3d1e7b9e7b6..ef6c80a70ef 100644 --- a/testing/mochitest/server.js +++ b/testing/mochitest/server.js @@ -108,6 +108,7 @@ if (this["nsHttpServer"]) { } var serverBasePath; +var displayResults = true; // // SERVER SETUP @@ -147,6 +148,11 @@ function runServer() throw "please define _SERVER_PORT (as a port number) before running server.js"; } + // If DISPLAY_RESULTS is not specified, it defaults to true + if (typeof(_DISPLAY_RESULTS) != "undefined") { + displayResults = _DISPLAY_RESULTS; + } + server._start(SERVER_PORT, gServerAddress); // touch a file in the profile directory to indicate we're alive @@ -629,10 +635,13 @@ function testListing(metadata, response) A({href: "#", id: "toggleNonTests"}, "Show Non-Tests"), BR() ), - - TABLE({cellpadding: 0, cellspacing: 0, class: table_class, id: "test-table"}, - TR(TD("Passed"), TD("Failed"), TD("Todo"), TD("Test Files")), - linksToTableRows(links, 0) + + ( + displayResults ? + TABLE({cellpadding: 0, cellspacing: 0, class: table_class, id: "test-table"}, + TR(TD("Passed"), TD("Failed"), TD("Todo"), TD("Test Files")), + linksToTableRows(links, 0) + ) : "" ), BR(), diff --git a/testing/mochitest/tests/SimpleTest/TestRunner.js b/testing/mochitest/tests/SimpleTest/TestRunner.js index c95534887d2..e57f8c57172 100644 --- a/testing/mochitest/tests/SimpleTest/TestRunner.js +++ b/testing/mochitest/tests/SimpleTest/TestRunner.js @@ -534,13 +534,17 @@ TestRunner.updateUI = function(tests) { // Set the table values var trID = "tr-" + $('current-test-path').innerHTML; var row = $(trID); - var tds = row.getElementsByTagName("td"); - tds[0].style.backgroundColor = "#0d0"; - tds[0].innerHTML = parseInt(tds[0].innerHTML) + parseInt(results.OK); - tds[1].style.backgroundColor = results.notOK > 0 ? "red" : "#0d0"; - tds[1].innerHTML = parseInt(tds[1].innerHTML) + parseInt(results.notOK); - tds[2].style.backgroundColor = results.todo > 0 ? "orange" : "#0d0"; - tds[2].innerHTML = parseInt(tds[2].innerHTML) + parseInt(results.todo); + + // Only update the row if it actually exists (autoUI) + if (row != null) { + var tds = row.getElementsByTagName("td"); + tds[0].style.backgroundColor = "#0d0"; + tds[0].innerHTML = parseInt(tds[0].innerHTML) + parseInt(results.OK); + tds[1].style.backgroundColor = results.notOK > 0 ? "red" : "#0d0"; + tds[1].innerHTML = parseInt(tds[1].innerHTML) + parseInt(results.notOK); + tds[2].style.backgroundColor = results.todo > 0 ? "orange" : "#0d0"; + tds[2].innerHTML = parseInt(tds[2].innerHTML) + parseInt(results.todo); + } //if we ran in a loop, display any found errors if (TestRunner.repeat > 0) {