run-webkit-tests shouldn't need Xcode to run Mac tests
authorjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 May 2020 23:38:22 +0000 (23:38 +0000)
committerjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 May 2020 23:38:22 +0000 (23:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=211903
<rdar://problem/63205839>

Reviewed by Stephanie Lewis.

* Scripts/webkitpy/common/system/platforminfo.py:
(PlatformInfo):
(PlatformInfo.xcode_sdk_version): Memoize SDK version retrieval.
(PlatformInfo.xcode_version): Only run xcodebuild if macosx SDK is present.
(PlatformInfo.available_sdks): Ditto.
* Scripts/webkitpy/common/system/platforminfo_unittest.py:
(TestPlatformInfo.test_available_sdks):

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

Tools/ChangeLog
Tools/Scripts/webkitpy/common/system/platforminfo.py
Tools/Scripts/webkitpy/common/system/platforminfo_unittest.py

index 374aff1..74ffb60 100644 (file)
@@ -1,3 +1,19 @@
+2020-05-14  Jonathan Bedard  <jbedard@apple.com>
+
+        run-webkit-tests shouldn't need Xcode to run Mac tests
+        https://bugs.webkit.org/show_bug.cgi?id=211903
+        <rdar://problem/63205839>
+
+        Reviewed by Stephanie Lewis.
+
+        * Scripts/webkitpy/common/system/platforminfo.py:
+        (PlatformInfo):
+        (PlatformInfo.xcode_sdk_version): Memoize SDK version retrieval.
+        (PlatformInfo.xcode_version): Only run xcodebuild if macosx SDK is present.
+        (PlatformInfo.available_sdks): Ditto.
+        * Scripts/webkitpy/common/system/platforminfo_unittest.py:
+        (TestPlatformInfo.test_available_sdks):
+
 2020-05-14  Daniel Bates  <dabates@apple.com>
 
         Include LocalOverrides.xcconfig in all Tools projects
index 426f31a..ce5f761 100644 (file)
@@ -31,6 +31,7 @@ import logging
 import re
 import sys
 
+from webkitpy.common.memoized import memoized
 from webkitpy.common.version import Version
 from webkitpy.common.version_name_map import PUBLIC_TABLE, INTERNAL_TABLE, VersionNameMap
 from webkitpy.common.system.executive import Executive
@@ -159,6 +160,7 @@ class PlatformInfo(object):
             return self._executive.run_command(['/usr/bin/sw_vers', '-buildVersion'], return_stderr=False, ignore_errors=True).rstrip()
         return None
 
+    @memoized
     def xcode_sdk_version(self, sdk_name):
         if self.is_mac():
             # Assumes that xcrun does not write to standard output on failure (e.g. SDK does not exist).
@@ -173,13 +175,15 @@ class PlatformInfo(object):
         output = self._executive.run_command(['xcrun', 'simctl', 'list'], return_stderr=False)
         return (line for line in output.splitlines())
 
+    @memoized
     def xcode_version(self):
-        if not self.is_mac():
+        if not self.xcode_sdk_version('macosx'):
             raise NotImplementedError
         return Version.from_string(self._executive.run_command(['xcodebuild', '-version']).split()[1])
 
+    @memoized
     def available_sdks(self):
-        if not self.is_mac():
+        if not self.xcode_sdk_version('macosx'):
             return []
 
         XCODE_SDK_REGEX = re.compile('\-sdk (?P<sdk>\D+)\d+\.\d+(?P<specifier>\D*)')
index e4a3167..1ecc48a 100644 (file)
@@ -160,6 +160,10 @@ class TestPlatformInfo(unittest.TestCase):
         self.assertIsNone(info.total_bytes_memory())
 
     def test_available_sdks(self):
+        sdk_version_output = '10.16\n'
+        info = self.make_info(fake_sys('darwin'), fake_platform('10.14.0'), fake_executive(sdk_version_output))
+        info.xcode_sdk_version('macosx')
+
         show_sdks_output = """iOS SDKs:
     iOS 12.0                          -sdk iphoneos12.0
 
@@ -177,7 +181,7 @@ watchOS Simulator SDKs:
     Simulator - watchOS 5.0           -sdk watchsimulator5.0
     Simulator - watchOS 5.0 Internal    -sdk watchsimulator5.0.type
 """
-        info = self.make_info(fake_sys('darwin'), fake_platform('10.14.0'), fake_executive(show_sdks_output))
+        info._executive = fake_executive(show_sdks_output)
         self.assertEqual(info.available_sdks(), [
             'iphoneos',
             'iphonesimulator', 'iphonesimulator.type',