Bug 1265582 - Add a copy of reftest analyzer for working with structured log files, r=dbaron
authorJames Graham <james@hoppipolla.co.uk>
Thu, 29 Sep 2016 14:17:28 +0100
changeset 315771 b888d1d778b8c29c52375e98f9343272c5d2469f
parent 315770 67cd8ab2f98e0521741df7eda542d0f677b99ed5
child 315772 22b1e96cfd05eab52fc71c0dd9a846f4cc45f5bf
push id20634
push usercbook@mozilla.com
push dateFri, 30 Sep 2016 10:10:13 +0000
treeherderfx-team@afe79b010d13 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1265582
milestone52.0a1
Bug 1265582 - Add a copy of reftest analyzer for working with structured log files, r=dbaron This allows reftests from web-platform-tests to be analyzed using the wpt_raw.log link on treeherder, and also supports the existing reftest harness. MozReview-Commit-ID: I6TdGKQXpf8
layout/tools/reftest/reftest-analyzer-structured.xhtml
copy from layout/tools/reftest/reftest-analyzer.xhtml
copy to layout/tools/reftest/reftest-analyzer-structured.xhtml
--- a/layout/tools/reftest/reftest-analyzer.xhtml
+++ b/layout/tools/reftest/reftest-analyzer-structured.xhtml
@@ -215,50 +215,52 @@ function log_pasted() {
 
 var gTestItems;
 
 function process_log(contents) {
   var lines = contents.split(/[\r\n]+/);
   gTestItems = [];
   for (var j in lines) {
     var line = lines[j];
-    // Ignore duplicated output in logcat.
-    if (line.match(/I\/Gecko.*?REFTEST/))
-      continue;
-    var match = line.match(/^.*?REFTEST (.*)$/);
-    if (!match)
+    try {
+      var data = JSON.parse(line);
+    } catch(e) {
       continue;
-    line = match[1];
-    match = line.match(/^(TEST-PASS|TEST-UNEXPECTED-PASS|TEST-KNOWN-FAIL|TEST-UNEXPECTED-FAIL|TEST-DEBUG-INFO)(\(EXPECTED RANDOM\)|) \| ([^\|]+) \|(.*)/);
-    if (match) {
-      var state = match[1];
-      var random = match[2];
-      var url = match[3];
-      var extra = match[4];
-      gTestItems.push(
-        {
-          pass: !state.match(/DEBUG-INFO$|FAIL$/),
-          // only one of the following three should ever be true
-          unexpected: !!state.match(/^TEST-UNEXPECTED/),
-          random: (random == "(EXPECTED RANDOM)"),
-          skip: (extra == " (SKIP)"),
-          url: url,
-          images: [],
-          imageLabels: []
-        });
+    }
+    // Ignore duplicated output in logcat.
+    if (!data.action == "test_end" && data.status != "FAIL")
+      continue;
+
+    if (!data.hasOwnProperty("extra") ||
+        !data.extra.hasOwnProperty("reftest_screenshots")) {
       continue;
     }
-    match = line.match(/IMAGE([^:]*): (data:.*)$/);
-    if (match) {
-      var item = gTestItems[gTestItems.length - 1];
-      item.images.push(match[2]);
-      item.imageLabels.push(match[1]);
+
+    var url = data.test;
+    var screenshots = data.extra.reftest_screenshots;
+    gTestItems.push(
+      {
+        pass: data.status === "PASS",
+        // only one of the following three should ever be true
+        unexpected: data.hasOwnProperty("expected"),
+        random: false,
+        skip: data.status == "SKIP",
+        url: url,
+        images: [],
+        imageLabels: []
+      });
+
+    var item = gTestItems[gTestItems.length - 1];
+    item.images.push("data:image/png;base64," + screenshots[0].screenshot);
+    item.imageLabels.push(screenshots[0].url);
+    if (screenshots.length > 1) {
+      item.images.push("data:image/png;base64," + screenshots[2].screenshot);
+      item.imageLabels.push(screenshots[2].url);
     }
   }
-
   build_viewer();
 }
 
 function build_viewer() {
   if (gTestItems.length == 0) {
     show_phase("entry");
     return;
   }
@@ -521,17 +523,17 @@ function show_pixelinfo(x, y, pix1rgb, p
 
   ]]></script>
 
 </head>
 <body onload="load()">
 
 <div id="entry">
 
-<h1>Reftest analyzer: load reftest log</h1>
+<h1>Reftest analyzer: load raw structured log</h1>
 
 <p>Either paste your log into this textarea:<br />
 <textarea cols="80" rows="10" id="logentry"/><br/>
 <input type="button" value="Process pasted log" onclick="log_pasted()" /></p>
 
 <p>... or load it from a file:<br/>
 <input type="file" id="fileentry" onchange="fileentry_changed()" />
 </p>