Bug 1495510 [wpt PR 13290] - Fix #13289: handle non-str exception messages, a=testonly
authorGeoffrey Sneddon <me@gsnedders.com>
Fri, 05 Oct 2018 14:29:03 +0000
changeset 495831 dabfef752bbde656f1cd1cbc26ad0eae5690c13e
parent 495830 930b87142399e2249e0ec0ba654487b2c4fb6efd
child 495832 ae0c31bd0b0f02b2631ea83fff8a14eacc97e5e0
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1495510, 13290, 13289
milestone64.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 1495510 [wpt PR 13290] - Fix #13289: handle non-str exception messages, a=testonly Automatic update from web-platform-testsFix #13289: handle non-str exception messages -- Set result to INTERNAL-ERROR when _run exits abnormally This is more resiliant than relying on an assertion to have the same ultimate effect. -- wpt-commits: 87aced4b630de20060d43f644787d8a7ed042928, cd30ed9c9d86033365e37a76ace1b040e57064b2 wpt-pr: 13290
testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorselenium.py
testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorselenium.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorselenium.py
@@ -235,30 +235,34 @@ class SeleniumRun(object):
             self.logger.error("Lost WebDriver connection")
             return Stop
 
         executor = threading.Thread(target=self._run)
         executor.start()
 
         flag = self.result_flag.wait(timeout + 2 * extra_timeout)
         if self.result is None:
-            assert not flag
-            self.result = False, ("EXTERNAL-TIMEOUT", None)
+            if flag:
+                # flag is True unless we timeout; this *shouldn't* happen, but
+                # it can if self._run fails to set self.result due to raising
+                self.result = False, ("INTERNAL-ERROR", "self._run didn't set a result")
+            else:
+                self.result = False, ("EXTERNAL-TIMEOUT", None)
 
         return self.result
 
     def _run(self):
         try:
             self.result = True, self.func(self.protocol, self.url, self.timeout)
         except exceptions.TimeoutException:
             self.result = False, ("EXTERNAL-TIMEOUT", None)
         except (socket.timeout, exceptions.ErrorInResponseException):
             self.result = False, ("CRASH", None)
         except Exception as e:
-            message = getattr(e, "message", "")
+            message = str(getattr(e, "message", ""))
             if message:
                 message += "\n"
             message += traceback.format_exc(e)
             self.result = False, ("INTERNAL-ERROR", e)
         finally:
             self.result_flag.set()
 
 
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py
@@ -223,18 +223,22 @@ class WebDriverRun(object):
             self.logger.error("Lost WebDriver connection")
             return Stop
 
         executor = threading.Thread(target=self._run)
         executor.start()
 
         flag = self.result_flag.wait(timeout + 2 * extra_timeout)
         if self.result is None:
-            assert not flag
-            self.result = False, ("EXTERNAL-TIMEOUT", None)
+            if flag:
+                # flag is True unless we timeout; this *shouldn't* happen, but
+                # it can if self._run fails to set self.result due to raising
+                self.result = False, ("INTERNAL-ERROR", "self._run didn't set a result")
+            else:
+                self.result = False, ("EXTERNAL-TIMEOUT", None)
 
         return self.result
 
     def _run(self):
         try:
             self.result = True, self.func(self.protocol, self.url, self.timeout)
         except (client.TimeoutException, client.ScriptTimeoutException):
             self.result = False, ("EXTERNAL-TIMEOUT", None)
@@ -242,17 +246,17 @@ class WebDriverRun(object):
             self.result = False, ("CRASH", None)
         except Exception as e:
             if (isinstance(e, client.WebDriverException) and
                     e.http_status == 408 and
                     e.status_code == "asynchronous script timeout"):
                 # workaround for https://bugs.chromium.org/p/chromedriver/issues/detail?id=2001
                 self.result = False, ("EXTERNAL-TIMEOUT", None)
             else:
-                message = getattr(e, "message", "")
+                message = str(getattr(e, "message", ""))
                 if message:
                     message += "\n"
                 message += traceback.format_exc(e)
                 self.result = False, ("INTERNAL-ERROR", message)
         finally:
             self.result_flag.set()