зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1055679 - Remove marionette's ad hoc log formatter now that it's no longer needed.;r=jgraham
This commit is contained in:
Родитель
968a1c0c9d
Коммит
66519af00d
|
@ -8,27 +8,6 @@ from marionette_test import MarionetteTestCase, MarionetteJSTestCase
|
|||
from mozlog import structured
|
||||
from runner import BaseMarionetteTestRunner, BaseMarionetteOptions
|
||||
|
||||
class MarionetteTbplFormatter(structured.formatters.TbplFormatter):
|
||||
"""Formatter that logs failures in a format that agrees with legacy
|
||||
log data used by tbpl."""
|
||||
|
||||
def test_end(self, data):
|
||||
# TBPL ui expects relevant info about an exception to appear in the first
|
||||
# line of the log message, however tracebacks provided by marionette
|
||||
# put this information on the last line.
|
||||
if "message" in data:
|
||||
message_lines = [line for line in data["message"].splitlines() if line != ""]
|
||||
if "Traceback" in message_lines[0]:
|
||||
exc_msg_index = None
|
||||
for index, line in enumerate(message_lines):
|
||||
if "Error: " in line or "Exception: " in line:
|
||||
exc_msg_index = index
|
||||
break
|
||||
if exc_msg_index:
|
||||
message_lines = (message_lines[exc_msg_index:] +
|
||||
message_lines[:exc_msg_index])
|
||||
data["message"] = "\n".join(message_lines)
|
||||
return super(MarionetteTbplFormatter, self).test_end(data)
|
||||
|
||||
class MarionetteTestRunner(BaseMarionetteTestRunner):
|
||||
def __init__(self, **kwargs):
|
||||
|
@ -49,15 +28,7 @@ def cli(runner_class=MarionetteTestRunner, parser_class=BaseMarionetteOptions):
|
|||
parser.verify_usage(options, tests)
|
||||
|
||||
logger = structured.commandline.setup_logging(
|
||||
options.logger_name, options, {})
|
||||
|
||||
# Only add the tbpl logger if a handler isn't already logging to stdout
|
||||
has_stdout_logger = any([h.stream == sys.stdout for h in logger.handlers])
|
||||
if not has_stdout_logger:
|
||||
formatter = MarionetteTbplFormatter()
|
||||
handler = structured.handlers.StreamHandler(sys.stdout, formatter)
|
||||
logger.add_handler(structured.handlers.LogLevelFilter(
|
||||
handler, 'info'))
|
||||
options.logger_name, options, {"tbpl": sys.stdout})
|
||||
|
||||
options.logger = logger
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче