Bug 1419826 - [mozlog] Add an optional 'name' attribute to the suite_start action, r?jgraham
MozReview-Commit-ID: KzfAgWAhCj9
--- a/testing/mozbase/docs/mozlog.rst
+++ b/testing/mozbase/docs/mozlog.rst
@@ -68,16 +68,19 @@ emitted:
a list of test ids can be used instead. In this case all tests will
automatically be placed in the 'default' group name. Test ids can
either be strings or lists of strings (an example of the latter is
reftests where the id has the form [test_url, ref_type, ref_url]).
Test ids are assumed to be unique within a given testsuite. In cases
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
by :doc:`mozinfo <mozinfo>`, plus a boolean ``debug`` field indicating
whether the build under test is a debug build.
``suite_end``
Emitted when the testsuite is finished and no more results will be produced.
--- a/testing/mozbase/mozlog/mozlog/structuredlog.py
+++ b/testing/mozbase/mozlog/mozlog/structuredlog.py
@@ -14,16 +14,17 @@ import traceback
from .logtypes import Unicode, TestId, TestList, Status, SubStatus, Dict, List, Int, Any, Tuple
from .logtypes import log_action, convertor_registry
"""Structured Logging for recording test results.
Allowed actions, and subfields:
suite_start
tests - List of test names
+ name - Name for the suite
suite_end
test_start
test - ID for the test
path - Relative path to test (optional)
test_end
@@ -264,24 +265,26 @@ class StructuredLogger(object):
if not self._state.suite_started:
self.error("Got suite_end message before suite_start. " +
"Logged with data: {}".format(json.dumps(data)))
return False
self._state.suite_started = False
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),
Dict(Any, "extra", default=None, optional=True))
def suite_start(self, data):
"""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.
:param dict device_info: Optional target device information provided by mozdevice.
"""
if not self._ensure_suite_state('suite_start', data):
return
--- a/testing/mozbase/mozlog/tests/test_structured.py
+++ b/testing/mozbase/mozlog/tests/test_structured.py
@@ -106,18 +106,19 @@ class TestStatusHandler(BaseStructuredTe
self.assertEqual(1, summary.log_level_counts['ERROR'])
self.assertIn('OK', summary.expected_statuses)
self.assertEqual(2, summary.expected_statuses['OK'])
class TestStructuredLog(BaseStructuredTest):
def test_suite_start(self):
- self.logger.suite_start(["test"])
+ self.logger.suite_start(["test"], "logtest")
self.assert_log_equals({"action": "suite_start",
+ "name": "logtest",
"tests": {"default": ["test"]}})
self.logger.suite_end()
def test_suite_end(self):
self.logger.suite_start([])
self.logger.suite_end()
self.assert_log_equals({"action": "suite_end"})
@@ -442,17 +443,17 @@ class TestTypeConversions(BaseStructured
self.logger.suite_end()
def test_arguments(self):
self.logger.info(message="test")
self.assert_log_equals({"action": "log",
"message": "test",
"level": "INFO"})
- self.logger.suite_start([], {})
+ self.logger.suite_start([], run_info={})
self.assert_log_equals({"action": "suite_start",
"tests": {"default": []},
"run_info": {}})
self.logger.test_start(test="test1")
self.logger.test_status(
"subtest1", "FAIL", test="test1", status="PASS")
self.assert_log_equals({"action": "test_status",
"test": "test1",
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/wptrunner.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/wptrunner.py
@@ -196,17 +196,17 @@ def run_tests(config, test_paths, produc
while repeat_count < repeat or repeat_until_unexpected:
repeat_count += 1
if repeat_until_unexpected:
logger.info("Repetition %i" % (repeat_count))
elif repeat > 1:
logger.info("Repetition %i / %i" % (repeat_count, repeat))
unexpected_count = 0
- logger.suite_start(test_loader.test_ids, run_info)
+ logger.suite_start(test_loader.test_ids, run_info=run_info)
for test_type in kwargs["test_types"]:
logger.info("Running %s tests" % test_type)
# WebDriver tests may create and destroy multiple browser
# processes as part of their expected behavior. These
# processes are managed by a WebDriver server binary. This
# obviates the need for wptrunner to provide a browser, so
# the NullBrowser is used in place of the "target" browser