Only include the image checksum error in pretty-diffs for -expected.png files.
authorojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 May 2012 01:01:16 +0000 (01:01 +0000)
committerojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 May 2012 01:01:16 +0000 (01:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=87881

Reviewed by Tony Chang.

* PrettyPatch/PrettyPatch.rb:
* PrettyPatch/PrettyPatch_test.rb:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@119010 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Websites/bugs.webkit.org/ChangeLog
Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb
Websites/bugs.webkit.org/PrettyPatch/PrettyPatch_test.rb

index 979dfc5..da61897 100644 (file)
@@ -1,3 +1,13 @@
+2012-05-30  Ojan Vafai  <ojan@chromium.org>
+
+        Only include the image checksum error in pretty-diffs for -expected.png files.
+        https://bugs.webkit.org/show_bug.cgi?id=87881
+
+        Reviewed by Tony Chang.
+
+        * PrettyPatch/PrettyPatch.rb:
+        * PrettyPatch/PrettyPatch_test.rb:
+
 2012-05-29  Ojan Vafai  <ojan@chromium.org>
 
         Show an error in the pretty diff when an image lacks a checksum
index 4d38bd2..4e43690 100644 (file)
@@ -98,7 +98,7 @@ private
         Websites
     ]
 
-    IMAGE_CHECKSUM_ERROR = "<p>INVALID: Image lacks a checksum. This will fail with a MISSING error in run-webkit-tests. Always generate new png files using run-webkit-tests.</p>"
+    IMAGE_CHECKSUM_ERROR = "INVALID: Image lacks a checksum. This will fail with a MISSING error in run-webkit-tests. Always generate new png files using run-webkit-tests."
 
     def self.normalize_line_ending(s)
         s.gsub /\r\n?/, "\n"
@@ -578,11 +578,15 @@ EOF
             if not @image_url then
                 return "<span class='text'>Image file removed</span>"
             end
-            image_snippet = "<img class='image' src='" + @image_url + "' />"
-            if not @image_checksum then
-                return IMAGE_CHECKSUM_ERROR + image_snippet
+
+            image_checksum = ""
+            if @image_checksum
+                image_checksum = @image_checksum
+            elsif @filename.include? "-expected.png"
+                image_checksum = IMAGE_CHECKSUM_ERROR
             end
-            return "<p>" + @image_checksum + "</p>" + image_snippet
+
+            return "<p>" + image_checksum + "</p><img class='image' src='" + @image_url + "' />"
         end
 
         def to_html
@@ -602,10 +606,13 @@ EOF
                         str += "<p class=\"#{style}\">"
 
                         if image_checksum
-                            str += image_checksum + "<br>"
-                        else
-                            str += IMAGE_CHECKSUM_ERROR + "<br>"
+                            str += image_checksum
+                        elsif @filename.include? "-expected.png"
+                            str += IMAGE_CHECKSUM_ERROR
                         end
+
+                        str += "<br>"
+
                         if image_url
                             str += "<img class='image' src='" + image_url + "' />"
                         else
index fef8ca0..97d1fda 100755 (executable)
@@ -69,7 +69,6 @@ class PrettyPatch_test < Test::Unit::TestCase
 
     def test_images_without_checksum
         pretty = check_one_patch(144064, ["Images without checksums", 10, 5, 4, 8])
-        puts pretty
         matches = pretty.match("INVALID: Image lacks a checksum.")
         assert(matches, "Should have invalid checksums")
         # FIXME: This should only have 4 invalid images, but git apply needs an actual copy of the before binary
@@ -77,4 +76,17 @@ class PrettyPatch_test < Test::Unit::TestCase
         # thought to have no checksum, instead of the 4 images that actually don't have a checksum.
         assert_equal(10, pretty.scan(/INVALID\: Image lacks a checksum\./).size)
     end
+
+    def test_images_correctly_without_checksum_git
+        pretty = check_one_patch(101620, ["Images correctly without checksums git", 7, 15, 10, 26])
+        matches = pretty.match("INVALID: Image lacks a checksum.")
+        assert(!matches, "Png should lack a checksum without an error.")
+    end
+
+    def test_images_correctly_without_checksum_svn
+        pretty = check_one_patch(31202, ["Images correctly without checksums svn", 4, 4, 1, 4])
+        matches = pretty.match("INVALID: Image lacks a checksum.")
+        assert(!matches, "Png should lack a checksum without an error.")
+    end
+
 end