Diff
Modified: trunk/Tools/ChangeLog (238748 => 238749)
--- trunk/Tools/ChangeLog 2018-11-30 19:59:33 UTC (rev 238748)
+++ trunk/Tools/ChangeLog 2018-11-30 20:13:16 UTC (rev 238749)
@@ -1,3 +1,53 @@
+2018-11-30 Jonathan Bedard <[email protected]>
+
+ webkitpy: Use DeviceType instead of str to represent device class
+ https://bugs.webkit.org/show_bug.cgi?id=192160
+ <rdar://problem/46344845>
+
+ Rubber-stamped by Aakash Jain.
+
+ * Scripts/webkitpy/layout_tests/controllers/manager.py:
+ (Manager._custom_device_for_test): Use DeviceTypes instead of strings to represent device type.
+ (Manager._set_up_run): Do not set _options.device_class, use device_type instead of device_class.
+ (Manager.run): Use device_type instead of device_class.
+ (Manager._print_expectations_for_subset): Ditto.
+ (Manager.print_expectations): Ditto.
+ * Scripts/webkitpy/layout_tests/controllers/manager_unittest.py:
+ (ManagerTest.test_uses_custom_device): Use DeviceType and actual device definition.
+ * Scripts/webkitpy/layout_tests/views/printing.py:
+ (Printer.print_workers_and_shards): Outputting the device suffix doesn't really help, and means
+ device type needs to be passed around.
+ * Scripts/webkitpy/port/apple.py:
+ (ApplePort.setup_test_run): Use device_type instead of device_class.
+ * Scripts/webkitpy/port/base.py:
+ (Port):
+ (Port.setup_test_run): Use device_type instead of device_class.
+ * Scripts/webkitpy/port/device_port.py:
+ (DevicePort):
+ (DevicePort.setup_test_run): Receive device_type as DeviceType object.
+ (DevicePort._create_devices): Deleted.
+ * Scripts/webkitpy/port/gtk.py:
+ (GtkPort.setup_test_run): Use device_type instead of device_class.
+ * Scripts/webkitpy/port/ios.py:
+ (IOSPort):
+ * Scripts/webkitpy/port/ios_simulator.py:
+ (IOSSimulatorPort):
+ (IOSSimulatorPort.__init__): Deleted.
+ (IOSSimulatorPort._set_device_class): Deleted.
+ * Scripts/webkitpy/port/test.py:
+ * Scripts/webkitpy/port/watch.py:
+ (WatchPort):
+ * Scripts/webkitpy/port/watch_simulator.py:
+ (WatchSimulatorPort):
+ (WatchSimulatorPort.__init__): Deleted.
+ (WatchSimulatorPort._set_device_class): Deleted.
+ * Scripts/webkitpy/port/win.py:
+ (WinPort.setup_test_run): Use device_type instead of device_class.
+ * Scripts/webkitpy/xcode/simulated_device.py:
+ (SimulatedDeviceManager._disambiguate_device_type): Using the existing devices for this is
+ a problem if no such device exists yet. Use the _device_identifier_to_name dictionary instead
+ since this should have hardware types in the device names.
+
2018-11-30 David Quesada <[email protected]>
-[WKProcessPool _downloadURLRequest:] should allow specifying the initiating web view
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py (238748 => 238749)
--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py 2018-11-30 19:59:33 UTC (rev 238748)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py 2018-11-30 20:13:16 UTC (rev 238749)
@@ -55,6 +55,7 @@
from webkitpy.layout_tests.models.test_input import TestInput
from webkitpy.layout_tests.models.test_run_results import INTERRUPTED_EXIT_STATUS
from webkitpy.tool.grammar import pluralize
+from webkitpy.xcode.device_type import DeviceType
_log = logging.getLogger(__name__)
@@ -103,10 +104,14 @@
return self.web_platform_test_subdir in test or self.webkit_specific_web_platform_test_subdir in test
def _custom_device_for_test(self, test):
- for device_class in self._port.CUSTOM_DEVICE_CLASSES:
- directory_suffix = device_class.lower().replace(' ', '') + self._port.TEST_PATH_SEPARATOR
- if directory_suffix in test:
- return device_class
+ # FIXME: Use available devices instead of CUSTOM_DEVICE_TYPES https://bugs.webkit.org/show_bug.cgi?id=192161
+ # FIXME: This is a terrible way to do device-specific expected results https://bugs.webkit.org/show_bug.cgi?id=192162
+ for device_type in self._port.CUSTOM_DEVICE_TYPES:
+ if device_type.hardware_family and device_type.hardware_family.lower() + self._port.TEST_PATH_SEPARATOR in test:
+ return device_type
+ if device_type.hardware_family and device_type.hardware_type and \
+ (device_type.hardware_family + device_type.hardware_type).lower().replace(' ', '') + self._port.TEST_PATH_SEPARATOR in test:
+ return device_type
return None
def _http_tests(self, test_names):
@@ -159,9 +164,7 @@
worker_count = self._runner.get_worker_count(test_inputs, int(self._options.child_processes))
self._options.child_processes = worker_count
- def _set_up_run(self, test_names, device_class=None):
- self._options.device_class = device_class
-
+ def _set_up_run(self, test_names, device_type=None):
# This must be started before we check the system dependencies,
# since the helper may do things to make the setup correct.
self._printer.write_update("Starting helper ...")
@@ -178,7 +181,7 @@
self._port.stop_helper()
return False
- self._port.setup_test_run(self._options.device_class)
+ self._port.setup_test_run(device_type)
return True
def run(self, args):
@@ -215,8 +218,8 @@
default_device_tests.append(test_file)
if custom_device_tests:
- for device_class in custom_device_tests:
- _log.debug('{} tests use device {}'.format(len(custom_device_tests[device_class]), device_class))
+ for device_type, tests in custom_device_tests.iteritems():
+ _log.debug('{} tests use device {}'.format(len(tests), device_type))
initial_results = None
retry_results = None
@@ -250,13 +253,13 @@
# Only use a single worker for custom device classes
self._options.child_processes = 1
- for device_class in custom_device_tests:
- device_tests = custom_device_tests[device_class]
+ for device_type in custom_device_tests:
+ device_tests = custom_device_tests[device_type]
if device_tests:
_log.info('')
- _log.info('Running %s for %s', pluralize(len(device_tests), "test"), device_class)
+ _log.info('Running %s for %s', pluralize(len(device_tests), "test"), device_type)
_log.info('')
- if not self._set_up_run(device_tests, device_class):
+ if not self._set_up_run(device_tests, device_type):
return test_run_results.RunDetails(exit_code=-1)
device_initial_results, device_retry_results, device_enabled_pixel_tests_in_retry = self._run_test_subset(device_tests, tests_to_skip)
@@ -544,7 +547,7 @@
line = self._expectations.model().get_expectation_line(test)
print(format_string.format(test, line.expected_behavior, self._expectations.readable_filename_and_line_number(line), line.original_string or ''))
- def _print_expectations_for_subset(self, device_class, test_col_width, tests_to_run, tests_to_skip={}):
+ def _print_expectations_for_subset(self, device_type, test_col_width, tests_to_run, tests_to_skip={}):
format_string = '{{:{width}}} {{}} {{}} {{}}'.format(width=test_col_width)
if tests_to_skip:
print('')
@@ -553,7 +556,7 @@
self._print_expectation_line_for_test(format_string, test)
print('')
- print('Tests to run{} ({})'.format(' for ' + device_class if device_class else '', len(tests_to_run)))
+ print('Tests to run{} ({})'.format(' for ' + str(device_type) if device_type else '', len(tests_to_run)))
for test in sorted(tests_to_run):
self._print_expectation_line_for_test(format_string, test)
@@ -586,13 +589,12 @@
default_device_tests.append(test_file)
if custom_device_tests:
- for device_class in custom_device_tests:
- _log.debug('{} tests use device {}'.format(len(custom_device_tests[device_class]), device_class))
+ for device_type, tests in custom_device_tests.iteritems():
+ _log.debug('{} tests use device {}'.format(len(tests), device_type))
self._print_expectations_for_subset(None, test_col_width, tests_to_run, tests_to_skip)
- for device_class in custom_device_tests:
- device_tests = custom_device_tests[device_class]
- self._print_expectations_for_subset(device_class, test_col_width, device_tests)
+ for device_type, tests in custom_device_tests.iteritems():
+ self._print_expectations_for_subset(device_type, test_col_width, tests)
return 0
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py (238748 => 238749)
--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py 2018-11-30 19:59:33 UTC (rev 238748)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py 2018-11-30 20:13:16 UTC (rev 238749)
@@ -40,6 +40,7 @@
from webkitpy.port.test import TestPort
from webkitpy.thirdparty.mock import Mock
from webkitpy.tool.mocktool import MockOptions
+from webkitpy.xcode.device_type import DeviceType
class ManagerTest(unittest.TestCase):
@@ -107,7 +108,7 @@
def test_uses_custom_device(self):
class MockCustomDevicePort(TestPort):
- CUSTOM_DEVICE_CLASSES = ['starship']
+ CUSTOM_DEVICE_TYPES = [DeviceType(hardware_family='iPad')]
def __init__(self, host):
super(MockCustomDevicePort, self).__init__(host)
@@ -115,8 +116,8 @@
def get_manager():
host = MockHost()
port = MockCustomDevicePort(host)
- manager = Manager(port, options=MockOptions(test_list=['fast/test-starship/lasers.html'], http=True), printer=Mock())
+ manager = Manager(port, options=MockOptions(test_list=['fast/ipad/lasers.html'], http=True), printer=Mock())
return manager
manager = get_manager()
- self.assertTrue(manager._custom_device_for_test('fast/test-starship/lasers.html') == 'starship')
+ self.assertTrue(manager._custom_device_for_test('fast/ipad/lasers.html') == DeviceType(hardware_family='iPad'))
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/views/printing.py (238748 => 238749)
--- trunk/Tools/Scripts/webkitpy/layout_tests/views/printing.py 2018-11-30 19:59:33 UTC (rev 238748)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/views/printing.py 2018-11-30 20:13:16 UTC (rev 238749)
@@ -113,12 +113,11 @@
def print_workers_and_shards(self, num_workers, num_shards):
driver_name = self._port.driver_name()
- device_suffix = ' for device "{}"'.format(self._options.device_class) if self._options.device_class else ''
if num_workers == 1:
- self._print_default('Running 1 {}{}.'.format(driver_name, device_suffix))
+ self._print_default('Running 1 {}.'.format(driver_name))
self._print_debug('({}).'.format(grammar.pluralize(num_shards, "shard")))
else:
- self._print_default('Running {} in parallel{}.'.format(grammar.pluralize(num_workers, driver_name), device_suffix))
+ self._print_default('Running {} in parallel.'.format(grammar.pluralize(num_workers, driver_name)))
self._print_debug('({} shards).'.format(num_shards))
self._print_default('')
Modified: trunk/Tools/Scripts/webkitpy/port/apple.py (238748 => 238749)
--- trunk/Tools/Scripts/webkitpy/port/apple.py 2018-11-30 19:59:33 UTC (rev 238748)
+++ trunk/Tools/Scripts/webkitpy/port/apple.py 2018-11-30 20:13:16 UTC (rev 238749)
@@ -84,7 +84,7 @@
port_name = port_name.replace('-wk2', '')
self._version = self._strip_port_name_prefix(port_name)
- def setup_test_run(self, device_class=None):
+ def setup_test_run(self, device_type=None):
self._crash_logs_to_skip_for_host[self.host] = self.host.filesystem.files_under(self.path_to_crash_logs())
def default_timeout_ms(self):
Modified: trunk/Tools/Scripts/webkitpy/port/base.py (238748 => 238749)
--- trunk/Tools/Scripts/webkitpy/port/base.py 2018-11-30 19:59:33 UTC (rev 238748)
+++ trunk/Tools/Scripts/webkitpy/port/base.py 2018-11-30 20:13:16 UTC (rev 238749)
@@ -81,7 +81,7 @@
DEFAULT_ARCHITECTURE = 'x86'
- CUSTOM_DEVICE_CLASSES = []
+ CUSTOM_DEVICE_TYPES = []
@classmethod
def determine_full_port_name(cls, host, options, port_name):
@@ -879,7 +879,7 @@
def wpt_manifest_file(self):
return self._build_path('web-platform-tests-manifest.json')
- def setup_test_run(self, device_class=None):
+ def setup_test_run(self, device_type=None):
"""Perform port-specific work at the beginning of a test run."""
pass
Modified: trunk/Tools/Scripts/webkitpy/port/device_port.py (238748 => 238749)
--- trunk/Tools/Scripts/webkitpy/port/device_port.py 2018-11-30 19:59:33 UTC (rev 238748)
+++ trunk/Tools/Scripts/webkitpy/port/device_port.py 2018-11-30 20:13:16 UTC (rev 238749)
@@ -37,7 +37,7 @@
class DevicePort(DarwinPort):
DEVICE_MANAGER = None
- DEFAULT_DEVICE_CLASS = None
+ DEFAULT_DEVICE_TYPE = None
NO_DEVICE_MANAGER = 'No device manager found for port'
def __init__(self, *args, **kwargs):
@@ -87,9 +87,6 @@
return []
return self.DEVICE_MANAGER.INITIALIZED_DEVICES
- def _create_devices(self, device_class):
- raise NotImplementedError
-
# Despite their names, these flags do not actually get passed all the way down to webkit-build.
def _build_driver_flags(self):
return ['--sdk', self.SDK] + (['ARCHS=%s' % self.architecture()] if self.architecture() else [])
@@ -109,11 +106,17 @@
if not device.install_dylibs(self._build_path()):
raise RuntimeError('Failed to install dylibs at {} on device {}'.format(self._build_path(), device.udid))
- def setup_test_run(self, device_class=None):
+ def setup_test_run(self, device_type=None):
if not self.DEVICE_MANAGER:
raise RuntimeError(self.NO_DEVICE_MANAGER)
- device_type = DeviceType.from_string(device_class if device_class else self.DEFAULT_DEVICE_CLASS, self.device_version())
+ device_type = device_type if device_type else self.DEFAULT_DEVICE_TYPE
+ device_type = DeviceType(
+ hardware_family=device_type.hardware_family,
+ hardware_type=device_type.hardware_type,
+ software_version=self.device_version(),
+ software_variant=device_type.software_variant,
+ )
_log.debug('\nCreating devices for {}'.format(device_type))
request = DeviceRequest(
Modified: trunk/Tools/Scripts/webkitpy/port/gtk.py (238748 => 238749)
--- trunk/Tools/Scripts/webkitpy/port/gtk.py 2018-11-30 19:59:33 UTC (rev 238748)
+++ trunk/Tools/Scripts/webkitpy/port/gtk.py 2018-11-30 20:13:16 UTC (rev 238749)
@@ -103,8 +103,8 @@
return self.default_timeout_ms()
return super(GtkPort, self).driver_stop_timeout()
- def setup_test_run(self, device_class=None):
- super(GtkPort, self).setup_test_run(device_class)
+ def setup_test_run(self, device_type=None):
+ super(GtkPort, self).setup_test_run(device_type)
self._pulseaudio_sanitizer.unload_pulseaudio_module()
if self.get_option("leaks"):
Modified: trunk/Tools/Scripts/webkitpy/port/ios.py (238748 => 238749)
--- trunk/Tools/Scripts/webkitpy/port/ios.py 2018-11-30 19:59:33 UTC (rev 238748)
+++ trunk/Tools/Scripts/webkitpy/port/ios.py 2018-11-30 20:13:16 UTC (rev 238749)
@@ -30,6 +30,7 @@
from webkitpy.port.config import apple_additions
from webkitpy.port.device_port import DevicePort
from webkitpy.port.simulator_process import SimulatorProcess
+from webkitpy.xcode.device_type import DeviceType
_log = logging.getLogger(__name__)
@@ -39,7 +40,7 @@
CURRENT_VERSION = Version(12)
# FIXME: This is not a clear way to do this (although it works) https://bugs.webkit.org/show_bug.cgi?id=192160
- DEFAULT_DEVICE_CLASS = ''
+ DEFAULT_DEVICE_TYPE = DeviceType(software_variant='iOS')
def __init__(self, host, port_name, **kwargs):
super(IOSPort, self).__init__(host, port_name, **kwargs)
Modified: trunk/Tools/Scripts/webkitpy/port/ios_simulator.py (238748 => 238749)
--- trunk/Tools/Scripts/webkitpy/port/ios_simulator.py 2018-11-30 19:59:33 UTC (rev 238748)
+++ trunk/Tools/Scripts/webkitpy/port/ios_simulator.py 2018-11-30 20:13:16 UTC (rev 238749)
@@ -42,17 +42,10 @@
DEVICE_MANAGER = SimulatedDeviceManager
- DEFAULT_DEVICE_CLASS = 'iPhone SE'
- CUSTOM_DEVICE_CLASSES = ['iPad', 'iPhone 7']
+ DEFAULT_DEVICE_TYPE = DeviceType(hardware_family='iPhone', hardware_type='SE')
+ CUSTOM_DEVICE_TYPES = [DeviceType(hardware_family='iPad'), DeviceType(hardware_family='iPhone', hardware_type='7')]
SDK = apple_additions().get_sdk('iphonesimulator') if apple_additions() else 'iphonesimulator'
- def __init__(self, host, port_name, **kwargs):
- super(IOSSimulatorPort, self).__init__(host, port_name, **kwargs)
-
- optional_device_class = self.get_option('device_class')
- self._device_class = optional_device_class if optional_device_class else self.DEFAULT_DEVICE_CLASS
- _log.debug('IOSSimulatorPort _device_class is %s', self._device_class)
-
@staticmethod
def _version_from_name(name):
if len(name.split('-')) > 2 and name.split('-')[2].isdigit():
@@ -78,9 +71,6 @@
return num_booted_sims
return SimulatedDeviceManager.max_supported_simulators(self.host)
- def _set_device_class(self, device_class):
- self._device_class = device_class if device_class else self.DEFAULT_DEVICE_CLASS
-
def clean_up_test_run(self):
super(IOSSimulatorPort, self).clean_up_test_run()
_log.debug("clean_up_test_run")
Modified: trunk/Tools/Scripts/webkitpy/port/test.py (238748 => 238749)
--- trunk/Tools/Scripts/webkitpy/port/test.py 2018-11-30 19:59:33 UTC (rev 238748)
+++ trunk/Tools/Scripts/webkitpy/port/test.py 2018-11-30 20:13:16 UTC (rev 238749)
@@ -467,7 +467,7 @@
def default_results_directory(self):
return '/tmp/layout-test-results'
- def setup_test_run(self, device_class=None):
+ def setup_test_run(self, device_type=None):
pass
def _driver_class(self):
Modified: trunk/Tools/Scripts/webkitpy/port/watch.py (238748 => 238749)
--- trunk/Tools/Scripts/webkitpy/port/watch.py 2018-11-30 19:59:33 UTC (rev 238748)
+++ trunk/Tools/Scripts/webkitpy/port/watch.py 2018-11-30 20:13:16 UTC (rev 238749)
@@ -27,6 +27,7 @@
from webkitpy.common.version_name_map import VersionNameMap, INTERNAL_TABLE
from webkitpy.port.config import apple_additions
from webkitpy.port.device_port import DevicePort
+from webkitpy.xcode.device_type import DeviceType
_log = logging.getLogger(__name__)
@@ -36,7 +37,7 @@
port_name = 'watchos'
CURRENT_VERSION = Version(5)
- DEFAULT_DEVICE_CLASS = 'Apple Watch'
+ DEFAULT_DEVICE_TYPE = DeviceType(software_variant='watchOS')
def __init__(self, *args, **kwargs):
super(WatchPort, self).__init__(*args, **kwargs)
Modified: trunk/Tools/Scripts/webkitpy/port/watch_simulator.py (238748 => 238749)
--- trunk/Tools/Scripts/webkitpy/port/watch_simulator.py 2018-11-30 19:59:33 UTC (rev 238748)
+++ trunk/Tools/Scripts/webkitpy/port/watch_simulator.py 2018-11-30 20:13:16 UTC (rev 238749)
@@ -40,16 +40,9 @@
DEVICE_MANAGER = SimulatedDeviceManager
- DEFAULT_DEVICE_CLASS = 'Apple Watch Series 3 - 42mm'
- CUSTOM_DEVICE_CLASSES = []
+ DEFAULT_DEVICE_TYPE = DeviceType(hardware_family='Apple Watch', hardware_type='Series 3 - 42mm')
SDK = apple_additions().get_sdk('watchsimulator') if apple_additions() else 'watchsimulator'
- def __init__(self, *args, **kwargs):
- super(WatchSimulatorPort, self).__init__(*args, **kwargs)
-
- self._set_device_class(self.get_option('device_class'))
- _log.debug('WatchSimulatorPort _device_class is %s', self._device_class)
-
def architecture(self):
return self.DEFAULT_ARCHITECTURE
@@ -91,9 +84,6 @@
return num_booted_sims
return SimulatedDeviceManager.max_supported_simulators(self.host)
- def _set_device_class(self, device_class):
- self._device_class = device_class or self.DEFAULT_DEVICE_CLASS
-
def operating_system(self):
return 'watchos-simulator'
Modified: trunk/Tools/Scripts/webkitpy/port/win.py (238748 => 238749)
--- trunk/Tools/Scripts/webkitpy/port/win.py 2018-11-30 19:59:33 UTC (rev 238748)
+++ trunk/Tools/Scripts/webkitpy/port/win.py 2018-11-30 20:13:16 UTC (rev 238749)
@@ -395,13 +395,13 @@
except:
_log.warn("Failed to delete preference files.")
- def setup_test_run(self, device_class=None):
+ def setup_test_run(self, device_type=None):
atexit.register(self.restore_crash_log_saving)
self.setup_crash_log_saving()
self.prevent_error_dialogs()
self.delete_sem_locks()
self.delete_preference_files()
- super(WinPort, self).setup_test_run(device_class)
+ super(WinPort, self).setup_test_run(device_type)
def clean_up_test_run(self):
self.allow_error_dialogs()
Modified: trunk/Tools/Scripts/webkitpy/xcode/simulated_device.py (238748 => 238749)
--- trunk/Tools/Scripts/webkitpy/xcode/simulated_device.py 2018-11-30 19:59:33 UTC (rev 238748)
+++ trunk/Tools/Scripts/webkitpy/xcode/simulated_device.py 2018-11-30 20:13:16 UTC (rev 238749)
@@ -217,9 +217,10 @@
if full_device_type.hardware_type is None:
# Again, we use the existing devices to determine a legal hardware type
- for device in SimulatedDeviceManager.AVAILABLE_DEVICES:
- if device.platform_device.device_type == full_device_type:
- full_device_type.hardware_type = device.platform_device.device_type.hardware_type
+ for name in SimulatedDeviceManager._device_identifier_to_name.itervalues():
+ type_from_name = DeviceType.from_string(name)
+ if type_from_name == full_device_type:
+ full_device_type.hardware_type = type_from_name.hardware_type
break
full_device_type.check_consistency()