webkitpy: Build ImageDiff if it is missing
authorjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Nov 2019 02:44:52 +0000 (02:44 +0000)
committerjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Nov 2019 02:44:52 +0000 (02:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=183422

Reviewed by Alexey Proskuryakov.

ImageDiff is built with a different SDK than the rest of the WebKit
stack, and this frequently causes infrastructure failures where ImageDiff
is missing on testers. To address this, we should automatically build
ImageDiff if it is missing.

* Scripts/webkitpy/port/base.py:
(Port.check_build): Unconditionally build ImageDiff if it is missing.
(Port.check_image_diff): Use _build_path since _path_to_image_diff will
attempt to use a back-up location.
(Port._path_to_image_diff): If the provided path to ImageDiff does not
exist, use the path of the one we built.

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

Tools/ChangeLog
Tools/Scripts/webkitpy/port/base.py

index 3c8f2df..a5ac67d 100644 (file)
@@ -1,3 +1,22 @@
+2019-11-04  Jonathan Bedard  <jbedard@apple.com>
+
+        webkitpy: Build ImageDiff if it is missing
+        https://bugs.webkit.org/show_bug.cgi?id=183422
+
+        Reviewed by Alexey Proskuryakov.
+
+        ImageDiff is built with a different SDK than the rest of the WebKit
+        stack, and this frequently causes infrastructure failures where ImageDiff
+        is missing on testers. To address this, we should automatically build
+        ImageDiff if it is missing.
+
+        * Scripts/webkitpy/port/base.py:
+        (Port.check_build): Unconditionally build ImageDiff if it is missing.
+        (Port.check_image_diff): Use _build_path since _path_to_image_diff will
+        attempt to use a back-up location.
+        (Port._path_to_image_diff): If the provided path to ImageDiff does not
+        exist, use the path of the one we built.
+
 2019-11-04  Daniel Bates  <dabates@apple.com>
 
         Add Googletest assertion support for CGRect and NSRect
index 6800b17..a4290ab 100644 (file)
@@ -242,10 +242,7 @@ class Port(object):
         if self.get_option('install') and not self._check_driver():
             return False
         if not self.check_image_diff():
-            if self.get_option('build'):
-                return self._build_image_diff()
-            else:
-                return False
+            return self._build_image_diff()
         return True
 
     def check_api_test_build(self, canonicalized_binaries=None):
@@ -287,7 +284,7 @@ class Port(object):
 
     def check_image_diff(self, override_step=None, logging=True):
         """This routine is used to check whether image_diff binary exists."""
-        image_diff_path = self._path_to_image_diff()
+        image_diff_path = self._build_path('ImageDiff')
         if not self._filesystem.exists(image_diff_path):
             if logging:
                 _log.error("ImageDiff was not found at %s" % image_diff_path)
@@ -1367,11 +1364,17 @@ class Port(object):
         This is likely only used by start/stop_helper()."""
         return None
 
+    @memoized
     def _path_to_image_diff(self):
         """Returns the full path to the image_diff binary, or None if it is not available.
 
         This is likely used only by diff_image()"""
-        return self._build_path('ImageDiff')
+        default_image_diff = self._build_path('ImageDiff')
+        if self._filesystem.exists(default_image_diff):
+            return default_image_diff
+        built_image_diff = self._filesystem.join(self._config.build_directory(self.get_option('configuration')), 'ImageDiff')
+        _log.debug('ImageDiff not found at {}, using {} instead'.format(default_image_diff, built_image_diff))
+        return built_image_diff
 
     API_TEST_BINARY_NAMES = ['TestWTF', 'TestWebKitAPI']