rebaseline_server: display as much info as possible if expected/actual image is missing
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 1 Apr 2014 22:16:33 +0000 (22:16 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 1 Apr 2014 22:16:33 +0000 (22:16 +0000)
BUG=skia:2368
NOTRY=True
R=borenet@google.com

Author: epoger@google.com

Review URL: https://codereview.chromium.org/221423003

git-svn-id: http://skia.googlecode.com/svn/trunk@14019 2bbb7eff-a529-9590-31e7-b0007b416f81

gm/rebaseline_server/imagediffdb.py
gm/rebaseline_server/imagepair.py
gm/rebaseline_server/imagepair_test.py
gm/rebaseline_server/testdata/outputs/expected/compare_configs_test.CompareConfigsTest.test_gm/gm.json
gm/rebaseline_server/testdata/outputs/expected/compare_to_expectations_test.CompareToExpectationsTest.test_gm/gm.json

index 8328543..3b1eb3e 100644 (file)
@@ -268,8 +268,14 @@ class ImageDiffDB(object):
             actual_image_url=actual_image_url,
             actual_image_locator=actual_image_locator)
       except Exception:
-        logging.exception('got exception while creating new DiffRecord')
-        return
+        # If we can't create a real DiffRecord for this (expected, actual) pair,
+        # store None and the UI will show whatever information we DO have.
+        # Fixes http://skbug.com/2368 .
+        logging.exception(
+            'got exception while creating a DiffRecord for '
+            'expected_image_url=%s , actual_image_url=%s; returning None' % (
+                expected_image_url, actual_image_url))
+        new_diff_record = None
       self._diff_dict[key] = new_diff_record
 
   def get_diff_record(self, expected_image_locator, actual_image_locator):
index f02704e..33385ab 100644 (file)
@@ -47,8 +47,10 @@ class ImagePair(object):
     self.expectations_dict = expectations
     self.extra_columns_dict = extra_columns
     if not imageA_relative_url or not imageB_relative_url:
+      self._is_different = True
       self.diff_record = None
     elif imageA_relative_url == imageB_relative_url:
+      self._is_different = False
       self.diff_record = None
     else:
       # TODO(epoger): Rather than blocking until image_diff_db can read in
@@ -56,6 +58,7 @@ class ImagePair(object):
       # asynchronously: tell image_diff_db to download a bunch of file pairs,
       # and only block later if we're still waiting for diff_records to come
       # back.
+      self._is_different = True
       image_diff_db.add_image_pair(
           expected_image_locator=imageA_relative_url,
           expected_image_url=posixpath.join(base_url, imageA_relative_url),
@@ -64,6 +67,8 @@ class ImagePair(object):
       self.diff_record = image_diff_db.get_diff_record(
           expected_image_locator=imageA_relative_url,
           actual_image_locator=imageB_relative_url)
+      if self.diff_record and self.diff_record.get_num_pixels_differing() == 0:
+        self._is_different = False
 
   def as_dict(self):
     """Returns a dictionary describing this ImagePair.
@@ -74,13 +79,11 @@ class ImagePair(object):
         KEY__IMAGE_A_URL: self.imageA_relative_url,
         KEY__IMAGE_B_URL: self.imageB_relative_url,
     }
+    asdict[KEY__IS_DIFFERENT] = self._is_different
     if self.expectations_dict:
       asdict[KEY__EXPECTATIONS_DATA] = self.expectations_dict
     if self.extra_columns_dict:
       asdict[KEY__EXTRA_COLUMN_VALUES] = self.extra_columns_dict
     if self.diff_record and (self.diff_record.get_num_pixels_differing() > 0):
-      asdict[KEY__IS_DIFFERENT] = True
       asdict[KEY__DIFFERENCE_DATA] = self.diff_record.as_dict()
-    else:
-      asdict[KEY__IS_DIFFERENT] = False
     return asdict
index b2cae31..95b7e4d 100755 (executable)
@@ -132,6 +132,36 @@ class ImagePairTest(unittest.TestCase):
                 'isDifferent': True,
             },
         ],
+
+        # Test fix for http://skbug.com/2368 -- how do we handle an ImagePair
+        # missing one of its images?
+        [
+            # inputs:
+            'arcofzorro/16206093933823793653.png',
+            'nonexistentDir/111111.png',
+            {
+                'ignoreFailure': True,
+                'bugs': [1001, 1002],
+            },
+            {
+                'builder': 'MyBuilder',
+                'test': 'MyTest',
+            },
+            # expected output:
+            {
+                'expectations': {
+                    'bugs': [1001, 1002],
+                    'ignoreFailure': True,
+                },
+                'extraColumns': {
+                    'builder': 'MyBuilder',
+                    'test': 'MyTest',
+                },
+                'imageAUrl': 'arcofzorro/16206093933823793653.png',
+                'imageBUrl': 'nonexistentDir/111111.png',
+                'isDifferent': True,
+            },
+        ],
     ]
 
     db = imagediffdb.ImageDiffDB(self._temp_dir)
index 0dcccc9..c8fbcf9 100644 (file)
@@ -44,7 +44,7 @@
     }
   }, 
   "header": {
-    "dataHash": "-8308658702264135120", 
+    "dataHash": "7627783634950094306", 
     "isEditable": false, 
     "isExported": true, 
     "schemaVersion": 2, 
@@ -62,7 +62,7 @@
       }, 
       "imageAUrl": null, 
       "imageBUrl": "bitmap-64bitMD5/texdata/3695033638604474475.png", 
-      "isDifferent": false
+      "isDifferent": true
     }, 
     {
       "extraColumns": {
@@ -73,7 +73,7 @@
       }, 
       "imageAUrl": "bitmap-64bitMD5/filterbitmap_checkerboard_32_2/712827739969462165.png", 
       "imageBUrl": null, 
-      "isDifferent": false
+      "isDifferent": true
     }, 
     {
       "extraColumns": {
@@ -84,7 +84,7 @@
       }, 
       "imageAUrl": "bitmap-64bitMD5/filterbitmap_checkerboard_192_192/3154864687054945306.png", 
       "imageBUrl": null, 
-      "isDifferent": false
+      "isDifferent": true
     }, 
     {
       "extraColumns": {
@@ -95,7 +95,7 @@
       }, 
       "imageAUrl": "bitmap-64bitMD5/bigblurs/17309852422285247848.png", 
       "imageBUrl": null, 
-      "isDifferent": false
+      "isDifferent": true
     }, 
     {
       "extraColumns": {
       }, 
       "imageAUrl": "bitmap-64bitMD5/bitmapsource/16289727936158057543.png", 
       "imageBUrl": null, 
-      "isDifferent": false
+      "isDifferent": true
     }, 
     {
       "extraColumns": {
       }, 
       "imageAUrl": "bitmap-64bitMD5/3x3bitmaprect/2054956815327187963.png", 
       "imageBUrl": null, 
-      "isDifferent": false
+      "isDifferent": true
     }, 
     {
       "extraColumns": {
       }, 
       "imageAUrl": "bitmap-64bitMD5/aaclip/14456211900777561488.png", 
       "imageBUrl": null, 
-      "isDifferent": false
+      "isDifferent": true
     }, 
     {
       "differenceData": {
index 5c106b0..f877468 100644 (file)
@@ -49,7 +49,7 @@
     }
   }, 
   "header": {
-    "dataHash": "2099241024256114776", 
+    "dataHash": "2775016045957284034", 
     "isEditable": false, 
     "isExported": true, 
     "schemaVersion": 2, 
       }, 
       "imageAUrl": null, 
       "imageBUrl": "bitmap-64bitMD5/bigblurs/2422083043229439955.png", 
-      "isDifferent": false
+      "isDifferent": true
     }, 
     {
       "extraColumns": {
       }, 
       "imageAUrl": null, 
       "imageBUrl": "bitmap-64bitMD5/bigblurs/17309852422285247848.png", 
-      "isDifferent": false
+      "isDifferent": true
     }, 
     {
       "extraColumns": {
       }, 
       "imageAUrl": null, 
       "imageBUrl": "bitmap-64bitMD5/bitmapsource/17503582803589749280.png", 
-      "isDifferent": false
+      "isDifferent": true
     }, 
     {
       "extraColumns": {
       }, 
       "imageAUrl": null, 
       "imageBUrl": "bitmap-64bitMD5/bitmapsource/16289727936158057543.png", 
-      "isDifferent": false
+      "isDifferent": true
     }, 
     {
       "expectations": {
       }, 
       "imageAUrl": null, 
       "imageBUrl": "bitmap-64bitMD5/bigblurs/14704206703218007573.png", 
-      "isDifferent": false
+      "isDifferent": true
     }, 
     {
       "extraColumns": {
       }, 
       "imageAUrl": null, 
       "imageBUrl": "bitmap-64bitMD5/bigblurs/17309852422285247848.png", 
-      "isDifferent": false
+      "isDifferent": true
     }, 
     {
       "extraColumns": {
       }, 
       "imageAUrl": null, 
       "imageBUrl": "bitmap-64bitMD5/bigblurs/1822195599289208664.png", 
-      "isDifferent": false
+      "isDifferent": true
     }, 
     {
       "extraColumns": {
       }, 
       "imageAUrl": null, 
       "imageBUrl": "bitmap-64bitMD5/bigblurs/16171608477794909861.png", 
-      "isDifferent": false
+      "isDifferent": true
     }, 
     {
       "extraColumns": {
       }, 
       "imageAUrl": null, 
       "imageBUrl": "bitmap-64bitMD5/bigblurs/6539050160610613353.png", 
-      "isDifferent": false
+      "isDifferent": true
     }, 
     {
       "expectations": {