Bug 1050251 - Use the correct message/name for chrome mochitest asserts. r=chmanchester, a=test-only
authorAhmed Kachkach <ahmed.kachkach@gmail.com>
Fri, 15 Aug 2014 14:42:00 -0400
changeset 216415 4b896ae5f54e619ce528f8833f5d8ee961c5ab58
parent 216414 254904326f4b3c7df0722c163d7d8306f60b07f0
child 216416 5435faed89b2b4ef1e3f6b835473442488aeeb28
push id3857
push userraliiev@mozilla.com
push dateTue, 02 Sep 2014 16:39:23 +0000
treeherdermozilla-beta@5638b907b505 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester, test-only
bugs1050251
milestone33.0a2
Bug 1050251 - Use the correct message/name for chrome mochitest asserts. r=chmanchester, a=test-only
testing/mochitest/browser-harness.xul
testing/mochitest/browser-test.js
testing/mochitest/runtests.py
testing/mochitest/tests/SimpleTest/TestRunner.js
--- a/testing/mochitest/browser-harness.xul
+++ b/testing/mochitest/browser-harness.xul
@@ -145,17 +145,17 @@
         if (result.info) {
           if (result.msg) {
             this.dumper.structuredLogger.info(result.msg);
           }
           return;
         }
 
         this.dumper.structuredLogger.testStatus(this.path,
-                                                result.msg,
+                                                result.name,
                                                 result.status,
                                                 result.expected,
                                                 result.msg);
       },
 
       setDuration: function setDuration(duration) {
         this.duration = duration;
       },
--- a/testing/mochitest/browser-test.js
+++ b/testing/mochitest/browser-test.js
@@ -679,17 +679,17 @@ Tester.prototype = {
         const MAX_UNEXPECTED_TIMEOUTS = 10;
         if (Date.now() - self.currentTest.lastOutputTime < (gTimeoutSeconds / 2) * 1000 &&
             ++self.currentTest.unexpectedTimeouts <= MAX_UNEXPECTED_TIMEOUTS) {
             self.currentTest.scope.__waitTimer =
               setTimeout(timeoutFn, gTimeoutSeconds * 1000);
           return;
         }
 
-        self.currentTest.addResult(new testResult(false, "Test timed out", "", false));
+        self.currentTest.addResult(new testResult(false, "Test timed out", null, false));
         self.currentTest.timedOut = true;
         self.currentTest.scope.__waitTimer = null;
         self.nextTest();
       }, gTimeoutSeconds * 1000);
     }
   },
 
   QueryInterface: function(aIID) {
@@ -697,17 +697,18 @@ Tester.prototype = {
         aIID.equals(Ci.nsISupports))
       return this;
 
     throw Components.results.NS_ERROR_NO_INTERFACE;
   }
 };
 
 function testResult(aCondition, aName, aDiag, aIsTodo, aStack) {
-  this.msg = aName || "";
+  this.name = aName;
+  this.msg = "";
 
   this.info = false;
   this.pass = !!aCondition;
   this.todo = aIsTodo;
 
   if (this.pass) {
     if (aIsTodo) {
       this.status = "FAIL";
@@ -716,19 +717,19 @@ function testResult(aCondition, aName, a
       this.status = "PASS";
       this.expected = "PASS";
     }
 
   } else {
     if (aDiag) {
       if (typeof aDiag == "object" && "fileName" in aDiag) {
         // we have an exception - print filename and linenumber information
-        this.msg += " at " + aDiag.fileName + ":" + aDiag.lineNumber;
+        this.msg += "at " + aDiag.fileName + ":" + aDiag.lineNumber + " - ";
       }
-      this.msg += " - " + aDiag;
+      this.msg += String(aDiag);
     }
     if (aStack) {
       this.msg += "\nStack trace:\n";
       let normalized;
       if (aStack instanceof Components.interfaces.nsIStackFrame) {
         let frames = [];
         for (let frame = aStack; frame; frame = frame.caller) {
           frames.push(frame.filename + ":" + frame.name + ":" + frame.lineNumber);
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -1973,19 +1973,18 @@ class Mochitest(MochitestUtilsMixin):
       """record last test on harness"""
       if message['action'] == 'test_start':
         self.harness.lastTestSeen = message['test']
       return message
 
     def dumpScreenOnTimeout(self, message):
       if (not self.dump_screen_on_fail
           and self.dump_screen_on_timeout
-          and 'expected' in message and message['status'] == 'FAIL'
-          and 'message' in message
-          and "Test timed out" in message['message']):
+          and message['action'] == 'test_status' and 'expected' in message
+          and "Test timed out" in message['subtest']):
         self.harness.dumpScreen(self.utilityPath)
       return message
 
     def dumpScreenOnFail(self, message):
       if self.dump_screen_on_fail and 'expected' in message and message['status'] == 'FAIL':
         self.harness.dumpScreen(self.utilityPath)
       return message
 
--- a/testing/mochitest/tests/SimpleTest/TestRunner.js
+++ b/testing/mochitest/tests/SimpleTest/TestRunner.js
@@ -136,17 +136,17 @@ function StructuredLogger(name) {
     this.testStart = function(test) {
         var data = {test: test};
         this._logData("test_start", data);
     };
 
     this.testStatus = function(test, subtest, status, expected="PASS", message=null) {
         var data = {test: test, subtest: subtest, status: status};
 
-        if (message !== null) {
+        if (message) {
             data.message = String(message);
         }
         if (expected != status && status != 'SKIP') {
             data.expected = expected;
         }
 
         this._logData("test_status", data);
     };