Bug 1265582 - Fix reftest structured logs to match wpt, r=ahal
authorJames Graham <james@hoppipolla.co.uk>
Tue, 27 Sep 2016 22:54:50 +0100
changeset 315772 22b1e96cfd05eab52fc71c0dd9a846f4cc45f5bf
parent 315771 b888d1d778b8c29c52375e98f9343272c5d2469f
child 315773 d05947f7d956b8367fb8715bfa968fe42e8ee68a
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)
reviewersahal
bugs1265582
milestone52.0a1
Bug 1265582 - Fix reftest structured logs to match wpt, r=ahal This allows the logs to work with the structured reftest viewer. MozReview-Commit-ID: CY71vSdDjLP
layout/tools/reftest/output.py
layout/tools/reftest/reftest.jsm
testing/mozbase/mozlog/mozlog/formatters/tbplformatter.py
--- a/layout/tools/reftest/output.py
+++ b/layout/tools/reftest/output.py
@@ -50,21 +50,21 @@ class ReftestFormatter(TbplFormatter):
                 status_msg += "(EXPECTED RANDOM)"
 
 
         output_text = "%s | %s | %s" % (status_msg, test, data.get("message", ""))
 
         if "reftest_screenshots" in extra:
             screenshots = extra["reftest_screenshots"]
             if len(screenshots) == 3:
-                output_text += ("\nREFTEST   IMAGE 1 (TEST): %s\n"
-                                "REFTEST   IMAGE 2 (REFERENCE): %s") % (screenshots[0]["screenshot"],
+                output_text += ("\nREFTEST   IMAGE 1 (TEST): data:image/png;base64,%s\n"
+                                "REFTEST   IMAGE 2 (REFERENCE): data:image/png;base64,%s") % (screenshots[0]["screenshot"],
                                                                          screenshots[2]["screenshot"])
             elif len(screenshots) == 1:
-                output_text += "\nREFTEST   IMAGE: %(image1)s" % screenshots[0]["screenshot"]
+                output_text += "\nREFTEST   IMAGE: data:image/png;base64,%(image1)s" % screenshots[0]["screenshot"]
 
 
         output_text += "\nREFTEST TEST-END | %s" % test
         return "%s\n" % output_text
 
     def process_output(self, data):
         return "%s\n" % data["data"]
 
--- a/layout/tools/reftest/reftest.jsm
+++ b/layout/tools/reftest/reftest.jsm
@@ -1705,23 +1705,27 @@ function RecordResult(testRunTime, error
             } else {
                 var message = "image comparison";
                 if (!test_passed && expected == EXPECTED_PASS ||
                     !test_passed && expected == EXPECTED_FUZZY ||
                     test_passed && expected == EXPECTED_FAIL) {
                     if (!equal) {
                         extra.max_difference = maxDifference.value;
                         extra.differences = differences;
+                        var image1 = gCanvas1.toDataURL();
+                        var image2 = gCanvas2.toDataURL();
                         extra.reftest_screenshots = [
-                            {url:gURLs[0].identifier[0], screenshot: gCanvas1.toDataURL()},
+                            {url:gURLs[0].identifier[0],
+                             screenshot: image1.slice(image1.indexOf(",") + 1)},
                             gURLs[0].identifier[1],
-                            {url:gURLs[0].identifier[1], screenshot: gCanvas2.toDataURL()}
+                            {url:gURLs[0].identifier[2],
+                             screenshot: image2.slice(image2.indexOf(",") + 1)}
                         ];
-                        extra.image1 = gCanvas1.toDataURL();
-                        extra.image2 = gCanvas2.toDataURL();
+                        extra.image1 = image1;
+                        extra.image2 = image2;
                         message += (", max difference: " + extra.max_difference +
                                     ", number of differing pixels: " + differences);
                     } else {
                         extra.image1 = gCanvas1.toDataURL();
                     }
                 }
                 logger.testEnd(gURLs[0].identifier, output.s[0], output.s[1], message, null, extra);
 
--- a/testing/mozbase/mozlog/mozlog/formatters/tbplformatter.py
+++ b/testing/mozbase/mozlog/mozlog/formatters/tbplformatter.py
@@ -186,21 +186,21 @@ class TbplFormatter(BaseFormatter):
                 message += "\n%s" % data["stack"]
             if message and message[-1] == "\n":
                 message = message[:-1]
 
             extra = data.get("extra", {})
             if "reftest_screenshots" in extra:
                 screenshots = extra["reftest_screenshots"]
                 if len(screenshots) == 3:
-                     message += ("\nREFTEST   IMAGE 1 (TEST): %s\n"
-                                 "REFTEST   IMAGE 2 (REFERENCE): %s") % (screenshots[0]["screenshot"],
+                     message += ("\nREFTEST   IMAGE 1 (TEST): data:image/png;base64,%s\n"
+                                 "REFTEST   IMAGE 2 (REFERENCE): data:image/png;base64,%s") % (screenshots[0]["screenshot"],
                                                                          screenshots[2]["screenshot"])
                 elif len(screenshots) == 1:
-                    message += "\nREFTEST   IMAGE: %(image1)s" % screenshots[0]["screenshot"]
+                    message += "\nREFTEST   IMAGE: data:image/png;base64,%(image1)s" % screenshots[0]["screenshot"]
 
             failure_line = "TEST-UNEXPECTED-%s | %s | %s\n" % (
             data["status"], test_id, message)
 
             if data["expected"] not in ("PASS", "OK"):
                 expected_msg = "expected %s | " % data["expected"]
             else:
                 expected_msg = ""