Title: [172117] trunk/Tools
Revision
172117
Author
dfar...@apple.com
Date
2014-08-05 18:38:06 -0700 (Tue, 05 Aug 2014)

Log Message

[iOS] run-webkit-tests: defaults for --runtime and --device-type flags
https://bugs.webkit.org/show_bug.cgi?id=135441

Reviewed by Tim Horton.

* Scripts/webkitpy/layout_tests/run_webkit_tests.py:
(parse_args):
(_set_up_derived_options):
If using the ios-simulator platform and runtime or device-type
aren't defined, get the latest runtime from the active Xcode.app
and pick a default device type based on the desired architecture:
iPhone 5 for i386 and iPhone 5s for x86_64.
* Scripts/webkitpy/xcode/__init__.py: Added.
* Scripts/webkitpy/xcode/simulator.py: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (172116 => 172117)


--- trunk/Tools/ChangeLog	2014-08-06 01:30:27 UTC (rev 172116)
+++ trunk/Tools/ChangeLog	2014-08-06 01:38:06 UTC (rev 172117)
@@ -1,5 +1,22 @@
 2014-08-05  David Farler  <dfar...@apple.com>
 
+        [iOS] run-webkit-tests: defaults for --runtime and --device-type flags
+        https://bugs.webkit.org/show_bug.cgi?id=135441
+
+        Reviewed by Tim Horton.
+
+        * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
+        (parse_args):
+        (_set_up_derived_options):
+        If using the ios-simulator platform and runtime or device-type
+        aren't defined, get the latest runtime from the active Xcode.app
+        and pick a default device type based on the desired architecture:
+        iPhone 5 for i386 and iPhone 5s for x86_64.
+        * Scripts/webkitpy/xcode/__init__.py: Added.
+        * Scripts/webkitpy/xcode/simulator.py: Added.
+
+2014-08-05  David Farler  <dfar...@apple.com>
+
         [iOS] simctl can hang if run quickly after shutting down CoreSimulator services
         https://bugs.webkit.org/show_bug.cgi?id=135626
 

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py (172116 => 172117)


--- trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py	2014-08-06 01:30:27 UTC (rev 172116)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py	2014-08-06 01:38:06 UTC (rev 172117)
@@ -285,8 +285,8 @@
     ]))
 
     option_group_definitions.append(("iOS Simulator Options", [
-        optparse.make_option('--runtime', help='iOS Simulator runtime identifier'),
-        optparse.make_option('--device-type', help='iOS Simulator device type identifier'),
+        optparse.make_option('--runtime', help='iOS Simulator runtime identifier (default: latest runtime)'),
+        optparse.make_option('--device-type', help='iOS Simulator device type identifier (default: i386 -> iPhone 5, x86_64 -> iPhone 5s)'),
     ]))
 
     option_group_definitions.append(("Miscellaneous Options", [
@@ -391,7 +391,15 @@
     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.get_latest_runtime()['identifier']
+        if options.device_type is None:
+            device_types = xcode.simulator.get_device_types()
+            options.device_type = device_types['iPhone 5'] if options.architecture == 'x86' else device_types['iPhone 5s']
 
+
 def run(port, options, args, logging_stream):
     logger = logging.getLogger()
     logger.setLevel(logging.DEBUG if options.debug_rwt_logging else logging.INFO)

Added: trunk/Tools/Scripts/webkitpy/xcode/__init__.py (0 => 172117)


--- trunk/Tools/Scripts/webkitpy/xcode/__init__.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/xcode/__init__.py	2014-08-06 01:38:06 UTC (rev 172117)
@@ -0,0 +1 @@
+import simulator

Added: trunk/Tools/Scripts/webkitpy/xcode/simulator.py (0 => 172117)


--- trunk/Tools/Scripts/webkitpy/xcode/simulator.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/xcode/simulator.py	2014-08-06 01:38:06 UTC (rev 172117)
@@ -0,0 +1,105 @@
+import subprocess
+import re
+
+"""
+Minimally wraps CoreSimulator functionality through simctl.
+
+If possible, use real CoreSimulator.framework functionality by linking to the framework itself.
+Do not use PyObjC to dlopen the framework.
+"""
+
+
+def get_runtimes(_only_available_=True):
+    """
+    Give a dictionary mapping
+    :return: A dictionary mapping iOS version string to runtime identifier.
+    :rtype: dict
+    """
+    runtimes = {}
+    runtime_re = re.compile(b'iOS (?P<version>[0-9]+\.[0-9]) \([0-9]+\.[0-9]+ - (?P<update>[^)]+)\) \((?P<identifier>[^)]+)\)( \((?P<unavailable>[^)]+)\))?')
+    stdout = subprocess.check_output(['xcrun', '-sdk', 'iphonesimulator', 'simctl', 'list', 'runtimes'])
+    lines = iter(stdout.splitlines())
+    header = next(lines)
+    if header != '== Runtimes ==':
+        return None
+
+    for line in lines:
+        runtime_match = runtime_re.match(line)
+        if not runtime_match:
+            continue
+        runtime = runtime_match.groupdict()
+        version = tuple([int(component) for component in runtime_match.group('version').split('.')])
+        runtime = {
+            'identifier': runtime['identifier'],
+            'available': runtime['unavailable'] is None,
+            'version': version,
+        }
+        if only_available and not runtime['available']:
+            continue
+
+        runtimes[version] = runtime
+
+    return runtimes
+
+
+def get_devices():
+    """
+    :return: A dictionary mapping iOS version to device hardware model, simulator UDID, and state.
+    :rtype: dict
+    """
+    devices = {}
+    version_re = re.compile('-- iOS (?P<version>[0-9]+\.[0-9]+) --')
+    devices_re = re.compile('\s*(?P<name>[^(]+ )\((?P<udid>[^)]+)\) \((?P<state>[^)]+)\)')
+    stdout = subprocess.check_output(['xcrun', '-sdk', 'iphonesimulator', 'simctl', 'list', 'devices'])
+    lines = iter(stdout.splitlines())
+    header = next(lines)
+    version = None
+    if header != '== Devices ==':
+        return None
+
+    for line in lines:
+        version_match = version_re.match(line)
+        if version_match:
+            version = tuple([int(component) for component in version_match.group('version').split('.')])
+            continue
+        device_match = devices_re.match(line)
+        if not device_match:
+            raise RuntimeError()
+        device = device_match.groupdict()
+        device['name'] = device['name'].rstrip()
+
+        devices[version][device['udid']] = device
+
+    return devices
+
+
+def get_device_types():
+    """
+    :return: A dictionary mapping of device name -> identifier
+    :rtype: dict
+    """
+    device_types = {}
+    device_type_re = re.compile('(?P<name>[^(]+)\((?P<identifier>[^)]+)\)')
+    stdout = subprocess.check_output(['xcrun', '-sdk', 'iphonesimulator', 'simctl', 'list', 'devicetypes'])
+    lines = iter(stdout.splitlines())
+    header = next(lines)
+    if header != '== Device Types ==':
+        return None
+
+    for line in lines:
+        device_type_match = device_type_re.match(line)
+        if not device_type_match:
+            continue
+        device_type = device_type_match.groupdict()
+        device_type['name'] = device_type['name'].rstrip()
+        device_types[device_type['name']] = device_type['identifier']
+
+    return device_types
+
+
+def get_latest_runtime():
+    runtimes = get_runtimes()
+    if not runtimes:
+        return None
+    latest_version = sorted(runtimes.keys())[0]
+    return runtimes[latest_version]
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to