Bug 1584192 - Fix handling multiple repeats in wptreport logs, r=maja_zf
authorJames Graham <james@hoppipolla.co.uk>
Fri, 27 Sep 2019 20:34:20 +0000
changeset 497623 83dc6a6ed93137707ecfd785f10a721e2e1abca7
parent 497622 448164fceb1b2fc1cb7e7f614c675318143431a6
child 497624 9042c3ee2c0bc43d3b65c4fe262cf77e67ab1897
push id114154
push userbtara@mozilla.com
push dateThu, 17 Oct 2019 09:58:40 +0000
treeherdermozilla-inbound@273c3db836e1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf
bugs1584192
milestone71.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 1584192 - Fix handling multiple repeats in wptreport logs, r=maja_zf Previously this would have ended up with multiple JSON objects all put on the same line and we'd be unable to update from such metadata. Ensure that there's one line per JSON object and the update code is able to consume this format. Differential Revision: https://phabricator.services.mozilla.com/D47248
testing/web-platform/tests/tools/wptrunner/wptrunner/formatters/wptreport.py
testing/web-platform/tests/tools/wptrunner/wptrunner/metadata.py
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/formatters/wptreport.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/formatters/wptreport.py
@@ -65,17 +65,17 @@ class WptreportFormatter(BaseFormatter):
 
     def suite_end(self, data):
         self.results['time_end'] = data['time']
         self.results["results"] = []
         for test_name in self.raw_results:
             result = {"test": test_name}
             result.update(self.raw_results[test_name])
             self.results["results"].append(result)
-        return json.dumps(self.results)
+        return json.dumps(self.results) + "\n"
 
     def find_or_create_test(self, data):
         test_name = data["test"]
         if test_name not in self.raw_results:
             self.raw_results[test_name] = {
                 "subtests": [],
                 "status": "",
                 "message": None
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/metadata.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/metadata.py
@@ -348,28 +348,50 @@ class ExpectedUpdater(object):
                            "test_end": self.test_end,
                            "assertion_count": self.assertion_count,
                            "lsan_leak": self.lsan_leak,
                            "mozleak_object": self.mozleak_object,
                            "mozleak_total": self.mozleak_total}
         self.tests_visited = {}
 
     def update_from_log(self, log_file):
+        # We support three possible formats:
+        # * wptreport format; one json object in the file, possibly pretty-printed
+        # * wptreport format; one run per line
+        # * raw log format
+
+        # Try one wptreport file first
         self.run_info = None
+        success = self.get_wptreport_data(log_file.read())
+
+        if success:
+            return
+
+        # Now try multiple wptreport files
+        log_file.seek(0)
+        for line in log_file:
+            success = self.get_wptreport_data(line)
+            if not success:
+                break
+        else:
+            return
+
+        log_file.seek(0)
+        self.update_from_raw_log(log_file)
+
+    def get_wptreport_data(self, input_str):
         try:
-            data = json.load(log_file)
+            data = json.loads(input_str)
         except Exception:
             pass
         else:
             if "action" not in data and "results" in data:
                 self.update_from_wptreport_log(data)
-                return
-
-        log_file.seek(0)
-        self.update_from_raw_log(log_file)
+                return True
+        return False
 
     def update_from_raw_log(self, log_file):
         action_map = self.action_map
         for line in log_file:
             try:
                 data = json.loads(line)
             except ValueError:
                 # Just skip lines that aren't json