Changeset 238749 in webkit


Ignore:
Timestamp:
Nov 30, 2018 12:13:16 PM (5 years ago)
Author:
Jonathan Bedard
Message:

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.

Location:
trunk/Tools
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r238742 r238749  
     12018-11-30  Jonathan Bedard  <jbedard@apple.com>
     2
     3        webkitpy: Use DeviceType instead of str to represent device class
     4        https://bugs.webkit.org/show_bug.cgi?id=192160
     5        <rdar://problem/46344845>
     6
     7        Rubber-stamped by Aakash Jain.
     8
     9        * Scripts/webkitpy/layout_tests/controllers/manager.py:
     10        (Manager._custom_device_for_test): Use DeviceTypes instead of strings to represent device type.
     11        (Manager._set_up_run): Do not set _options.device_class, use device_type instead of device_class.
     12        (Manager.run): Use device_type instead of device_class.
     13        (Manager._print_expectations_for_subset): Ditto.
     14        (Manager.print_expectations): Ditto.
     15        * Scripts/webkitpy/layout_tests/controllers/manager_unittest.py:
     16        (ManagerTest.test_uses_custom_device): Use DeviceType and actual device definition.
     17        * Scripts/webkitpy/layout_tests/views/printing.py:
     18        (Printer.print_workers_and_shards): Outputting the device suffix doesn't really help, and means
     19        device type needs to be passed around.
     20        * Scripts/webkitpy/port/apple.py:
     21        (ApplePort.setup_test_run): Use device_type instead of device_class.
     22        * Scripts/webkitpy/port/base.py:
     23        (Port):
     24        (Port.setup_test_run): Use device_type instead of device_class.
     25        * Scripts/webkitpy/port/device_port.py:
     26        (DevicePort):
     27        (DevicePort.setup_test_run): Receive device_type as DeviceType object.
     28        (DevicePort._create_devices): Deleted.
     29        * Scripts/webkitpy/port/gtk.py:
     30        (GtkPort.setup_test_run): Use device_type instead of device_class.
     31        * Scripts/webkitpy/port/ios.py:
     32        (IOSPort):
     33        * Scripts/webkitpy/port/ios_simulator.py:
     34        (IOSSimulatorPort):
     35        (IOSSimulatorPort.__init__): Deleted.
     36        (IOSSimulatorPort._set_device_class): Deleted.
     37        * Scripts/webkitpy/port/test.py:
     38        * Scripts/webkitpy/port/watch.py:
     39        (WatchPort):
     40        * Scripts/webkitpy/port/watch_simulator.py:
     41        (WatchSimulatorPort):
     42        (WatchSimulatorPort.__init__): Deleted.
     43        (WatchSimulatorPort._set_device_class): Deleted.
     44        * Scripts/webkitpy/port/win.py:
     45        (WinPort.setup_test_run): Use device_type instead of device_class.
     46        * Scripts/webkitpy/xcode/simulated_device.py:
     47        (SimulatedDeviceManager._disambiguate_device_type): Using the existing devices for this is
     48        a problem if no such device exists yet. Use the _device_identifier_to_name dictionary instead
     49        since this should have hardware types in the device names.
     50
    1512018-11-30  David Quesada  <david_quesada@apple.com>
    252
  • trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py

    r237914 r238749  
    5656from webkitpy.layout_tests.models.test_run_results import INTERRUPTED_EXIT_STATUS
    5757from webkitpy.tool.grammar import pluralize
     58from webkitpy.xcode.device_type import DeviceType
    5859
    5960_log = logging.getLogger(__name__)
     
    104105
    105106    def _custom_device_for_test(self, test):
    106         for device_class in self._port.CUSTOM_DEVICE_CLASSES:
    107             directory_suffix = device_class.lower().replace(' ', '') + self._port.TEST_PATH_SEPARATOR
    108             if directory_suffix in test:
    109                 return device_class
     107        # FIXME: Use available devices instead of CUSTOM_DEVICE_TYPES https://bugs.webkit.org/show_bug.cgi?id=192161
     108        # FIXME: This is a terrible way to do device-specific expected results https://bugs.webkit.org/show_bug.cgi?id=192162
     109        for device_type in self._port.CUSTOM_DEVICE_TYPES:
     110            if device_type.hardware_family and device_type.hardware_family.lower() + self._port.TEST_PATH_SEPARATOR in test:
     111                return device_type
     112            if device_type.hardware_family and device_type.hardware_type and \
     113                (device_type.hardware_family + device_type.hardware_type).lower().replace(' ', '') + self._port.TEST_PATH_SEPARATOR in test:
     114                return device_type
    110115        return None
    111116
     
    160165        self._options.child_processes = worker_count
    161166
    162     def _set_up_run(self, test_names, device_class=None):
    163         self._options.device_class = device_class
    164 
     167    def _set_up_run(self, test_names, device_type=None):
    165168        # This must be started before we check the system dependencies,
    166169        # since the helper may do things to make the setup correct.
     
    179182                return False
    180183
    181         self._port.setup_test_run(self._options.device_class)
     184        self._port.setup_test_run(device_type)
    182185        return True
    183186
     
    216219
    217220        if custom_device_tests:
    218             for device_class in custom_device_tests:
    219                 _log.debug('{} tests use device {}'.format(len(custom_device_tests[device_class]), device_class))
     221            for device_type, tests in custom_device_tests.iteritems():
     222                _log.debug('{} tests use device {}'.format(len(tests), device_type))
    220223
    221224        initial_results = None
     
    251254        # Only use a single worker for custom device classes
    252255        self._options.child_processes = 1
    253         for device_class in custom_device_tests:
    254             device_tests = custom_device_tests[device_class]
     256        for device_type in custom_device_tests:
     257            device_tests = custom_device_tests[device_type]
    255258            if device_tests:
    256259                _log.info('')
    257                 _log.info('Running %s for %s', pluralize(len(device_tests), "test"), device_class)
     260                _log.info('Running %s for %s', pluralize(len(device_tests), "test"), device_type)
    258261                _log.info('')
    259                 if not self._set_up_run(device_tests, device_class):
     262                if not self._set_up_run(device_tests, device_type):
    260263                    return test_run_results.RunDetails(exit_code=-1)
    261264
     
    545548        print(format_string.format(test, line.expected_behavior, self._expectations.readable_filename_and_line_number(line), line.original_string or ''))
    546549   
    547     def _print_expectations_for_subset(self, device_class, test_col_width, tests_to_run, tests_to_skip={}):
     550    def _print_expectations_for_subset(self, device_type, test_col_width, tests_to_run, tests_to_skip={}):
    548551        format_string = '{{:{width}}} {{}} {{}} {{}}'.format(width=test_col_width)
    549552        if tests_to_skip:
     
    554557
    555558        print('')
    556         print('Tests to run{} ({})'.format(' for ' + device_class if device_class else '', len(tests_to_run)))
     559        print('Tests to run{} ({})'.format(' for ' + str(device_type) if device_type else '', len(tests_to_run)))
    557560        for test in sorted(tests_to_run):
    558561            self._print_expectation_line_for_test(format_string, test)
     
    587590
    588591        if custom_device_tests:
    589             for device_class in custom_device_tests:
    590                 _log.debug('{} tests use device {}'.format(len(custom_device_tests[device_class]), device_class))
     592            for device_type, tests in custom_device_tests.iteritems():
     593                _log.debug('{} tests use device {}'.format(len(tests), device_type))
    591594
    592595        self._print_expectations_for_subset(None, test_col_width, tests_to_run, tests_to_skip)
    593596
    594         for device_class in custom_device_tests:
    595             device_tests = custom_device_tests[device_class]
    596             self._print_expectations_for_subset(device_class, test_col_width, device_tests)
     597        for device_type, tests in custom_device_tests.iteritems():
     598            self._print_expectations_for_subset(device_type, test_col_width, tests)
    597599
    598600        return 0
  • trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py

    r216725 r238749  
    4141from webkitpy.thirdparty.mock import Mock
    4242from webkitpy.tool.mocktool import MockOptions
     43from webkitpy.xcode.device_type import DeviceType
    4344
    4445
     
    108109    def test_uses_custom_device(self):
    109110        class MockCustomDevicePort(TestPort):
    110             CUSTOM_DEVICE_CLASSES = ['starship']
     111            CUSTOM_DEVICE_TYPES = [DeviceType(hardware_family='iPad')]
    111112
    112113            def __init__(self, host):
     
    116117            host = MockHost()
    117118            port = MockCustomDevicePort(host)
    118             manager = Manager(port, options=MockOptions(test_list=['fast/test-starship/lasers.html'], http=True), printer=Mock())
     119            manager = Manager(port, options=MockOptions(test_list=['fast/ipad/lasers.html'], http=True), printer=Mock())
    119120            return manager
    120121
    121122        manager = get_manager()
    122         self.assertTrue(manager._custom_device_for_test('fast/test-starship/lasers.html') == 'starship')
     123        self.assertTrue(manager._custom_device_for_test('fast/ipad/lasers.html') == DeviceType(hardware_family='iPad'))
  • trunk/Tools/Scripts/webkitpy/layout_tests/views/printing.py

    r235771 r238749  
    114114        driver_name = self._port.driver_name()
    115115
    116         device_suffix = ' for device "{}"'.format(self._options.device_class) if self._options.device_class else ''
    117116        if num_workers == 1:
    118             self._print_default('Running 1 {}{}.'.format(driver_name, device_suffix))
     117            self._print_default('Running 1 {}.'.format(driver_name))
    119118            self._print_debug('({}).'.format(grammar.pluralize(num_shards, "shard")))
    120119        else:
    121             self._print_default('Running {} in parallel{}.'.format(grammar.pluralize(num_workers, driver_name), device_suffix))
     120            self._print_default('Running {} in parallel.'.format(grammar.pluralize(num_workers, driver_name)))
    122121            self._print_debug('({} shards).'.format(num_shards))
    123122        self._print_default('')
  • trunk/Tools/Scripts/webkitpy/port/apple.py

    r229955 r238749  
    8585        self._version = self._strip_port_name_prefix(port_name)
    8686
    87     def setup_test_run(self, device_class=None):
     87    def setup_test_run(self, device_type=None):
    8888        self._crash_logs_to_skip_for_host[self.host] = self.host.filesystem.files_under(self.path_to_crash_logs())
    8989
  • trunk/Tools/Scripts/webkitpy/port/base.py

    r235227 r238749  
    8282    DEFAULT_ARCHITECTURE = 'x86'
    8383
    84     CUSTOM_DEVICE_CLASSES = []
     84    CUSTOM_DEVICE_TYPES = []
    8585
    8686    @classmethod
     
    880880        return self._build_path('web-platform-tests-manifest.json')
    881881
    882     def setup_test_run(self, device_class=None):
     882    def setup_test_run(self, device_type=None):
    883883        """Perform port-specific work at the beginning of a test run."""
    884884        pass
  • trunk/Tools/Scripts/webkitpy/port/device_port.py

    r238694 r238749  
    3838
    3939    DEVICE_MANAGER = None
    40     DEFAULT_DEVICE_CLASS = None
     40    DEFAULT_DEVICE_TYPE = None
    4141    NO_DEVICE_MANAGER = 'No device manager found for port'
    4242
     
    8888        return self.DEVICE_MANAGER.INITIALIZED_DEVICES
    8989
    90     def _create_devices(self, device_class):
    91         raise NotImplementedError
    92 
    9390    # Despite their names, these flags do not actually get passed all the way down to webkit-build.
    9491    def _build_driver_flags(self):
     
    110107                raise RuntimeError('Failed to install dylibs at {} on device {}'.format(self._build_path(), device.udid))
    111108
    112     def setup_test_run(self, device_class=None):
     109    def setup_test_run(self, device_type=None):
    113110        if not self.DEVICE_MANAGER:
    114111            raise RuntimeError(self.NO_DEVICE_MANAGER)
    115112
    116         device_type = DeviceType.from_string(device_class if device_class else self.DEFAULT_DEVICE_CLASS, self.device_version())
     113        device_type = device_type if device_type else self.DEFAULT_DEVICE_TYPE
     114        device_type = DeviceType(
     115            hardware_family=device_type.hardware_family,
     116            hardware_type=device_type.hardware_type,
     117            software_version=self.device_version(),
     118            software_variant=device_type.software_variant,
     119        )
    117120        _log.debug('\nCreating devices for {}'.format(device_type))
    118121
  • trunk/Tools/Scripts/webkitpy/port/gtk.py

    r237741 r238749  
    104104        return super(GtkPort, self).driver_stop_timeout()
    105105
    106     def setup_test_run(self, device_class=None):
    107         super(GtkPort, self).setup_test_run(device_class)
     106    def setup_test_run(self, device_type=None):
     107        super(GtkPort, self).setup_test_run(device_type)
    108108        self._pulseaudio_sanitizer.unload_pulseaudio_module()
    109109
  • trunk/Tools/Scripts/webkitpy/port/ios.py

    r238694 r238749  
    3131from webkitpy.port.device_port import DevicePort
    3232from webkitpy.port.simulator_process import SimulatorProcess
     33from webkitpy.xcode.device_type import DeviceType
    3334
    3435_log = logging.getLogger(__name__)
     
    4041    CURRENT_VERSION = Version(12)
    4142    # FIXME: This is not a clear way to do this (although it works) https://bugs.webkit.org/show_bug.cgi?id=192160
    42     DEFAULT_DEVICE_CLASS = ''
     43    DEFAULT_DEVICE_TYPE = DeviceType(software_variant='iOS')
    4344
    4445    def __init__(self, host, port_name, **kwargs):
  • trunk/Tools/Scripts/webkitpy/port/ios_simulator.py

    r238694 r238749  
    4343    DEVICE_MANAGER = SimulatedDeviceManager
    4444
    45     DEFAULT_DEVICE_CLASS = 'iPhone SE'
    46     CUSTOM_DEVICE_CLASSES = ['iPad', 'iPhone 7']
     45    DEFAULT_DEVICE_TYPE = DeviceType(hardware_family='iPhone', hardware_type='SE')
     46    CUSTOM_DEVICE_TYPES = [DeviceType(hardware_family='iPad'), DeviceType(hardware_family='iPhone', hardware_type='7')]
    4747    SDK = apple_additions().get_sdk('iphonesimulator') if apple_additions() else 'iphonesimulator'
    48 
    49     def __init__(self, host, port_name, **kwargs):
    50         super(IOSSimulatorPort, self).__init__(host, port_name, **kwargs)
    51 
    52         optional_device_class = self.get_option('device_class')
    53         self._device_class = optional_device_class if optional_device_class else self.DEFAULT_DEVICE_CLASS
    54         _log.debug('IOSSimulatorPort _device_class is %s', self._device_class)
    5548
    5649    @staticmethod
     
    7871                return num_booted_sims
    7972        return SimulatedDeviceManager.max_supported_simulators(self.host)
    80 
    81     def _set_device_class(self, device_class):
    82         self._device_class = device_class if device_class else self.DEFAULT_DEVICE_CLASS
    8373
    8474    def clean_up_test_run(self):
  • trunk/Tools/Scripts/webkitpy/port/test.py

    r235764 r238749  
    468468        return '/tmp/layout-test-results'
    469469
    470     def setup_test_run(self, device_class=None):
     470    def setup_test_run(self, device_type=None):
    471471        pass
    472472
  • trunk/Tools/Scripts/webkitpy/port/watch.py

    r238694 r238749  
    2828from webkitpy.port.config import apple_additions
    2929from webkitpy.port.device_port import DevicePort
     30from webkitpy.xcode.device_type import DeviceType
    3031
    3132
     
    3738
    3839    CURRENT_VERSION = Version(5)
    39     DEFAULT_DEVICE_CLASS = 'Apple Watch'
     40    DEFAULT_DEVICE_TYPE = DeviceType(software_variant='watchOS')
    4041
    4142    def __init__(self, *args, **kwargs):
  • trunk/Tools/Scripts/webkitpy/port/watch_simulator.py

    r238694 r238749  
    4141    DEVICE_MANAGER = SimulatedDeviceManager
    4242
    43     DEFAULT_DEVICE_CLASS = 'Apple Watch Series 3 - 42mm'
    44     CUSTOM_DEVICE_CLASSES = []
     43    DEFAULT_DEVICE_TYPE = DeviceType(hardware_family='Apple Watch', hardware_type='Series 3 - 42mm')
    4544    SDK = apple_additions().get_sdk('watchsimulator') if apple_additions() else 'watchsimulator'
    46 
    47     def __init__(self, *args, **kwargs):
    48         super(WatchSimulatorPort, self).__init__(*args, **kwargs)
    49 
    50         self._set_device_class(self.get_option('device_class'))
    51         _log.debug('WatchSimulatorPort _device_class is %s', self._device_class)
    5245
    5346    def architecture(self):
     
    9285        return SimulatedDeviceManager.max_supported_simulators(self.host)
    9386
    94     def _set_device_class(self, device_class):
    95         self._device_class = device_class or self.DEFAULT_DEVICE_CLASS
    96 
    9787    def operating_system(self):
    9888        return 'watchos-simulator'
  • trunk/Tools/Scripts/webkitpy/port/win.py

    r235227 r238749  
    396396            _log.warn("Failed to delete preference files.")
    397397
    398     def setup_test_run(self, device_class=None):
     398    def setup_test_run(self, device_type=None):
    399399        atexit.register(self.restore_crash_log_saving)
    400400        self.setup_crash_log_saving()
     
    402402        self.delete_sem_locks()
    403403        self.delete_preference_files()
    404         super(WinPort, self).setup_test_run(device_class)
     404        super(WinPort, self).setup_test_run(device_type)
    405405
    406406    def clean_up_test_run(self):
  • trunk/Tools/Scripts/webkitpy/xcode/simulated_device.py

    r238684 r238749  
    218218        if full_device_type.hardware_type is None:
    219219            # Again, we use the existing devices to determine a legal hardware type
    220             for device in SimulatedDeviceManager.AVAILABLE_DEVICES:
    221                 if device.platform_device.device_type == full_device_type:
    222                     full_device_type.hardware_type = device.platform_device.device_type.hardware_type
     220            for name in SimulatedDeviceManager._device_identifier_to_name.itervalues():
     221                type_from_name = DeviceType.from_string(name)
     222                if type_from_name == full_device_type:
     223                    full_device_type.hardware_type = type_from_name.hardware_type
    223224                    break
    224225
Note: See TracChangeset for help on using the changeset viewer.