run_webkit_tests.py should not know about iOS Simulator details
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Feb 2015 22:13:11 +0000 (22:13 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Feb 2015 22:13:11 +0000 (22:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=141711

Reviewed by Alex Christensen.

Run_webkit_tests.py should only parse the iOS-specific command
line options --runtime and --device-type. Let the port-specific
logic in ios.py validate the parsed options and instantiate
internal data structures.

Currently run_webkit_tests.py parses the iOS-specific command
line options --runtime and --device-type, validates them, and
instantiates internal data structures from the parsed strings.
Instead the validation logic and instantiation of internal
data structures should be handled by the iOS port object.

* Scripts/webkitpy/layout_tests/run_webkit_tests.py:
(_set_up_derived_options): Remove logic to validate --runtime and --device-type
and instantiate internal data structures for them.
* Scripts/webkitpy/port/driver.py:
(IOSSimulatorDriver.cmd_line): Modified to reference IOSSimulatorPort.simulator_runtime
and IOSSimulatorPort.simulator_device_type for the iOS Simulator runtime and device type,
respectively.
* Scripts/webkitpy/port/ios.py: Sort the list of imports.
(IOSSimulatorPort.simulator_runtime): Added. Instantiates a Runtime
object from --runtime, if specified. Otherwise, instantiates a Runtime
object for the latest installed iphonesimulator SDK version.
(IOSSimulatorPort.simulator_device_type): Added. Instantiates a DeviceType
object from --device-type, if specified. Otherwise, instantiates
a DeviceType object for a iPhone 5 or iPhone 5s when on a 32-bit and 64-bit
machine, respectively.
(IOSSimulatorPort.check_sys_deps): Added. Validate if the chosen iOS simulator
runtime is available to use.
(IOSSimulatorPort.testing_device): Modified to make use of properties simulator_device_type
and simulator_runtime for the iOS Simulator device type and runtime, respectively.
* Scripts/webkitpy/xcode/simulator.py:
(Runtime.from_version_string): Added. Turns around and calls Runtime.from_identifier()
with a runtime identifier for the specified iOS version.

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

Tools/ChangeLog
Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py
Tools/Scripts/webkitpy/port/driver.py
Tools/Scripts/webkitpy/port/ios.py
Tools/Scripts/webkitpy/xcode/simulator.py

index ed48a07..6703da1 100644 (file)
@@ -1,3 +1,44 @@
+2015-02-17  Daniel Bates  <dabates@apple.com>
+
+        run_webkit_tests.py should not know about iOS Simulator details
+        https://bugs.webkit.org/show_bug.cgi?id=141711
+
+        Reviewed by Alex Christensen.
+
+        Run_webkit_tests.py should only parse the iOS-specific command
+        line options --runtime and --device-type. Let the port-specific
+        logic in ios.py validate the parsed options and instantiate
+        internal data structures.
+
+        Currently run_webkit_tests.py parses the iOS-specific command
+        line options --runtime and --device-type, validates them, and
+        instantiates internal data structures from the parsed strings.
+        Instead the validation logic and instantiation of internal
+        data structures should be handled by the iOS port object.
+
+        * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
+        (_set_up_derived_options): Remove logic to validate --runtime and --device-type
+        and instantiate internal data structures for them.
+        * Scripts/webkitpy/port/driver.py:
+        (IOSSimulatorDriver.cmd_line): Modified to reference IOSSimulatorPort.simulator_runtime
+        and IOSSimulatorPort.simulator_device_type for the iOS Simulator runtime and device type,
+        respectively.
+        * Scripts/webkitpy/port/ios.py: Sort the list of imports.
+        (IOSSimulatorPort.simulator_runtime): Added. Instantiates a Runtime
+        object from --runtime, if specified. Otherwise, instantiates a Runtime
+        object for the latest installed iphonesimulator SDK version.
+        (IOSSimulatorPort.simulator_device_type): Added. Instantiates a DeviceType
+        object from --device-type, if specified. Otherwise, instantiates
+        a DeviceType object for a iPhone 5 or iPhone 5s when on a 32-bit and 64-bit
+        machine, respectively.
+        (IOSSimulatorPort.check_sys_deps): Added. Validate if the chosen iOS simulator
+        runtime is available to use.
+        (IOSSimulatorPort.testing_device): Modified to make use of properties simulator_device_type
+        and simulator_runtime for the iOS Simulator device type and runtime, respectively.
+        * Scripts/webkitpy/xcode/simulator.py:
+        (Runtime.from_version_string): Added. Turns around and calls Runtime.from_identifier()
+        with a runtime identifier for the specified iOS version.
+
 2015-02-17  Dana Burkart  <dburkart@apple.com>
 
         ASan does not like JSC::MachineThreads::tryCopyOtherThreadStack
index 5f6bbc8..0981f0b 100755 (executable)
@@ -392,21 +392,6 @@ def _set_up_derived_options(port, options):
     if options.platform == "gtk" or options.platform == "efl":
         options.webkit_test_runner = True
 
-    if options.platform == 'ios-simulator':
-        from webkitpy import xcode
-        if options.runtime is None:
-            options.runtime = xcode.simulator.Simulator().latest_available_runtime
-        else:
-            options.runtime = xcode.simulator.Runtime.from_identifier(options.runtime)
-            if not options.runtime.available:
-                raise Exception('The iOS Simulator runtime with identifier "{identifier}" cannot be used because it is unavailable.'.format(identifier=options.runtime.identifier))
-        if options.device_type is None:
-            iphone5 = xcode.simulator.DeviceType.from_name('iPhone 5')
-            iphone5s = xcode.simulator.DeviceType.from_name('iPhone 5s')
-            options.device_type = iphone5 if options.architecture == 'x86' else iphone5s
-        else:
-            options.device_type = xcode.simulator.DeviceType.from_identifier(options.device_type)
-
 
 def run(port, options, args, logging_stream):
     logger = logging.getLogger()
index 282ea5e..ee86a87 100755 (executable)
@@ -556,11 +556,9 @@ class IOSSimulatorDriver(Driver):
         dump_tool = cmd[0]
         dump_tool_args = cmd[1:]
         product_dir = self._port._build_path()
-        runtime = self._port.get_option('runtime')
-        device_type = self._port.get_option('device_type')
         relay_args = [
-            '-runtime', runtime.identifier,
-            '-deviceType', device_type.identifier,
+            '-runtime', self._port.simulator_runtime.identifier,
+            '-deviceType', self._port.simulator_device_type.identifier,
             '-suffix', str(self._worker_number),
             '-productDir', product_dir,
             '-app', dump_tool,
index 25928eb..bc277c3 100644 (file)
 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+import itertools
 import logging
 import os
-import shutil
-import time
 import re
-import itertools
+import shutil
 import subprocess
+import time
 
-from webkitpy.layout_tests.models.test_configuration import TestConfiguration
+from webkitpy.common.memoized import memoized
 from webkitpy.common.system.crashlogs import CrashLogs
 from webkitpy.common.system.executive import ScriptError
-from webkitpy.port.apple import ApplePort
+from webkitpy.layout_tests.models.test_configuration import TestConfiguration
+from webkitpy.port import config as port_config
 from webkitpy.port import driver, image_diff
+from webkitpy.port.apple import ApplePort
 from webkitpy.port.base import Port
 from webkitpy.port.leakdetector import LeakDetector
-from webkitpy.port import config as port_config
-from webkitpy.xcode.simulator import Simulator
+from webkitpy.xcode.simulator import Simulator, Runtime, DeviceType
 
 
 _log = logging.getLogger(__name__)
@@ -102,6 +103,29 @@ class IOSSimulatorPort(Port):
         return 'DumpRenderTree.app'
 
     @property
+    @memoized
+    def simulator_runtime(self):
+        runtime_identifier = self.get_option('runtime')
+        if runtime_identifier:
+            runtime = Runtime.from_identifier(runtime_identifier)
+        else:
+            runtime = Runtime.from_version_string(self.host.platform.xcode_sdk_version('iphonesimulator'))
+        return runtime
+
+    @property
+    @memoized
+    def simulator_device_type(self):
+        device_type_identifier = self.get_option('device_type')
+        if device_type_identifier:
+            device_type = DeviceType.from_identifier(device_type_identifier)
+        else:
+            if self.architecture() == 'x86_64':
+                device_type = DeviceType.from_name('iPhone 5s')
+            else:
+                device_type = DeviceType.from_name('iPhone 5')
+        return device_type
+
+    @property
     def relay_path(self):
         mac_config = port_config.Config(self._executive, self._filesystem, 'mac')
         return self._filesystem.join(mac_config.build_directory(self.get_option('configuration')), self.relay_name)
@@ -211,6 +235,12 @@ class IOSSimulatorPort(Port):
     def operating_system(self):
         return 'ios-simulator'
 
+    def check_sys_deps(self, needs_http):
+        if not self.simulator_runtime.available:
+            _log.error('The iOS Simulator runtime with identifier "{0}" cannot be used because it is unavailable.'.format(self.simulator_runtime.identifier))
+            return False
+        return super(IOSSimulatorPort, self).check_sys_deps(needs_http)
+
     def check_for_leaks(self, process_name, process_pid):
         if not self.get_option('leaks'):
             return
@@ -286,10 +316,7 @@ class IOSSimulatorPort(Port):
     def testing_device(self):
         if self._testing_device is not None:
             return self._testing_device
-
-        device_type = self.get_option('device_type')
-        runtime = self.get_option('runtime')
-        self._testing_device = Simulator().lookup_or_create_device(device_type.name + ' WebKit Tester', device_type, runtime)
+        self._testing_device = Simulator().lookup_or_create_device(self.simulator_device_type.name + ' WebKit Tester', self.simulator_device_type, self.simulator_runtime)
         return self.testing_device
 
     def look_for_new_crash_logs(self, crashed_processes, start_time):
index d4c9a07..797d4ba 100644 (file)
@@ -127,6 +127,10 @@ class Runtime(object):
         self.is_internal_runtime = is_internal_runtime
 
     @classmethod
+    def from_version_string(cls, version):
+        return cls.from_identifier('com.apple.CoreSimulator.SimRuntime.iOS-' + version.replace('.', '-'))
+
+    @classmethod
     def from_identifier(cls, identifier):
         """
         :param identifier: The identifier for the desired CoreSimulator runtime.