Bug 1221187: testing/marionette/client: Add -v flag for trace logging output; r?automatedtester
Adds -v and --verbose flags to the `./mach marionette-test` command to
increase the verbosity of the Marionette logging output.
A single -v corresponds to Log.Level.Debug and above. A double -vv
or more corresponds to Log.Level.Trace and above.
--- a/testing/marionette/client/marionette/runner/base.py
+++ b/testing/marionette/client/marionette/runner/base.py
@@ -257,16 +257,20 @@ class BaseMarionetteArguments(ArgumentPa
os.makedirs(path)
return path
self.argument_containers = []
self.add_argument('tests',
nargs='*',
default=[],
help='Tests to run.')
+ self.add_argument('-v', '--verbose',
+ action='count',
+ help='Increase verbosity to include debug messages with -v, '
+ 'and trace messages with -vv.')
self.add_argument('--emulator',
choices=['x86', 'arm'],
help='if no --address is given, then the harness will launch a B2G emulator on which to run '
'emulator tests. if --address is given, then the harness assumes you are running an '
'emulator already, and will run the emulator tests using that emulator. you need to '
'specify which architecture to emulate for both cases')
self.add_argument('--emulator-binary',
help='launch a specific emulator binary rather than launching from the B2G built emulator')
@@ -516,17 +520,18 @@ class BaseMarionetteTestRunner(object):
logger=None, no_window=False, logdir=None, logcat_stdout=False,
xml_output=None, repeat=0, testvars=None, tree=None, type=None,
device_serial=None, symbols_path=None, timeout=None,
shuffle=False, shuffle_seed=random.randint(0, sys.maxint),
sdcard=None, this_chunk=1, total_chunks=1, sources=None,
server_root=None, gecko_log=None, result_callbacks=None,
adb_host=None, adb_port=None, prefs=None, test_tags=None,
socket_timeout=BaseMarionetteArguments.socket_timeout_default,
- startup_timeout=None, addons=None, workspace=None, **kwargs):
+ startup_timeout=None, addons=None, workspace=None,
+ verbose=0, **kwargs):
self.address = address
self.emulator = emulator
self.emulator_binary = emulator_binary
self.emulator_img = emulator_img
self.emulator_res = emulator_res
self.homedir = homedir
self.app = app
self.app_args = app_args or []
@@ -566,16 +571,17 @@ class BaseMarionetteTestRunner(object):
self._adb_port = adb_port
self.prefs = prefs or {}
self.test_tags = test_tags
self.startup_timeout = startup_timeout
self.workspace = workspace
# If no workspace is set, default location for logcat and gecko.log is .
# and default location for profile is TMP
self.workspace_path = workspace or os.getcwd()
+ self.verbose = verbose
def gather_debug(test, status):
rv = {}
marionette = test._marionette_weakref()
# In the event we're gathering debug without starting a session, skip marionette commands
if marionette.session is not None:
try:
@@ -696,16 +702,17 @@ class BaseMarionetteTestRunner(object):
'device_serial': self.device_serial,
'symbols_path': self.symbols_path,
'timeout': self.timeout,
'socket_timeout': self.socket_timeout,
'adb_host': self._adb_host,
'adb_port': self._adb_port,
'prefs': self.prefs,
'startup_timeout': self.startup_timeout,
+ 'verbose': self.verbose,
}
if self.bin:
kwargs.update({
'host': 'localhost',
'port': 2828,
'app': self.app,
'app_args': self.app_args,
'bin': self.bin,
--- a/testing/marionette/driver/marionette_driver/geckoinstance.py
+++ b/testing/marionette/driver/marionette_driver/geckoinstance.py
@@ -1,52 +1,54 @@
# 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 copy import deepcopy
import os
import sys
import tempfile
import time
+from copy import deepcopy
+
from mozprofile import Profile
from mozrunner import Runner
class GeckoInstance(object):
-
required_prefs = {
- "marionette.defaultPrefs.enabled": True,
- "marionette.logging": True,
- "browser.displayedE10SPrompt": 5,
"browser.displayedE10SPrompt.1": 5,
"browser.displayedE10SPrompt.2": 5,
"browser.displayedE10SPrompt.3": 5,
"browser.displayedE10SPrompt.4": 5,
+ "browser.displayedE10SPrompt": 5,
"browser.sessionstore.resume_from_crash": False,
"browser.shell.checkDefaultBrowser": False,
"browser.startup.page": 0,
- "browser.tabs.remote.autostart": False,
"browser.tabs.remote.autostart.1": False,
"browser.tabs.remote.autostart.2": False,
+ "browser.tabs.remote.autostart": False,
"browser.urlbar.userMadeSearchSuggestionsChoice": True,
"browser.warnOnQuit": False,
- "dom.ipc.reportProcessHangs": False,
+ "datareporting.healthreport.logging.consoleEnabled": False,
+ "datareporting.healthreport.service.enabled": False,
+ "datareporting.healthreport.service.firstRun": False,
"datareporting.healthreport.uploadEnabled": False,
"datareporting.policy.dataSubmissionEnabled": False,
"datareporting.policy.dataSubmissionPolicyAccepted": False,
+ "dom.ipc.reportProcessHangs": False,
"focusmanager.testmode": True,
+ "marionette.defaultPrefs.enabled": True,
"startup.homepage_welcome_url": "about:blank",
"toolkit.telemetry.enabled": False,
}
def __init__(self, host, port, bin, profile=None, addons=None,
app_args=None, symbols_path=None, gecko_log=None, prefs=None,
- workspace=None):
+ workspace=None, verbose=0):
self.marionette_host = host
self.marionette_port = port
self.bin = bin
# Alternative to default temporary directory
self.workspace = workspace
# Check if it is a Profile object or a path to profile
self.profile = None
self.addons = addons
@@ -69,22 +71,26 @@ class GeckoInstance(object):
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
+ self.verbose = verbose
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 self.verbose:
+ level = "TRACE" if self.verbose >= 2 else "DEBUG"
+ profile_args["preferences"]["marionette.logging"] = level
if '-jsdebugger' in self.app_args:
profile_args["preferences"].update({
"devtools.browsertoolbox.panel": "jsdebugger",
"devtools.debugger.remote-enabled": True,
"devtools.chrome.enabled": True,
"devtools.debugger.prompt-connection": False,
"marionette.debugging.clicktostart": True,
})
@@ -200,28 +206,26 @@ class DesktopInstance(GeckoInstance):
'extensions.getAddons.cache.enabled': False,
'extensions.installDistroAddons': False,
'extensions.logging.enabled': True,
'extensions.showMismatchUI': False,
'extensions.update.enabled': False,
'extensions.update.notifyUser': False,
'geo.provider.testing': True,
'javascript.options.showInConsole': True,
- # See Bug 1221187 - marionette logging is too verbose, especially for
- # long-running tests.
- 'marionette.logging': False,
'security.notification_enable_delay': 0,
'signon.rememberSignons': False,
'toolkit.startup.max_resumed_crashes': -1,
}
def __init__(self, *args, **kwargs):
super(DesktopInstance, self).__init__(*args, **kwargs)
self.required_prefs.update(DesktopInstance.desktop_prefs)
+
class NullOutput(object):
def __call__(self, line):
pass
apps = {
'b2g': B2GDesktopInstance,
'b2gdesktop': B2GDesktopInstance,
--- a/testing/marionette/driver/marionette_driver/marionette.py
+++ b/testing/marionette/driver/marionette_driver/marionette.py
@@ -537,17 +537,17 @@ class Marionette(object):
def __init__(self, host='localhost', port=2828, app=None, app_args=None, bin=None,
profile=None, addons=None, emulator=None, sdcard=None, emulator_img=None,
emulator_binary=None, emulator_res=None, connect_to_running_emulator=False,
gecko_log=None, homedir=None, baseurl=None, no_window=False, logdir=None,
busybox=None, symbols_path=None, timeout=None, socket_timeout=360,
device_serial=None, adb_path=None, process_args=None,
adb_host=None, adb_port=None, prefs=None, startup_timeout=None,
- workspace=None):
+ workspace=None, verbose=0):
self.host = host
self.port = self.local_port = port
self.bin = bin
self.profile = profile
self.addons = addons
self.instance = None
self.session = None
self.session_id = None
@@ -591,17 +591,18 @@ class Marionette(object):
KeyError):
instance_class = geckoinstance.GeckoInstance
self.instance = instance_class(host=self.host, port=self.port,
bin=self.bin, profile=self.profile,
app_args=app_args,
symbols_path=symbols_path,
gecko_log=gecko_log, prefs=prefs,
addons=self.addons,
- workspace=workspace)
+ workspace=workspace,
+ verbose=verbose)
self.instance.start()
self.raise_for_port(self.wait_for_port(timeout=startup_timeout))
if emulator:
self.runner = B2GEmulatorRunner(b2g_home=homedir,
no_window=self.no_window,
logdir=logdir,
arch=emulator,