def test_ios_version_by_name(self): map = VersionNameMap() self.assertEqual(('ios', Version(11)), map.from_name('iOS 11')) self.assertEqual(('ios', Version(11)), map.from_name('ios11')) self.assertEqual(('ios', Version(11)), map.from_name('iOS 11.2')) self.assertEqual(('ios', Version(11)), map.from_name('ios11.2')) self.assertEqual(('ios', Version(11)), map.from_name('iOS11.2'))
def test_matching_up_success(self): SimulatedDeviceTest.reset_simulated_device_manager() host = SimulatedDeviceTest.mock_host_for_simctl() SimulatedDeviceManager.available_devices(host) runtime = SimulatedDeviceManager.get_runtime_for_device_type( DeviceType.from_string('iphone 5s', Version(9, 2))) self.assertEquals(runtime.os_variant, 'iOS') self.assertEquals(runtime.version, Version(9, 3))
def _automap_to_major_version(cls, prefix, minimum=Version(1), maximum=Version(1)): result = {} assert minimum <= maximum for i in range((maximum.major + 1) - minimum.major): result['{} {}'.format(prefix, str( Version(minimum.major + i)))] = Version(minimum.major + i) return result
def test_ios_name_by_version(self): map = VersionNameMap() self.assertEqual('iOS 13', map.to_name(version=Version(13), platform='ios')) self.assertEqual('iOS 12', map.to_name(version=Version(12), platform='ios')) self.assertEqual('iOS 11', map.to_name(version=Version(11), platform='ios')) self.assertEqual('iOS 10', map.to_name(version=Version(10), platform='ios')) self.assertEqual('iOS 10', map.to_name(version=Version(10, 3), platform='ios'))
def test_contained_in(self): self.assertTrue( DeviceType.from_string('iPhone 6s') in DeviceType.from_string( 'iPhone')) self.assertFalse( DeviceType.from_string('iPhone') in DeviceType.from_string( 'iPhone 6s')) self.assertTrue( DeviceType.from_string('iPhone', Version(11, 1)) in DeviceType.from_string('iPhone', Version(11))) self.assertFalse( DeviceType.from_string('iPhone', Version(11)) in DeviceType.from_string('iPhone', Version(11, 1)))
def test_iphone_initialization(self): type = DeviceType(hardware_family='iPhone') self.assertEquals('iPhone', type.hardware_family) self.assertEquals(None, type.hardware_type) self.assertEquals('iOS', type.software_variant) self.assertEquals(None, type.software_version) self.assertEqual('iPhone running iOS', str(type)) type = DeviceType('iPhone', '6s', Version(11)) self.assertEquals('iPhone', type.hardware_family) self.assertEquals('6s', type.hardware_type) self.assertEquals('iOS', type.software_variant) self.assertEquals(Version(11), type.software_version) self.assertEqual('iPhone 6s running iOS 11', str(type))
def test_ipad_initialization(self): type = DeviceType(hardware_family='iPad') self.assertEquals('iPad', type.hardware_family) self.assertEquals(None, type.hardware_type) self.assertEquals('iOS', type.software_variant) self.assertEquals(None, type.software_version) self.assertEqual('iPad running iOS', str(type)) type = DeviceType('iPad', 'Air 2', Version(11)) self.assertEquals('iPad', type.hardware_family) self.assertEquals('Air 2', type.hardware_type) self.assertEquals('iOS', type.software_variant) self.assertEquals(Version(11), type.software_version) self.assertEqual('iPad Air 2 running iOS 11', str(type))
def test_tv_initialization(self): type = DeviceType(hardware_family='TV') self.assertEquals('Apple TV', type.hardware_family) self.assertEquals(None, type.hardware_type) self.assertEquals('tvOS', type.software_variant) self.assertEquals(None, type.software_version) self.assertEqual('Apple TV running tvOS', str(type)) type = DeviceType('Apple TV', '4K', Version(11)) self.assertEquals('Apple TV', type.hardware_family) self.assertEquals('4K', type.hardware_type) self.assertEquals('tvOS', type.software_variant) self.assertEquals(Version(11), type.software_version) self.assertEqual('Apple TV 4K running tvOS 11', str(type))
def test_watch_initialization(self): type = DeviceType(hardware_family='Watch') self.assertEquals('Apple Watch', type.hardware_family) self.assertEquals(None, type.hardware_type) self.assertEquals('watchOS', type.software_variant) self.assertEquals(None, type.software_version) self.assertEqual('Apple Watch running watchOS', str(type)) type = DeviceType('Apple Watch', 'Series 2 - 42mm', Version(4)) self.assertEquals('Apple Watch', type.hardware_family) self.assertEquals('Series 2 - 42mm', type.hardware_type) self.assertEquals('watchOS', type.software_variant) self.assertEquals(Version(4), type.software_version) self.assertEqual('Apple Watch Series 2 - 42mm running watchOS 4', str(type))
def test_int_constructor(self): v = Version(1) self.assertEqual(v.major, 1) self.assertEqual(v.minor, 0) self.assertEqual(v.tiny, 0) self.assertEqual(v.micro, 0) self.assertEqual(v.nano, 0)
def test_layout_searchpath_wih_device_type(self): search_path = self.make_port(port_name='ios-device-wk2', os_version=Version(14)).default_baseline_search_path(DeviceType.from_string('iPhone SE')) self.assertEqual(search_path, [ '/mock-checkout/LayoutTests/platform/iphone-se-device-14-wk2', '/mock-checkout/LayoutTests/platform/iphone-se-device-14', '/mock-checkout/LayoutTests/platform/iphone-se-device-wk2', '/mock-checkout/LayoutTests/platform/iphone-se-device', '/mock-checkout/LayoutTests/platform/iphone-device-14-wk2', '/mock-checkout/LayoutTests/platform/iphone-device-14', '/mock-checkout/LayoutTests/platform/iphone-device-wk2', '/mock-checkout/LayoutTests/platform/iphone-device', '/mock-checkout/LayoutTests/platform/ios-device-14-wk2', '/mock-checkout/LayoutTests/platform/ios-device-14', '/mock-checkout/LayoutTests/platform/ios-device-wk2', '/mock-checkout/LayoutTests/platform/ios-device', '/mock-checkout/LayoutTests/platform/iphone-se-14-wk2', '/mock-checkout/LayoutTests/platform/iphone-se-14', '/mock-checkout/LayoutTests/platform/iphone-se-wk2', '/mock-checkout/LayoutTests/platform/iphone-se', '/mock-checkout/LayoutTests/platform/iphone-14-wk2', '/mock-checkout/LayoutTests/platform/iphone-14', '/mock-checkout/LayoutTests/platform/iphone-wk2', '/mock-checkout/LayoutTests/platform/iphone', '/mock-checkout/LayoutTests/platform/ios-14-wk2', '/mock-checkout/LayoutTests/platform/ios-14', '/mock-checkout/LayoutTests/platform/ios-wk2', '/mock-checkout/LayoutTests/platform/ios', '/mock-checkout/LayoutTests/platform/wk2', ])
def test_get_by_int(self): v = Version(1, 2, 3, 4, 5) self.assertEqual(v[0], v.major) self.assertEqual(v[1], v.minor) self.assertEqual(v[2], v.tiny) self.assertEqual(v[3], v.micro) self.assertEqual(v[4], v.nano)
def test_get_by_string(self): v = Version(1, 2, 3, 4, 5) self.assertEqual(v['major'], v.major) self.assertEqual(v['minor'], v.minor) self.assertEqual(v['tiny'], v.tiny) self.assertEqual(v['micro'], v.micro) self.assertEqual(v['nano'], v.nano)
def test_matching_up_failure(self): SimulatedDeviceTest.reset_simulated_device_manager() host = SimulatedDeviceTest.mock_host_for_simctl() SimulatedDeviceManager.available_devices(host) runtime = SimulatedDeviceManager.get_runtime_for_device_type( DeviceType.from_string('iphone 5s', Version(9, 4))) self.assertEquals(runtime, None)
def test_set_by_string(self): v = Version() v['major'] = 1 self.assertEqual(v.major, 1) v['minor'] = 2 self.assertEqual(v.minor, 2) v['tiny'] = 3 self.assertEqual(v.tiny, 3) v['micro'] = 4 self.assertEqual(v.micro, 4) v['nano'] = 5 self.assertEqual(v.nano, 5)
def test_set_by_int(self): v = Version() v[0] = 1 self.assertEqual(v.major, 1) v[1] = 2 self.assertEqual(v.minor, 2) v[2] = 3 self.assertEqual(v.tiny, 3) v[3] = 4 self.assertEqual(v.micro, 4) v[4] = 5 self.assertEqual(v.nano, 5)
def test_layout_test_searchpath_without_apple_additions(self): search_path = self.make_port(port_name='ios-device-wk2', os_version=Version(14)).default_baseline_search_path() self.assertEqual(search_path, [ '/mock-checkout/LayoutTests/platform/ios-device-14-wk2', '/mock-checkout/LayoutTests/platform/ios-device-14', '/mock-checkout/LayoutTests/platform/ios-device-wk2', '/mock-checkout/LayoutTests/platform/ios-device', '/mock-checkout/LayoutTests/platform/ios-14-wk2', '/mock-checkout/LayoutTests/platform/ios-14', '/mock-checkout/LayoutTests/platform/ios-wk2', '/mock-checkout/LayoutTests/platform/ios', '/mock-checkout/LayoutTests/platform/wk2', ])
def add_list(self, paths): for path in paths: self._add_parent_directories(os.path.dirname(os.path.abspath(path))) if self.svn_version() >= Version(1, 7): # For subversion client 1.7 and later, need to add '--parents' option to ensure intermediate directories # are added; in addition, 1.7 returns an exit code of 1 from svn add if one or more of the requested # adds are already under version control, including intermediate directories subject to addition # due to --parents svn_add_args = ['svn', 'add', '--parents'] + paths exit_code = self.run(svn_add_args, return_exit_code=True) if exit_code and exit_code != 1: raise ScriptError(script_args=svn_add_args, exit_code=exit_code) else: self._run_svn(["add"] + paths)
def make_port(self, host=None, port_name=None, options=None, os_name=None, os_version=Version(14), **kwargs): port = super(IOSTest, self).make_port(host=host, port_name=port_name, options=options, os_name=os_name, os_version=None, kwargs=kwargs) port.set_option('version', str(os_version)) return port
def make_port(self, host=None, port_name=None, options=None, os_name=None, os_version=Version(14), **kwargs): port = super(IOSSimulatorTest, self).make_port(host=host, port_name=port_name, options=options, os_name=os_name, os_version=os_version, kwargs=kwargs) port.set_option('child_processes', 1) return port
def test_from_string(self): self.assertEqual('iPhone 6s running iOS', str(DeviceType.from_string('iPhone 6s'))) self.assertEqual('iPhone 6 Plus running iOS', str(DeviceType.from_string('iPhone 6 Plus'))) self.assertEqual('iPhone running iOS 11', str(DeviceType.from_string('iPhone', Version(11)))) self.assertEqual('iPad Air 2 running iOS', str(DeviceType.from_string('iPad Air 2'))) self.assertEqual( 'Apple Watch Series 2 - 42mm running watchOS', str(DeviceType.from_string('Apple Watch Series 2 - 42mm'))) self.assertEqual('Apple TV 4K running tvOS', str(DeviceType.from_string('Apple TV 4K'))) self.assertEqual('Device running iOS', str(DeviceType.from_string(''))) self.assertEqual('Apple Watch running watchOS', str(DeviceType.from_string('Apple Watch')))
def test_lower_case_device_type(self): SimulatedDeviceTest.reset_simulated_device_manager() host = SimulatedDeviceTest.mock_host_for_simctl() SimulatedDeviceManager.available_devices(host) SimulatedDeviceManager.initialize_devices(DeviceRequest( DeviceType.from_string('iphone 5s', Version(11))), host=host) self.assertEquals(1, len(SimulatedDeviceManager.INITIALIZED_DEVICES)) self.assertEquals('34FB476C-6FA0-43C8-8945-1BD7A4EBF0DE', SimulatedDeviceManager.INITIALIZED_DEVICES[0].udid) self.assertEquals( SimulatedDevice.DeviceState.BOOTED, SimulatedDeviceManager. INITIALIZED_DEVICES[0].platform_device.state()) SimulatedDeviceManager.tear_down(host) self.assertIsNone(SimulatedDeviceManager.INITIALIZED_DEVICES)
def test_mac_name_by_version(self): map = VersionNameMap() self.assertEqual('Catalina', map.to_name(version=Version(10, 15), platform='mac')) self.assertEqual('Mojave', map.to_name(version=Version(10, 14), platform='mac')) self.assertEqual('High Sierra', map.to_name(version=Version(10, 13), platform='mac')) self.assertEqual( 'High Sierra', map.to_name(version=Version(10, 13, 3), platform='mac')) self.assertEqual('Sierra', map.to_name(version=Version(10, 12), platform='mac')) self.assertEqual('El Capitan', map.to_name(version=Version(10, 11), platform='mac')) self.assertEqual( 'El Capitan', map.to_name(version=Version(10, 11, 3), platform='mac'))
def test_matches(self): version = Version(1, 2, 3) self.assertTrue(version.matches('')) self.assertTrue(version.matches('1.*')) self.assertFalse(version.matches('2.*')) self.assertFalse(version.matches('!=1.*')) self.assertTrue(version.matches('!=2.*')) self.assertTrue(version.matches('<=2')) self.assertFalse(version.matches('<=1')) self.assertTrue(version.matches('<1.3')) self.assertFalse(version.matches('<1.2')) self.assertTrue(version.matches('>=1')) self.assertFalse(version.matches('>=2')) self.assertTrue(version.matches('>1.2')) self.assertFalse(version.matches('>1.3'))
def default_baseline_search_path(self, **kwargs): versions_to_fallback = [] if self.device_version() == self.CURRENT_VERSION: versions_to_fallback = [self.CURRENT_VERSION] elif self.device_version(): temp_version = Version(self.device_version().major) while temp_version.major != self.CURRENT_VERSION.major: versions_to_fallback.append(Version.from_iterable(temp_version)) if temp_version < self.CURRENT_VERSION: temp_version.major += 1 else: temp_version.major -= 1 expectations = [] for version in versions_to_fallback: if apple_additions(): apple_name = VersionNameMap.map(self.host.platform).to_name(version, platform=WatchPort.port_name, table=INTERNAL_TABLE) expectations.append(self._apple_baseline_path('{}-{}'.format(self.port_name, apple_name.lower().replace(' ', '')))) expectations.append(self._webkit_baseline_path('{}-{}'.format(self.port_name, version.major))) if apple_additions(): expectations.append(self._apple_baseline_path(self.port_name)) expectations.append(self._webkit_baseline_path(self.port_name)) for version in versions_to_fallback: apple_name = None if apple_additions(): apple_name = VersionNameMap.map(self.host.platform).to_name(version, platform=WatchPort.port_name, table=INTERNAL_TABLE) if apple_name: expectations.append( self._apple_baseline_path('{}-{}'.format(WatchPort.port_name, apple_name.lower().replace(' ', '')))) expectations.append(self._webkit_baseline_path('{}-{}'.format(WatchPort.port_name, version.major))) if apple_additions(): expectations.append(self._apple_baseline_path(WatchPort.port_name)) expectations.append(self._webkit_baseline_path(WatchPort.port_name)) expectations.append(self._webkit_baseline_path('wk2')) return expectations
def make_port(self, host=None, port_name=None, options=None, os_name=None, os_version=Version(5), **kwargs): if options: options.architecture = 'x86' options.webkit_test_runner = True else: options = MockOptions(architecture='x86', webkit_test_runner=True, configuration='Release') port = super(WatchTest, self).make_port(host=host, port_name=port_name, options=options, os_name=os_name, os_version=None, kwargs=kwargs) port.set_option('version', str(os_version)) return port
'webkitcorepy')) and webkitcorepy_path not in sys.path: sys.path.insert(0, webkitcorepy_path) _maybe_add_webkitcorepy_path() try: from webkitcorepy import AutoInstall, Package, Version except ImportError: raise ImportError( "'webkitcorepy' could not be found on your Python path.\n" + "You are not running from a WebKit checkout.\n" + "Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`" ) version = Version(0, 14, 6) AutoInstall.register(Package('fasteners', Version(0, 15, 0))) AutoInstall.register(Package('monotonic', Version(1, 5))) AutoInstall.register(Package('whichcraft', Version(0, 6, 1))) AutoInstall.register(Package('xmltodict', Version(0, 11, 0))) from webkitscmpy.contributor import Contributor from webkitscmpy.commit import Commit from webkitscmpy.scm_base import ScmBase from webkitscmpy import local from webkitscmpy import mocks name = 'webkitscmpy'
if os.path.isdir(webkitcorepy_path) and os.path.isdir(os.path.join(webkitcorepy_path, 'webkitcorepy')) and webkitcorepy_path not in sys.path: sys.path.insert(0, webkitcorepy_path) _maybe_add_webkitcorepy_path() try: from webkitcorepy import AutoInstall, Package, Version except ImportError: raise ImportError( "'webkitcorepy' could not be found on your Python path.\n" + "You are not running from a WebKit checkout.\n" + "Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`" ) version = Version(0, 9, 2) AutoInstall.register(Package('entrypoints', Version(0, 3, 0))) AutoInstall.register(Package('fasteners', Version(0, 15, 0))) AutoInstall.register(Package('keyring', Version(11, 1, 0))) AutoInstall.register(Package('monotonic', Version(1, 5))) AutoInstall.register(Package('xmltodict', Version(0, 12, 0))) from webkitscmpy.contributor import Contributor from webkitscmpy.commit import Commit from webkitscmpy.scm_base import ScmBase from webkitscmpy import local from webkitscmpy import mocks name = 'webkitscmpy'
libraries = os.path.join(os.path.abspath(os.path.dirname(os.path.dirname(__file__))), 'libraries') sys.path.insert(0, os.path.join(libraries, 'webkitcorepy')) if sys.platform == 'darwin': is_root = not os.getuid() does_own_libraries = os.stat(libraries).st_uid == os.getuid() if (is_root or not does_own_libraries): libraries = os.path.expanduser('~/Library/webkitpy') from webkitcorepy import AutoInstall, Package, Version AutoInstall.set_directory(os.path.join(libraries, 'autoinstalled', 'python-{}'.format(sys.version_info[0]))) if sys.version_info > (3, 4): # Python >=3.5.* AutoInstall.register(Package('pylint', Version(2, 6, 0))) else: AutoInstall.register(Package('pylint', Version(0, 28, 0))) AutoInstall.register(Package('logilab.common', Version(0, 58, 1), pypi_name='logilab-common', aliases=['logilab'])) AutoInstall.register(Package('logilab.astng', Version(0, 24, 1), pypi_name='logilab-astng', aliases=['logilab'])) AutoInstall.register(Package('pathlib', Version(2, 3, 5), pypi_name='pathlib2')) AutoInstall.register(Package('atomicwrites', Version(1, 1, 5))) AutoInstall.register(Package('attr', Version(18, 1, 0), pypi_name='attrs')) AutoInstall.register(Package('bs4', Version(4, 9, 3), pypi_name='beautifulsoup4')) AutoInstall.register(Package('configparser', Version(4, 0, 2))) AutoInstall.register(Package('contextlib2', Version(0, 6, 0))) AutoInstall.register(Package('coverage', Version(5, 2, 1))) AutoInstall.register(Package('funcsigs', Version(1, 0, 2))) AutoInstall.register(Package('importlib_metadata', Version(1, 7, 0)))
def _status_regexp(self, expected_types): field_count = 6 if self.svn_version() > Version(1, 6) else 5 return "^(?P<status>[%s]).{%s} (?P<filename>.+)$" % (expected_types, field_count)