Bug 1037521 - Add information about unexpected results to mach output.
authorArnav Sharma <arnav.pokemonfan@gmail.com>
Tue, 22 Jul 2014 20:19:00 +0100
changeset 195588 8ab7e0d27367d6de6cb88acc69987d7b7ddeda29
parent 195587 b88aab9f4e80cf2351c44eaddd401cb806d519e0
child 195589 70bc8f7cde4ee14304e46d24ae5baf2cadd2581b
push id27188
push usercbook@mozilla.com
push dateWed, 23 Jul 2014 13:53:43 +0000
treeherdermozilla-central@785acfd2ae48 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1037521
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1037521 - Add information about unexpected results to mach output.
testing/mozbase/mozlog/mozlog/structured/formatters/machformatter.py
--- a/testing/mozbase/mozlog/mozlog/structured/formatters/machformatter.py
+++ b/testing/mozbase/mozlog/mozlog/structured/formatters/machformatter.py
@@ -43,58 +43,78 @@ class BaseMachFormatter(base.BaseFormatt
 
     def suite_end(self, data):
         return ""
 
     def test_start(self, data):
         return "%s" % (self._get_test_id(data),)
 
     def test_end(self, data):
+        subtests = self._get_subtest_data(data)
+        unexpected = subtests["unexpected"]
         if "expected" in data:
+            parent_unexpected = True
             expected_str = ", expected %s" % data["expected"]
+            unexpected.append(("[Parent]", data["status"], data["expected"],
+                               data.get("message", "")))
         else:
+            parent_unexpected = False
             expected_str = ""
 
-        subtests = self._get_subtest_data(data)
-        unexpected = subtests["unexpected"] + (1 if "expected" in data else 0)
-
         #Reset the counts to 0
         test = self._get_test_id(data)
-        self.status_buffer[test] = {"count": 0, "unexpected": 0, "pass": 0}
+        self.status_buffer[test] = {"count": 0, "unexpected": [], "pass": 0}
         self.has_unexpected[test] = bool(unexpected)
 
-        return "Harness status %s%s. Subtests passed %i/%i. Unexpected %i" % (
-            data["status"], expected_str, subtests["pass"],
-            subtests["count"], unexpected)
+        if subtests["count"] != 0:
+            rv = "Harness %s%s. Subtests passed %i/%i. Unexpected %s" % (
+                data["status"], expected_str, subtests["pass"], subtests["count"],
+                len(unexpected))
+        else:
+            rv = "%s%s" % (data["status"], expected_str)
+
+        if unexpected:
+            rv += "\n"
+            if len(unexpected) == 1 and parent_unexpected:
+                rv += "%s" % unexpected[0][-1]
+            else:
+                for name, status, expected, message in unexpected:
+                    expected_str = "Expected %s, got %s" % (expected, status)
+                    rv += "%s\n" % ("\n".join([name, "-" * len(name), expected_str, message]))
+                rv = rv[:-1]
+        return rv
 
     def test_status(self, data):
         test = self._get_test_id(data)
         if test not in self.status_buffer:
-            self.status_buffer[test] = {"count": 0, "unexpected": 0, "pass": 0}
+            self.status_buffer[test] = {"count": 0, "unexpected": [], "pass": 0}
         self.status_buffer[test]["count"] += 1
 
         if "expected" in data:
-            self.status_buffer[test]["unexpected"] += 1
+            self.status_buffer[test]["unexpected"].append((data["subtest"],
+                                                           data["status"],
+                                                           data["expected"],
+                                                           data.get("message")))
         if data["status"] == "PASS":
             self.status_buffer[test]["pass"] += 1
 
     def process_output(self, data):
         return '"%s" (pid:%s command:%s)' % (data["data"],
                                              data["process"],
                                              data["command"])
 
     def log(self, data):
         if data.get('component'):
             return " ".join([data["component"], data["level"], data["message"]])
 
         return "%s %s" % (data["level"], data["message"])
 
     def _get_subtest_data(self, data):
         test = self._get_test_id(data)
-        return self.status_buffer.get(test, {"count": 0, "unexpected": 0, "pass": 0})
+        return self.status_buffer.get(test, {"count": 0, "unexpected": [], "pass": 0})
 
     def _time(self, data):
         entry_time = data["time"]
         if self.write_interval and self.last_time is not None:
             t = entry_time - self.last_time
             self.last_time = entry_time
         else:
             t = entry_time - self.start_time