Bug 1413729 - Web-platform logging changes for proper structured logging in test verification; r=jgraham
authorGeoff Brown <gbrown@mozilla.com>
Wed, 01 Nov 2017 11:49:43 -0600
changeset 392560 94fa68445ec3b498d0cad46d7efdfe18183e55d7
parent 392559 5b960167158f0638ac21770e09186b323f2a5e7b
child 392561 622c44a6c3d118ab308b598a2b94846c838d2822
push id32923
push userarchaeopteryx@coole-files.de
push dateSat, 18 Nov 2017 09:59:20 +0000
treeherdermozilla-central@d4753dc14b2a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgraham
bugs1413729
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1413729 - Web-platform logging changes for proper structured logging in test verification; r=jgraham
testing/web-platform/tests/tools/wptrunner/wptrunner/stability.py
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/stability.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/stability.py
@@ -1,19 +1,19 @@
 import copy
 import functools
 import imp
+import io
 import os
-import sys
 from collections import OrderedDict, defaultdict
 from datetime import datetime
 
 from mozlog import reader
-from mozlog.formatters import JSONFormatter, TbplFormatter
-from mozlog.handlers import BaseHandler, LogLevelFilter, StreamHandler
+from mozlog.formatters import JSONFormatter
+from mozlog.handlers import BaseHandler, StreamHandler, LogLevelFilter
 
 here = os.path.dirname(__file__)
 localpaths = imp.load_source("localpaths", os.path.abspath(os.path.join(here, os.pardir, os.pardir, "localpaths.py")))
 from wpt.markdown import markdown_adjust, table
 
 
 class LogActionFilter(BaseHandler):
 
@@ -175,41 +175,36 @@ def run_step(logger, iterations, restart
     if restart_after_iteration:
         kwargs["repeat"] = iterations
     else:
         kwargs["rerun"] = iterations
 
     kwargs["pause_after_test"] = False
     kwargs.update(kwargs_extras)
 
-    handler = LogActionFilter(
-        LogLevelFilter(
-            StreamHandler(
-                sys.stdout,
-                TbplFormatter()
-            ),
-            "WARNING"),
-        ["log", "process_output"])
+    def wrap_handler(x):
+        return LogActionFilter(
+            LogLevelFilter(x, "WARNING"),
+            ["log", "process_output"])
 
-    # There is a public API for this in the next mozlog
     initial_handlers = logger._state.handlers
-    logger._state.handlers = []
+    logger._state.handlers = [wrap_handler(handler)
+                              for handler in initial_handlers]
 
-    with open("raw.log", "wb") as log:
-        # Setup logging for wptrunner that keeps process output and
-        # warning+ level logs only
-        logger.add_handler(handler)
-        logger.add_handler(StreamHandler(log, JSONFormatter()))
+    log = io.BytesIO()
+    # Setup logging for wptrunner that keeps process output and
+    # warning+ level logs only
+    logger.add_handler(StreamHandler(log, JSONFormatter()))
 
-        wptrunner.run_tests(**kwargs)
+    wptrunner.run_tests(**kwargs)
 
     logger._state.handlers = initial_handlers
 
-    with open("raw.log", "rb") as log:
-        results, inconsistent = process_results(log, iterations)
+    log.seek(0)
+    results, inconsistent = process_results(log, iterations)
     return results, inconsistent, iterations
 
 
 def get_steps(logger, repeat_loop, repeat_restart, kwargs_extras):
     steps = []
     for kwargs_extra in kwargs_extras:
         if kwargs_extra:
             flags_string = " with flags %s" % " ".join(