Bug 873149 - Report the slowest test in mochitest, r=ted
authorMartijn Wargers <mwargers@mozilla.com>
Fri, 14 Jun 2013 02:03:48 +0200
changeset 140269 5d49f49bebb9a12d9139870c6691e1352284e8a1
parent 140268 91c8657b0fa98c32d036b9ab52a34c85588e1aff
child 140270 d712769487a4eb14b081467373a95f46190b90e9
push id1952
push usermozilla@noorenberghe.ca
push dateMon, 29 Jul 2013 05:36:04 +0000
treeherderfx-team@fac2d791f66b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs873149
milestone25.0a1
Bug 873149 - Report the slowest test in mochitest, r=ted
testing/mochitest/tests/SimpleTest/TestRunner.js
--- a/testing/mochitest/tests/SimpleTest/TestRunner.js
+++ b/testing/mochitest/tests/SimpleTest/TestRunner.js
@@ -79,16 +79,18 @@ TestRunner.originalTestURL = "";
 TestRunner._urls = [];
 TestRunner._lastAssertionCount = 0;
 TestRunner._expectedMinAsserts = 0;
 TestRunner._expectedMaxAsserts = 0;
 
 TestRunner.timeout = 5 * 60 * 1000; // 5 minutes.
 TestRunner.maxTimeouts = 4; // halt testing after too many timeouts
 TestRunner.runSlower = false;
+TestRunner.slowestTestTime = 0;
+TestRunner.slowestTestURL = "";
 
 TestRunner._expectingProcessCrash = false;
 
 /**
  * Make sure the tests don't hang indefinitely.
 **/
 TestRunner._numTimeouts = 0;
 TestRunner._currentTestStartTime = new Date().valueOf();
@@ -340,19 +342,20 @@ TestRunner.runNextTest = function() {
           var indicator = $("indicator");
           indicator.innerHTML = "Status: Fail (No checks actually run)";
           indicator.style.backgroundColor = "red";
         }
 
         SpecialPowers.unregisterProcessCrashObservers();
 
         TestRunner.log("TEST-START | Shutdown"); // used by automation.py
-        TestRunner.log("Passed: " + $("pass-count").innerHTML);
-        TestRunner.log("Failed: " + $("fail-count").innerHTML);
-        TestRunner.log("Todo:   " + $("todo-count").innerHTML);
+        TestRunner.log("Passed:  " + $("pass-count").innerHTML);
+        TestRunner.log("Failed:  " + $("fail-count").innerHTML);
+        TestRunner.log("Todo:    " + $("todo-count").innerHTML);
+        TestRunner.log("Slowest: " + TestRunner.slowestTestTime + 'ms - ' + TestRunner.slowestTestURL);
         // If we are looping, don't send this cause it closes the log file
         if (TestRunner.repeat == 0) {
           TestRunner.log("SimpleTest FINISHED");
         }
 
         if (TestRunner.repeat == 0 && TestRunner.onComplete) {
              TestRunner.onComplete();
          }
@@ -431,16 +434,20 @@ TestRunner.testFinished = function(tests
                              " because it didn't call SimpleTest.finish()");
             tests.push({ result: false });
         }
 
         var runtime = new Date().valueOf() - TestRunner._currentTestStartTime;
         TestRunner.log("TEST-END | " +
                        TestRunner.currentTestURL +
                        " | finished in " + runtime + "ms");
+        if (TestRunner.slowestTestTime < runtime && TestRunner._timeoutFactor == 1) {
+          TestRunner.slowestTestTime = runtime;
+          TestRunner.slowestTestURL = TestRunner.currentTestURL;
+        }
 
         TestRunner.updateUI(tests);
 
         var interstitialURL;
         if ($('testframe').contentWindow.location.protocol == "chrome:") {
             interstitialURL = "tests/SimpleTest/iframe-between-tests.html";
         } else {
             interstitialURL = "/tests/SimpleTest/iframe-between-tests.html";