WebKit Bugzilla
Attachment 356198 Details for
Bug 192160
: webkitpy: Use DeviceType instead of str to represent device class
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for landing
bug-192160-20181130104510.patch (text/plain), 22.99 KB, created by
Jonathan Bedard
on 2018-11-30 10:45:11 PST
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Jonathan Bedard
Created:
2018-11-30 10:45:11 PST
Size:
22.99 KB
patch
obsolete
>Index: Tools/ChangeLog >=================================================================== >--- Tools/ChangeLog (revision 238741) >+++ Tools/ChangeLog (working copy) >@@ -1,3 +1,53 @@ >+2018-11-30 Jonathan Bedard <jbedard@apple.com> >+ >+ 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 Zalan Bujtas <zalan@apple.com> > > [LFC][BFC] Compute min/maxHeight margins only when they are needed. >Index: Tools/Scripts/webkitpy/layout_tests/controllers/manager.py >=================================================================== >--- Tools/Scripts/webkitpy/layout_tests/controllers/manager.py (revision 238741) >+++ Tools/Scripts/webkitpy/layout_tests/controllers/manager.py (working copy) >@@ -55,6 +55,7 @@ from webkitpy.layout_tests.models import > 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 @@ class Manager(object): > 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 @@ class Manager(object): > 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 @@ class Manager(object): > 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 @@ class Manager(object): > 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 @@ class Manager(object): > > # 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 @@ class Manager(object): > 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 @@ class Manager(object): > 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 @@ class Manager(object): > 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 >Index: Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py >=================================================================== >--- Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py (revision 238741) >+++ Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py (working copy) >@@ -40,6 +40,7 @@ from webkitpy.layout_tests.models.test_r > 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 @@ class ManagerTest(unittest.TestCase): > > 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 @@ class ManagerTest(unittest.TestCase): > 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')) >Index: Tools/Scripts/webkitpy/layout_tests/views/printing.py >=================================================================== >--- Tools/Scripts/webkitpy/layout_tests/views/printing.py (revision 238741) >+++ Tools/Scripts/webkitpy/layout_tests/views/printing.py (working copy) >@@ -113,12 +113,11 @@ class Printer(object): > 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('') > >Index: Tools/Scripts/webkitpy/port/apple.py >=================================================================== >--- Tools/Scripts/webkitpy/port/apple.py (revision 238741) >+++ Tools/Scripts/webkitpy/port/apple.py (working copy) >@@ -84,7 +84,7 @@ class ApplePort(Port): > 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): >Index: Tools/Scripts/webkitpy/port/base.py >=================================================================== >--- Tools/Scripts/webkitpy/port/base.py (revision 238741) >+++ Tools/Scripts/webkitpy/port/base.py (working copy) >@@ -81,7 +81,7 @@ class Port(object): > > DEFAULT_ARCHITECTURE = 'x86' > >- CUSTOM_DEVICE_CLASSES = [] >+ CUSTOM_DEVICE_TYPES = [] > > @classmethod > def determine_full_port_name(cls, host, options, port_name): >@@ -879,7 +879,7 @@ class Port(object): > 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 > >Index: Tools/Scripts/webkitpy/port/device_port.py >=================================================================== >--- Tools/Scripts/webkitpy/port/device_port.py (revision 238741) >+++ Tools/Scripts/webkitpy/port/device_port.py (working copy) >@@ -37,7 +37,7 @@ _log = logging.getLogger(__name__) > 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 @@ class DevicePort(DarwinPort): > 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 @@ class DevicePort(DarwinPort): > 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( >Index: Tools/Scripts/webkitpy/port/gtk.py >=================================================================== >--- Tools/Scripts/webkitpy/port/gtk.py (revision 238741) >+++ Tools/Scripts/webkitpy/port/gtk.py (working copy) >@@ -103,8 +103,8 @@ class GtkPort(Port): > 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"): >Index: Tools/Scripts/webkitpy/port/ios.py >=================================================================== >--- Tools/Scripts/webkitpy/port/ios.py (revision 238741) >+++ Tools/Scripts/webkitpy/port/ios.py (working copy) >@@ -30,6 +30,7 @@ from webkitpy.layout_tests.models.test_c > 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 @@ class IOSPort(DevicePort): > > 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) >Index: Tools/Scripts/webkitpy/port/ios_simulator.py >=================================================================== >--- Tools/Scripts/webkitpy/port/ios_simulator.py (revision 238741) >+++ Tools/Scripts/webkitpy/port/ios_simulator.py (working copy) >@@ -42,17 +42,10 @@ class IOSSimulatorPort(IOSPort): > > 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 @@ class IOSSimulatorPort(IOSPort): > 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") >Index: Tools/Scripts/webkitpy/port/test.py >=================================================================== >--- Tools/Scripts/webkitpy/port/test.py (revision 238741) >+++ Tools/Scripts/webkitpy/port/test.py (working copy) >@@ -467,7 +467,7 @@ class TestPort(Port): > 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): >Index: Tools/Scripts/webkitpy/port/watch.py >=================================================================== >--- Tools/Scripts/webkitpy/port/watch.py (revision 238741) >+++ Tools/Scripts/webkitpy/port/watch.py (working copy) >@@ -27,6 +27,7 @@ from webkitpy.common.version import Vers > 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 @@ class WatchPort(DevicePort): > 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) >Index: Tools/Scripts/webkitpy/port/watch_simulator.py >=================================================================== >--- Tools/Scripts/webkitpy/port/watch_simulator.py (revision 238741) >+++ Tools/Scripts/webkitpy/port/watch_simulator.py (working copy) >@@ -40,16 +40,9 @@ class WatchSimulatorPort(WatchPort): > > 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 @@ class WatchSimulatorPort(WatchPort): > 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' > >Index: Tools/Scripts/webkitpy/port/win.py >=================================================================== >--- Tools/Scripts/webkitpy/port/win.py (revision 238741) >+++ Tools/Scripts/webkitpy/port/win.py (working copy) >@@ -395,13 +395,13 @@ class WinPort(ApplePort): > 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() >Index: Tools/Scripts/webkitpy/xcode/simulated_device.py >=================================================================== >--- Tools/Scripts/webkitpy/xcode/simulated_device.py (revision 238741) >+++ Tools/Scripts/webkitpy/xcode/simulated_device.py (working copy) >@@ -217,9 +217,10 @@ class SimulatedDeviceManager(object): > > 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()
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 192160
:
356084
| 356198