Skip to content
This repository was archived by the owner on Mar 19, 2021. It is now read-only.

Commit 927d87e

Browse files
jgrahammoz-wptsync-bot
authored andcommitted
Fix handling multiple repeats in wptreport logs
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 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1584192 gecko-commit: 83dc6a6ed93137707ecfd785f10a721e2e1abca7 gecko-integration-branch: autoland gecko-reviewers: maja_zf
1 parent f960a2d commit 927d87e

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

tools/wptrunner/wptrunner/formatters/wptreport.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def suite_end(self, data):
7070
result = {"test": test_name}
7171
result.update(self.raw_results[test_name])
7272
self.results["results"].append(result)
73-
return json.dumps(self.results)
73+
return json.dumps(self.results) + "\n"
7474

7575
def find_or_create_test(self, data):
7676
test_name = data["test"]

tools/wptrunner/wptrunner/metadata.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,18 +353,40 @@ def __init__(self, id_test_map):
353353
self.tests_visited = {}
354354

355355
def update_from_log(self, log_file):
356+
# We support three possible formats:
357+
# * wptreport format; one json object in the file, possibly pretty-printed
358+
# * wptreport format; one run per line
359+
# * raw log format
360+
361+
# Try one wptreport file first
356362
self.run_info = None
363+
success = self.get_wptreport_data(log_file.read())
364+
365+
if success:
366+
return
367+
368+
# Now try multiple wptreport files
369+
log_file.seek(0)
370+
for line in log_file:
371+
success = self.get_wptreport_data(line)
372+
if not success:
373+
break
374+
else:
375+
return
376+
377+
log_file.seek(0)
378+
self.update_from_raw_log(log_file)
379+
380+
def get_wptreport_data(self, input_str):
357381
try:
358-
data = json.load(log_file)
382+
data = json.loads(input_str)
359383
except Exception:
360384
pass
361385
else:
362386
if "action" not in data and "results" in data:
363387
self.update_from_wptreport_log(data)
364-
return
365-
366-
log_file.seek(0)
367-
self.update_from_raw_log(log_file)
388+
return True
389+
return False
368390

369391
def update_from_raw_log(self, log_file):
370392
action_map = self.action_map

0 commit comments

Comments
 (0)