Backed out 2 changesets (bug 1419826) for web-platform-tests-reftests failures. r=backout a=backout on a CLOSED TREE

Backed out changeset b3e4c5744eff (bug 1419826)
Backed out changeset 3a7a93bf138e (bug 1419826)
This commit is contained in:
Brindusan Cristian 2017-11-23 17:06:12 +02:00
Родитель 5c93b047f9
Коммит e2431736b7
5 изменённых файлов: 8 добавлений и 105 удалений

Просмотреть файл

@ -73,9 +73,6 @@ emitted:
where the test list is not known upfront an empty dict or list may
be passed (dict).
``name``
An optional string to identify the suite by.
``run_info``
An optional dictionary describing the properties of the
build and test environment. This contains the information provided
@ -154,17 +151,6 @@ emitted:
``message``
Text of the log message.
``logger_shutdown``
This is a special action that gets implicitly logged from the logger's
destructor, when exiting the context manager or by calling
:meth:`StructuredLogger.shutdown`.
``name``
Name of the logger being shutdown.
``component``
Component name of the logger being shutdown.
Testsuite Protocol
------------------
@ -218,13 +204,12 @@ StructuredLogger Objects
------------------------
.. automodule:: mozlog.structuredlog
:members: set_default_logger, get_default_logger, LoggerShutdownError
:members: set_default_logger, get_default_logger
.. autoclass:: StructuredLogger
:members: add_handler, remove_handler, handlers, suite_start,
suite_end, test_start, test_status, test_end,
process_output, critical, error, warning, info, debug,
shutdown
process_output, critical, error, warning, info, debug
.. autoclass:: StructuredLogFileLike
:members:
@ -362,16 +347,6 @@ Log to stdout::
logger.test_end("test-id-1", "OK")
logger.suite_end()
Log with a context manager::
from mozlog.structuredlog import StructuredLogger
from mozlog.handlers import StreamHandler
from mozlog.formatters import JSONFormatter
with StructuredLogger("my-test-suite") as logger:
logger.add_handler(StreamHandler(sys.stdout,
JSONFormatter()))
logger.info("This is an info message")
Populate an ``argparse.ArgumentParser`` with logging options, and
create a logger based on the value of those options, defaulting to

Просмотреть файл

@ -45,6 +45,9 @@ class TbplFormatter(BaseFormatter):
else:
self.buffer = None
def __call__(self, data):
return getattr(self, data["action"])(data)
def _format_subtests(self, component, subtract_context=False):
count = self.subtests_count
if subtract_context:

Просмотреть файл

@ -19,7 +19,6 @@ from .logtypes import log_action, convertor_registry
Allowed actions, and subfields:
suite_start
tests - List of test names
name - Name for the suite
suite_end
@ -110,10 +109,6 @@ def log_actions():
return set(convertor_registry.keys())
class LoggerShutdownError(Exception):
"""Raised when attempting to log after logger.shutdown() has been called."""
class LoggerState(object):
def __init__(self):
@ -154,7 +149,6 @@ class StructuredLogger(object):
self._state = self._logger_states[name]
self._component_state = self._state.component_states[component]
self._has_shutdown = False
def add_handler(self, handler):
"""Add a handler to the current logger"""
@ -232,9 +226,6 @@ class StructuredLogger(object):
self._handle_log(log_data)
def _handle_log(self, data):
if self._has_shutdown:
raise LoggerShutdownError("{} action received after shutdown.".format(data['action']))
with self._lock:
if self.component_filter:
data = self.component_filter(data)
@ -278,7 +269,6 @@ class StructuredLogger(object):
return True
@log_action(TestList("tests"),
Unicode("name", default=None, optional=True),
Dict(Any, "run_info", default=None, optional=True),
Dict(Any, "version_info", default=None, optional=True),
Dict(Any, "device_info", default=None, optional=True),
@ -287,7 +277,6 @@ class StructuredLogger(object):
"""Log a suite_start message
:param dict tests: Test identifiers that will be run in the suite, keyed by group name.
:param str name: Optional name to identify the suite.
:param dict run_info: Optional information typically provided by mozinfo.
:param dict version_info: Optional target application version information provided
by mozversion.
@ -463,28 +452,6 @@ class StructuredLogger(object):
"""
self._log_data("assertion_count", data)
def __enter__(self):
return self
def __exit__(self, exc, val, tb):
self.shutdown()
def __del__(self):
self.shutdown()
def shutdown(self):
"""Shutdown the logger.
This logs a 'logger_shutdown' action after which any further
attempts to use the logger will raise a :exc:`LoggerShutdownError`.
This function is also called implicitly from the destructor or
when exiting the context manager.
"""
if not self._has_shutdown:
self._log_data('logger_shutdown', {'name': self.name, 'component': self.component})
self._has_shutdown = True
def _log_func(level_name):
@log_action(Unicode("message"),

Просмотреть файл

@ -111,9 +111,8 @@ class TestStatusHandler(BaseStructuredTest):
class TestStructuredLog(BaseStructuredTest):
def test_suite_start(self):
self.logger.suite_start(["test"], "logtest")
self.logger.suite_start(["test"])
self.assert_log_equals({"action": "suite_start",
"name": "logtest",
"tests": {"default": ["test"]}})
self.logger.suite_end()
@ -397,47 +396,6 @@ class TestStructuredLog(BaseStructuredTest):
"level": "INFO",
"message": "line 4"})
def test_logger_shutdown(self):
with self.assertRaises(KeyError):
self.logger.log_raw({"action": "logger_shutdown", "name": "test", "component": None})
# explicit shutdown
self.logger.info("line 1")
self.assert_log_equals({"action": "log",
"level": "INFO",
"message": "line 1"})
self.logger.shutdown()
self.assert_log_equals({"action": "logger_shutdown",
"name": "test",
"component": None})
with self.assertRaises(structuredlog.LoggerShutdownError):
self.logger.info("bad log")
with self.assertRaises(structuredlog.LoggerShutdownError):
self.logger.log_raw({"action": "log", "level": "info", "message": "bad log"})
# context manager shutdown
with structuredlog.StructuredLogger("test") as log:
log.add_handler(self.handler)
log.info("line 2")
self.assert_log_equals({"action": "log",
"level": "INFO",
"message": "line 2"})
self.assert_log_equals({"action": "logger_shutdown",
"name": "test",
"component": None})
# destructor shutdown
self.logger = structuredlog.StructuredLogger("test")
self.logger.add_handler(self.handler)
self.logger.info("line 3")
self.assert_log_equals({"action": "log",
"level": "INFO",
"message": "line 3"})
del self.logger
self.assert_log_equals({"action": "logger_shutdown",
"name": "test",
"component": None})
class TestTypeConversions(BaseStructuredTest):
@ -489,7 +447,7 @@ class TestTypeConversions(BaseStructuredTest):
"message": "test",
"level": "INFO"})
self.logger.suite_start([], run_info={})
self.logger.suite_start([], {})
self.assert_log_equals({"action": "suite_start",
"tests": {"default": []},
"run_info": {}})

Просмотреть файл

@ -201,7 +201,7 @@ def run_tests(config, test_paths, product, **kwargs):
logger.info("Repetition %i / %i" % (repeat_count, repeat))
unexpected_count = 0
logger.suite_start(test_loader.test_ids, run_info=run_info)
logger.suite_start(test_loader.test_ids, run_info)
for test_type in kwargs["test_types"]:
logger.info("Running %s tests" % test_type)