<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[180238] trunk/Tools</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/180238">180238</a></dd>
<dt>Author</dt> <dd>dbates@webkit.org</dd>
<dt>Date</dt> <dd>2015-02-17 14:13:11 -0800 (Tue, 17 Feb 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptswebkitpylayout_testsrun_webkit_testspy">trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py</a></li>
<li><a href="#trunkToolsScriptswebkitpyportdriverpy">trunk/Tools/Scripts/webkitpy/port/driver.py</a></li>
<li><a href="#trunkToolsScriptswebkitpyportiospy">trunk/Tools/Scripts/webkitpy/port/ios.py</a></li>
<li><a href="#trunkToolsScriptswebkitpyxcodesimulatorpy">trunk/Tools/Scripts/webkitpy/xcode/simulator.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (180237 => 180238)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-02-17 21:41:25 UTC (rev 180237)
+++ trunk/Tools/ChangeLog        2015-02-17 22:13:11 UTC (rev 180238)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2015-02-17  Daniel Bates  &lt;dabates@apple.com&gt;
+
+        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.
+
</ins><span class="cx"> 2015-02-17  Dana Burkart  &lt;dburkart@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         ASan does not like JSC::MachineThreads::tryCopyOtherThreadStack
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpylayout_testsrun_webkit_testspy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py (180237 => 180238)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py        2015-02-17 21:41:25 UTC (rev 180237)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py        2015-02-17 22:13:11 UTC (rev 180238)
</span><span class="lines">@@ -392,22 +392,7 @@
</span><span class="cx">     if options.platform == &quot;gtk&quot; or options.platform == &quot;efl&quot;:
</span><span class="cx">         options.webkit_test_runner = True
</span><span class="cx"> 
</span><del>-    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 &quot;{identifier}&quot; 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)
</del><span class="cx"> 
</span><del>-
</del><span class="cx"> def run(port, options, args, logging_stream):
</span><span class="cx">     logger = logging.getLogger()
</span><span class="cx">     logger.setLevel(logging.DEBUG if options.debug_rwt_logging else logging.INFO)
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpyportdriverpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/port/driver.py (180237 => 180238)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/port/driver.py        2015-02-17 21:41:25 UTC (rev 180237)
+++ trunk/Tools/Scripts/webkitpy/port/driver.py        2015-02-17 22:13:11 UTC (rev 180238)
</span><span class="lines">@@ -556,11 +556,9 @@
</span><span class="cx">         dump_tool = cmd[0]
</span><span class="cx">         dump_tool_args = cmd[1:]
</span><span class="cx">         product_dir = self._port._build_path()
</span><del>-        runtime = self._port.get_option('runtime')
-        device_type = self._port.get_option('device_type')
</del><span class="cx">         relay_args = [
</span><del>-            '-runtime', runtime.identifier,
-            '-deviceType', device_type.identifier,
</del><ins>+            '-runtime', self._port.simulator_runtime.identifier,
+            '-deviceType', self._port.simulator_device_type.identifier,
</ins><span class="cx">             '-suffix', str(self._worker_number),
</span><span class="cx">             '-productDir', product_dir,
</span><span class="cx">             '-app', dump_tool,
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpyportiospy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/port/ios.py (180237 => 180238)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/port/ios.py        2015-02-17 21:41:25 UTC (rev 180237)
+++ trunk/Tools/Scripts/webkitpy/port/ios.py        2015-02-17 22:13:11 UTC (rev 180238)
</span><span class="lines">@@ -20,23 +20,24 @@
</span><span class="cx"> # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
</span><span class="cx"> # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> 
</span><ins>+import itertools
</ins><span class="cx"> import logging
</span><span class="cx"> import os
</span><ins>+import re
</ins><span class="cx"> import shutil
</span><ins>+import subprocess
</ins><span class="cx"> import time
</span><del>-import re
-import itertools
-import subprocess
</del><span class="cx"> 
</span><del>-from webkitpy.layout_tests.models.test_configuration import TestConfiguration
</del><ins>+from webkitpy.common.memoized import memoized
</ins><span class="cx"> from webkitpy.common.system.crashlogs import CrashLogs
</span><span class="cx"> from webkitpy.common.system.executive import ScriptError
</span><ins>+from webkitpy.layout_tests.models.test_configuration import TestConfiguration
+from webkitpy.port import config as port_config
+from webkitpy.port import driver, image_diff
</ins><span class="cx"> from webkitpy.port.apple import ApplePort
</span><del>-from webkitpy.port import driver, image_diff
</del><span class="cx"> from webkitpy.port.base import Port
</span><span class="cx"> from webkitpy.port.leakdetector import LeakDetector
</span><del>-from webkitpy.port import config as port_config
-from webkitpy.xcode.simulator import Simulator
</del><ins>+from webkitpy.xcode.simulator import Simulator, Runtime, DeviceType
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> _log = logging.getLogger(__name__)
</span><span class="lines">@@ -102,6 +103,29 @@
</span><span class="cx">         return 'DumpRenderTree.app'
</span><span class="cx"> 
</span><span class="cx">     @property
</span><ins>+    @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
</ins><span class="cx">     def relay_path(self):
</span><span class="cx">         mac_config = port_config.Config(self._executive, self._filesystem, 'mac')
</span><span class="cx">         return self._filesystem.join(mac_config.build_directory(self.get_option('configuration')), self.relay_name)
</span><span class="lines">@@ -211,6 +235,12 @@
</span><span class="cx">     def operating_system(self):
</span><span class="cx">         return 'ios-simulator'
</span><span class="cx"> 
</span><ins>+    def check_sys_deps(self, needs_http):
+        if not self.simulator_runtime.available:
+            _log.error('The iOS Simulator runtime with identifier &quot;{0}&quot; cannot be used because it is unavailable.'.format(self.simulator_runtime.identifier))
+            return False
+        return super(IOSSimulatorPort, self).check_sys_deps(needs_http)
+
</ins><span class="cx">     def check_for_leaks(self, process_name, process_pid):
</span><span class="cx">         if not self.get_option('leaks'):
</span><span class="cx">             return
</span><span class="lines">@@ -286,10 +316,7 @@
</span><span class="cx">     def testing_device(self):
</span><span class="cx">         if self._testing_device is not None:
</span><span class="cx">             return self._testing_device
</span><del>-
-        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)
</del><ins>+        self._testing_device = Simulator().lookup_or_create_device(self.simulator_device_type.name + ' WebKit Tester', self.simulator_device_type, self.simulator_runtime)
</ins><span class="cx">         return self.testing_device
</span><span class="cx"> 
</span><span class="cx">     def look_for_new_crash_logs(self, crashed_processes, start_time):
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpyxcodesimulatorpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/xcode/simulator.py (180237 => 180238)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/xcode/simulator.py        2015-02-17 21:41:25 UTC (rev 180237)
+++ trunk/Tools/Scripts/webkitpy/xcode/simulator.py        2015-02-17 22:13:11 UTC (rev 180238)
</span><span class="lines">@@ -127,6 +127,10 @@
</span><span class="cx">         self.is_internal_runtime = is_internal_runtime
</span><span class="cx"> 
</span><span class="cx">     @classmethod
</span><ins>+    def from_version_string(cls, version):
+        return cls.from_identifier('com.apple.CoreSimulator.SimRuntime.iOS-' + version.replace('.', '-'))
+
+    @classmethod
</ins><span class="cx">     def from_identifier(cls, identifier):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         :param identifier: The identifier for the desired CoreSimulator runtime.
</span></span></pre>
</div>
</div>

</body>
</html>