mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1095635 - Accept '-' to correspond to stdout for marionette's --gecko-log option.;r=ahal
This commit is contained in:
parent
d2e6dc8cd7
commit
005f71fd1e
@ -6,6 +6,7 @@ from copy import deepcopy
|
||||
import errno
|
||||
import platform
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
from mozprofile import Profile
|
||||
@ -53,35 +54,44 @@ class GeckoInstance(object):
|
||||
profile_args["path_from"] = self.profile_path
|
||||
profile = Profile.clone(**profile_args)
|
||||
|
||||
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)
|
||||
process_args = {
|
||||
'processOutputLine': [NullOutput()],
|
||||
}
|
||||
|
||||
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)
|
||||
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()
|
||||
|
||||
@ -95,9 +105,7 @@ class GeckoInstance(object):
|
||||
cmdargs=['-no-remote', '-marionette'] + self.app_args,
|
||||
env=env,
|
||||
symbols_path=self.symbols_path,
|
||||
process_args={
|
||||
'processOutputLine': [NullOutput()],
|
||||
'logfile': self.gecko_log})
|
||||
process_args=process_args)
|
||||
self.runner.start()
|
||||
|
||||
def close(self):
|
||||
|
@ -379,7 +379,8 @@ class BaseMarionetteOptions(OptionParser):
|
||||
help="Define the path to store log file. If the path is"
|
||||
" a directory, the real log file will be created"
|
||||
" given the format gecko-(timestamp).log. If it is"
|
||||
" a file, if will be used directly. Default: 'gecko.log'")
|
||||
" a file, if will be used directly. '-' may be passed"
|
||||
" to write to stdout. Default: './gecko.log'")
|
||||
self.add_option('--logger-name',
|
||||
dest='logger_name',
|
||||
action='store',
|
||||
|
@ -128,6 +128,8 @@ class MachCommands(MachCommandBase):
|
||||
help='Test type, usually one of: browser, b2g, b2g-qemu.')
|
||||
@CommandArgument('--profile',
|
||||
help='Path to gecko profile to use.')
|
||||
@CommandArgument('--gecko-log',
|
||||
help='Path to gecko log file, or "-" for stdout.')
|
||||
@CommandArgument('tests', nargs='*', metavar='TESTS',
|
||||
help='Path to test(s) to run.')
|
||||
def run_marionette_test(self, tests, **kwargs):
|
||||
|
Loading…
Reference in New Issue
Block a user