Bug 1174766 - Append to gecko logfile after marionette restarts the browser rather than removing the old file every time.;r=ato
authorChris Manchester <cmanchester@mozilla.com>
Sat, 20 Jun 2015 09:46:00 -0700
changeset 250105 d2d535a3fdbf0b4ed2d3e3541b30fbb91a03c367
parent 250104 a8fc665d7fab6603fa05cdbcddb32b2f8e00c63a
child 250106 585f52ceab5c45d52a715e18388cea03ece8d16a
push id61441
push usercmanchester@mozilla.com
push dateWed, 24 Jun 2015 17:16:33 +0000
treeherdermozilla-inbound@585f52ceab5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1174766
milestone41.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 1174766 - Append to gecko logfile after marionette restarts the browser rather than removing the old file every time.;r=ato
testing/marionette/driver/marionette_driver/geckoinstance.py
--- a/testing/marionette/driver/marionette_driver/geckoinstance.py
+++ b/testing/marionette/driver/marionette_driver/geckoinstance.py
@@ -45,16 +45,28 @@ class GeckoInstance(object):
             self.profile_path = profile
         self.prefs = prefs
         self.required_prefs = deepcopy(GeckoInstance.required_prefs)
         if prefs:
             self.required_prefs.update(prefs)
         self.app_args = app_args or []
         self.runner = None
         self.symbols_path = symbols_path
+
+        if gecko_log != '-':
+            if gecko_log is None:
+                gecko_log = 'gecko.log'
+            elif os.path.isdir(gecko_log):
+                fname = 'gecko-%d.log' % time.time()
+                gecko_log = os.path.join(gecko_log, fname)
+
+            gecko_log = os.path.realpath(gecko_log)
+            if os.access(gecko_log, os.F_OK):
+                os.remove(gecko_log)
+
         self.gecko_log = gecko_log
 
     def start(self):
         profile_args = {"preferences": deepcopy(self.required_prefs)}
         profile_args["preferences"]["marionette.defaultPrefs.port"] = self.marionette_port
         if self.prefs:
             profile_args["preferences"].update(self.prefs)
         if '-jsdebugger' in self.app_args:
@@ -75,46 +87,16 @@ class GeckoInstance(object):
 
         process_args = {
             'processOutputLine': [NullOutput()],
         }
 
         if self.gecko_log == '-':
             process_args['stream'] = sys.stdout
         else:
-            if self.gecko_log is None:
-                self.gecko_log = 'gecko.log'
-            elif os.path.isdir(self.gecko_log):
-                fname = "gecko-%d.log" % time.time()
-                self.gecko_log = os.path.join(self.gecko_log, fname)
-
-            self.gecko_log = os.path.realpath(self.gecko_log)
-            if os.access(self.gecko_log, os.F_OK):
-                if platform.system() is 'Windows':
-                    # NOTE: windows has a weird filesystem where it happily 'closes'
-                    # the file, but complains if you try to delete it. You get a
-                    # 'file still in use' error. Sometimes you can wait a bit and
-                    # a retry will succeed.
-                    # If all retries fail, we'll just continue without removing
-                    # the file. In this case, if we are restarting the instance,
-                    # then the new logs just get appended to the old file.
-                    tries = 0
-                    while tries < 10:
-                        try:
-                            os.remove(self.gecko_log)
-                            break
-                        except WindowsError as e:
-                            if e.errno == errno.EACCES:
-                                tries += 1
-                                time.sleep(0.5)
-                            else:
-                                raise e
-                else:
-                    os.remove(self.gecko_log)
-
             process_args['logfile'] = self.gecko_log
 
         env = os.environ.copy()
 
         # environment variables needed for crashreporting
         # https://developer.mozilla.org/docs/Environment_variables_affecting_crash_reporting
         env.update({ 'MOZ_CRASHREPORTER': '1',
                      'MOZ_CRASHREPORTER_NO_REPORT': '1', })