Bug 1465527 - Print stacks from parent tests in mach formatter. r?jgraham draft
authorAndreas Tolfsen <ato@sny.no>
Wed, 30 May 2018 18:29:35 +0100
changeset 802805 afa9afc44e19e1e435af329cd6dcd6f4d379aff1
parent 802711 9900cebb1f9000bd05731ba67736b7c51f7eb812
child 802806 88a5c478452e523be6ba70de719aad83a3d6fe12
child 802810 c780b2b82b2db42d9fab4ada012912df82f47895
push id111967
push userbmo:ato@sny.no
push dateFri, 01 Jun 2018 13:53:53 +0000
reviewersjgraham
bugs1465527
milestone62.0a1
Bug 1465527 - Print stacks from parent tests in mach formatter. r?jgraham Parent tests may also have stacktraces and this patch prints and formats them the same way we do for subtests' stacks. MozReview-Commit-ID: 64gfPWuQnHd
testing/mozbase/mozlog/mozlog/formatters/machformatter.py
--- a/testing/mozbase/mozlog/mozlog/formatters/machformatter.py
+++ b/testing/mozbase/mozlog/mozlog/formatters/machformatter.py
@@ -94,22 +94,24 @@ class MachFormatter(base.BaseFormatter):
             if status in ("PASS", "OK"):
                 status = "UNEXPECTED-%s" % status
         return color(status)
 
     def _format_status(self, test, data):
         name = data.get("subtest", test)
         rv = "%s %s" % (self._format_expected(
             data["status"], data.get("expected", data["status"])), name)
-        if 'message' in data:
-            rv += " - %s" % data['message']
+        if "message" in data:
+            rv += " - %s" % data["message"]
+        if "stack" in data:
+            rv += self._format_stack(data["stack"])
+        return rv
 
-        if 'stack' in data:
-            rv += "\n%s\n" % self.term.dim(data['stack'].strip('\n'))
-        return rv
+    def _format_stack(self, stack):
+        return "\n%s\n" % self.term.dim(stack.strip("\n"))
 
     def _format_suite_summary(self, suite, summary):
         count = summary['counts']
         logs = summary['unexpected_logs']
 
         rv = ["", self.term.yellow(suite), self.term.yellow("~" * len(suite))]
 
         # Format check counts
@@ -193,16 +195,18 @@ class MachFormatter(base.BaseFormatter):
             rv = "%s%s" % (data["status"], expected_str)
 
         unexpected = self.summary.current["unexpected_logs"].get(data["test"])
         if unexpected:
             if len(unexpected) == 1 and parent_unexpected:
                 message = unexpected[0].get("message", "")
                 if message:
                     rv += " - %s" % message
+                if "stack" in data:
+                    rv += self._format_stack(data["stack"])
             elif not self.verbose:
                 rv += "\n"
                 for d in unexpected:
                     rv += self._format_status(data['test'], d)
 
         if "expected" not in data and not bool(subtests['unexpected']):
             color = self.term.green
         else: