Bug 1058038 - Improve Marionette failure notices for frontend tests when the test fails to find "Complete". r=cmanchester
authorMark Banner <standard8@mozilla.com>
Fri, 02 Jan 2015 15:43:30 +0000
changeset 247673 4cc15f56104cb2a15ce9b6019459bf51aed8fb7a
parent 247672 60901e935dd66d8900e738764480850a6ad1f76e
child 247674 5e34d8220c131d83090643565a54c733ebe50a02
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscmanchester
bugs1058038
milestone37.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 1058038 - Improve Marionette failure notices for frontend tests when the test fails to find "Complete". r=cmanchester
browser/components/loop/test/shared/frontend_tester.py
--- a/browser/components/loop/test/shared/frontend_tester.py
+++ b/browser/components/loop/test/shared/frontend_tester.py
@@ -1,9 +1,10 @@
 from marionette_test import MarionetteTestCase
+from errors import NoSuchElementException
 import threading
 import SimpleHTTPServer
 import SocketServer
 import BaseHTTPServer
 import socket
 import urllib
 import urlparse
 import os
@@ -80,17 +81,28 @@ class BaseTestFrontendUnits(MarionetteTe
 
         # Finally join the relative path with the given src path
         self.server_prefix = urlparse.urljoin("http://localhost:" + str(self.port),
                                               self.relPath)
 
     def check_page(self, page):
 
         self.marionette.navigate(urlparse.urljoin(self.server_prefix, page))
-        self.marionette.find_element("id", 'complete')
+        try:
+            self.marionette.find_element("id", 'complete')
+        except NoSuchElementException:
+            fullPageUrl = urlparse.urljoin(self.relPath, page)
+
+            details = "%s: 1 failure encountered\n%s" % \
+                      (fullPageUrl,
+                       self.get_failure_summary(
+                           fullPageUrl, "Waiting for Completion",
+                           "Could not find the test complete indicator"))
+
+            raise AssertionError(details)
 
         fail_node = self.marionette.find_element("css selector",
                                                  '.failures > em')
         if fail_node.text == "0":
             return
 
         # This may want to be in a more general place triggerable by an env
         # var some day if it ends up being something we need often:
@@ -99,29 +111,33 @@ class BaseTestFrontendUnits(MarionetteTe
         # but not from marionette, uncomment the two lines below to break
         # on failing tests, so that the browsers won't be torn down, and you
         # can use the browser debugging facilities to see what's going on.
         #from ipdb import set_trace
         #set_trace()
 
         raise AssertionError(self.get_failure_details(page))
 
+    def get_failure_summary(self, fullPageUrl, testName, testError):
+        return "TEST-UNEXPECTED-FAIL | %s | %s - %s" % (fullPageUrl, testName, testError)
+
     def get_failure_details(self, page):
         fail_nodes = self.marionette.find_elements("css selector",
                                                    '.test.fail')
         fullPageUrl = urlparse.urljoin(self.relPath, page)
 
         details = ["%s: %d failure(s) encountered:" % (fullPageUrl, len(fail_nodes))]
 
         for node in fail_nodes:
             errorText = node.find_element("css selector", '.error').text
 
             # We have to work our own failure message here, as we could be reporting multiple failures.
             # XXX Ideally we'd also give the full test tree for <test name> - that requires walking
             # up the DOM tree.
 
             # Format: TEST-UNEXPECTED-FAIL | <filename> | <test name> - <test error>
             details.append(
-                "TEST-UNEXPECTED-FAIL | %s | %s - %s" % \
-                (fullPageUrl, node.find_element("tag name", 'h2').text.split("\n")[0], errorText.split("\n")[0]))
+                self.get_failure_summary(page,
+                                         node.find_element("tag name", 'h2').text.split("\n")[0],
+                                         errorText.split("\n")[0]))
             details.append(
                 errorText)
         return "\n".join(details)