Bug 1129495 - [mozlog] Add optional 'path' attribute to test_start, r=jgraham
--- a/testing/mozbase/docs/mozlog_structured.rst
+++ b/testing/mozbase/docs/mozlog_structured.rst
@@ -79,16 +79,20 @@ emitted:
Emitted when the testsuite is finished and no more results will be produced.
``test_start``
Emitted when a test is being started.
``test``
A unique id for the test (string or list of strings).
+ ``path``
+ Optional path to the test relative to some base (typically the root of the
+ source tree. Mainly used when ``test`` id is not a path (string).
+
``test_status``
Emitted for a test which has subtests to record the result of a
single subtest.
``test``
The same unique id for the test as in the ``test_start`` message.
``subtest``
--- a/testing/mozbase/mozlog/mozlog/structured/structuredlog.py
+++ b/testing/mozbase/mozlog/mozlog/structured/structuredlog.py
@@ -19,16 +19,17 @@ from logtypes import log_action, convert
Allowed actions, and subfields:
suite_start
tests - List of test names
suite_end
test_start
test - ID for the test
+ path - Relative path to test (optional)
test_end
test - ID for the test
status [PASS | FAIL | OK | ERROR |
TIMEOUT | CRASH | ASSERT | SKIP] - test status
expected [As for status] - Status that the test was expected to get,
or absent if the test got the expected status
extra - Dictionary of harness-specific extra information e.g. debug info
@@ -243,21 +244,24 @@ class StructuredLogger(object):
if not self._state.suite_started:
self.error("Got suite_end message before suite_start.")
return
self._state.suite_started = False
self._log_data("suite_end")
- @log_action(TestId("test"))
+ @log_action(TestId("test"),
+ Unicode("path", default=None, optional=True))
def test_start(self, data):
"""Log a test_start message
:param test: Identifier of the test that will run.
+ :param path: Path to test relative to some base (typically the root of
+ the source tree).
"""
if not self._state.suite_started:
self.error("Got test_start message before suite_start for test %s" %
data["test"])
return
if data["test"] in self._state.running_tests:
self.error("test_start for %s logged while in progress." %
data["test"])
--- a/testing/mozbase/mozlog/tests/test_structured.py
+++ b/testing/mozbase/mozlog/tests/test_structured.py
@@ -112,19 +112,20 @@ class TestStructuredLog(BaseStructuredTe
self.assert_log_equals({"action": "suite_end"})
def test_start(self):
self.logger.suite_start([])
self.logger.test_start("test1")
self.assert_log_equals({"action": "test_start",
"test":"test1"})
- self.logger.test_start(("test1", "==", "test1-ref"))
+ self.logger.test_start(("test1", "==", "test1-ref"), path="path/to/test")
self.assert_log_equals({"action": "test_start",
- "test":("test1", "==", "test1-ref")})
+ "test":("test1", "==", "test1-ref"),
+ "path": "path/to/test"})
self.logger.suite_end()
def test_start_inprogress(self):
self.logger.suite_start([])
self.logger.test_start("test1")
self.logger.test_start("test1")
self.assert_log_equals({"action": "log",
"message": "test_start for test1 logged while in progress.",