Bug 1299216 - Remove always parameter from do_process_check decorator. r=automatedtester
authorHenrik Skupin <mail@hskupin.info>
Wed, 21 Sep 2016 12:57:50 +0200
changeset 348251 d57d7ada1080b190a6415134f4d2dab55e382f86
parent 348250 32b908ad1b02660ff9bce79cbae9b8b4e5515a94
child 348252 e7aa936d8b6e3707a29665d9eb6623d21ff5deea
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
Bug 1299216 - Remove always parameter from do_process_check decorator. r=automatedtester Removing the always parameter which is kinda useless here. Originally it was added to call check_for_crash() in case of a MarionetteException happening. But such an exception is never thrown in case of crashes. It will always be an IOError. So lets get it removed and ensure we call check_for_crashes() in all the cases, and can feed the crash status into the call to handle_socket_failure(). MozReview-Commit-ID: JeK3X7voocD
--- a/testing/marionette/client/marionette_driver/decorators.py
+++ b/testing/marionette/client/marionette_driver/decorators.py
@@ -1,71 +1,51 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
-from errors import MarionetteException
 from functools import wraps
 import socket
 import sys
 import traceback
 def _find_marionette_in_args(*args, **kwargs):
         m = [a for a in args + tuple(kwargs.values()) if hasattr(a, 'session')][0]
     except IndexError:
         print("Can only apply decorator to function using a marionette object")
     return m
-def do_process_check(func, always=False):
-    """Decorator which checks the process after the function has run.
-    There is a check for crashes which always gets executed. And in the case of
-    connection issues the process will be force closed.
-    :param always: If False, only checks for crashes if an exception
-                   was raised. If True, always checks for crashes.
-    """
+def do_process_check(func):
+    """Decorator which checks the process status after the function has run."""
     def _(*args, **kwargs):
         m = _find_marionette_in_args(*args, **kwargs)
-        def check_for_crash():
+        try:
+            return func(*args, **kwargs)
+        except IOError as e:
+            exc, val, tb = sys.exc_info()
+            crashed = False
-                return m.check_for_crash()
+                crashed = m.check_for_crash()
             except Exception:
                 # don't want to lose the original exception
-                return False
-        try:
-            return func(*args, **kwargs)
-        except (MarionetteException, IOError) as e:
-            exc, val, tb = sys.exc_info()
-            crashed = False
-            # In case of no Marionette failures ensure to check for possible crashes.
-            # Do it before checking for port disconnects, to avoid reporting of unrelated
-            # crashes due to a forced shutdown of the application.
-            if not isinstance(e, MarionetteException) or type(e) is MarionetteException:
-                if not always:
-                    crashed = check_for_crash()
             # In case of socket failures force a shutdown of the application
             if type(e) in (socket.error, socket.timeout) or crashed:
             raise exc, val, tb
-        finally:
-            if always:
-                check_for_crash()
     return _
 def uses_marionette(func):
     """Decorator which creates a marionette session and deletes it
     afterwards if one doesn't already exist.