From e55738f58610f628b8c4be57175336ed85314e11 Mon Sep 17 00:00:00 2001 From: Andrew Halberstadt Date: Tue, 10 Feb 2015 17:11:35 -0500 Subject: [PATCH] Bug 1129495 - [mozlog] Add optional 'path' attribute to test_start, r=jgraham --- testing/mozbase/docs/mozlog_structured.rst | 4 ++++ testing/mozbase/mozlog/mozlog/structured/structuredlog.py | 6 +++++- testing/mozbase/mozlog/tests/test_structured.py | 5 +++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/testing/mozbase/docs/mozlog_structured.rst b/testing/mozbase/docs/mozlog_structured.rst index 2bb7570e1a5..231afc579ee 100644 --- a/testing/mozbase/docs/mozlog_structured.rst +++ b/testing/mozbase/docs/mozlog_structured.rst @@ -84,6 +84,10 @@ emitted: ``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. diff --git a/testing/mozbase/mozlog/mozlog/structured/structuredlog.py b/testing/mozbase/mozlog/mozlog/structured/structuredlog.py index 4fadc9bce16..695ca357f11 100644 --- a/testing/mozbase/mozlog/mozlog/structured/structuredlog.py +++ b/testing/mozbase/mozlog/mozlog/structured/structuredlog.py @@ -24,6 +24,7 @@ Allowed actions, and subfields: test_start test - ID for the test + path - Relative path to test (optional) test_end test - ID for the test @@ -248,11 +249,14 @@ class StructuredLogger(object): 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" % diff --git a/testing/mozbase/mozlog/tests/test_structured.py b/testing/mozbase/mozlog/tests/test_structured.py index 809949e681f..c857731c413 100644 --- a/testing/mozbase/mozlog/tests/test_structured.py +++ b/testing/mozbase/mozlog/tests/test_structured.py @@ -117,9 +117,10 @@ class TestStructuredLog(BaseStructuredTest): 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):