def map(platform=None): from webkitpy.port.config import apple_additions if apple_additions(): return apple_additions().version_name_mapping(platform) return VersionNameMap(platform=platform)
def default_baseline_search_path(self): versions_to_fallback = [] version_name_map = VersionNameMap.map(self.host.platform) if self._os_version == self.CURRENT_VERSION: versions_to_fallback = [self.CURRENT_VERSION] else: temp_version = Version(self._os_version.major, self._os_version.minor) while temp_version != self.CURRENT_VERSION: versions_to_fallback.append( Version.from_iterable(temp_version)) if temp_version < self.CURRENT_VERSION: temp_version.minor += 1 else: temp_version.minor -= 1 wk_string = 'wk1' if self.get_option('webkit_test_runner'): wk_string = 'wk2' expectations = [] for version in versions_to_fallback: version_name = version_name_map.to_name(version, platform=self.port_name) if version_name: standardized_version_name = version_name.lower().replace( ' ', '') apple_name = None if apple_additions(): apple_name = version_name_map.to_name(version, platform=self.port_name, table=INTERNAL_TABLE) if apple_name: expectations.append( self._apple_baseline_path('mac-{}-{}'.format( apple_name.lower().replace(' ', ''), wk_string))) if version_name: expectations.append( self._webkit_baseline_path('mac-{}-{}'.format( standardized_version_name, wk_string))) if apple_name: expectations.append( self._apple_baseline_path('mac-{}'.format( apple_name.lower().replace(' ', '')))) if version_name: expectations.append( self._webkit_baseline_path( 'mac-{}'.format(standardized_version_name))) if apple_additions(): expectations.append( self._apple_baseline_path('{}-{}'.format( self.port_name, wk_string))) expectations.append( self._webkit_baseline_path('{}-{}'.format(self.port_name, wk_string))) if apple_additions(): expectations.append( self._apple_baseline_path('{}'.format(self.port_name))) expectations.append(self._webkit_baseline_path(self.port_name)) if self.get_option('webkit_test_runner'): expectations.append(self._webkit_baseline_path('wk2')) return expectations
def _create_checker(self, file_type, file_path, handle_style_error, min_confidence, commit_queue): """Instantiate and return a style checker based on file type.""" if file_type == FileType.NONE: checker = None elif file_type == FileType.CHANGELOG: should_line_be_checked = None if handle_style_error: should_line_be_checked = handle_style_error.should_line_be_checked checker = ChangeLogChecker(file_path, handle_style_error, should_line_be_checked) elif file_type == FileType.CPP: file_extension = self._file_extension(file_path) checker = CppChecker(file_path, file_extension, handle_style_error, min_confidence) elif file_type == FileType.JS: basename = os.path.basename(file_path) # Do not attempt to check non-Inspector or 3rd-party JavaScript files as JS. if os.path.join('WebInspectorUI', 'UserInterface') in file_path and (not 'External' in file_path): checker = JSChecker(file_path, handle_style_error) elif basename in _NEVER_SKIPPED_JS_FILES: checker = JSTestChecker(file_path, handle_style_error) else: checker = TextChecker(file_path, handle_style_error) elif file_type == FileType.JSON: basename = os.path.basename(file_path) if basename == 'contributors.json': if commit_queue: checker = JSONContributorsChecker(file_path, handle_style_error) else: checker = ContributorsChecker(file_path, handle_style_error) elif basename == 'features.json': checker = JSONFeaturesChecker(file_path, handle_style_error) elif basename == 'CSSProperties.json': checker = JSONCSSPropertiesChecker(file_path, handle_style_error) else: checker = JSONChecker(file_path, handle_style_error) elif file_type == FileType.PYTHON: python3_paths = ['Tools/resultsdbpy'] for partial in python3_paths: if file_path.startswith(partial): return Python3Checker(file_path, handle_style_error) if apple_additions(): checker = apple_additions().python_checker(file_path, handle_style_error) else: checker = PythonChecker(file_path, handle_style_error) elif file_type == FileType.XML: checker = XMLChecker(file_path, handle_style_error) elif file_type == FileType.XCODEPROJ: checker = XcodeProjectFileChecker(file_path, handle_style_error) elif file_type == FileType.PNG: checker = PNGChecker(file_path, handle_style_error) elif file_type == FileType.CMAKE: checker = CMakeChecker(file_path, handle_style_error) elif file_type == FileType.TEXT: basename = os.path.basename(file_path) if basename == 'TestExpectations': checker = TestExpectationsChecker(file_path, handle_style_error) elif file_path.endswith('.messages.in'): checker = MessagesInChecker(file_path, handle_style_error) else: checker = TextChecker(file_path, handle_style_error) elif file_type == FileType.WATCHLIST: checker = WatchListChecker(file_path, handle_style_error) elif file_type == FileType.FEATUREDEFINES: checker = FeatureDefinesChecker(file_path, handle_style_error) elif file_type == FileType.SDKVARIANT: checker = SDKVariantChecker(file_path, handle_style_error) else: raise ValueError('Invalid file type "%(file_type)s": the only valid file types ' "are %(NONE)s, %(CPP)s, and %(TEXT)s." % {"file_type": file_type, "NONE": FileType.NONE, "CPP": FileType.CPP, "TEXT": FileType.TEXT}) return checker
class IOSSimulatorPort(IOSPort): port_name = "ios-simulator" FUTURE_VERSION = 'future' ARCHITECTURES = ['x86_64', 'i386'] DEFAULT_ARCHITECTURE = 'x86_64' DEVICE_MANAGER = SimulatedDeviceManager DEFAULT_DEVICE_TYPES = [ DeviceType(hardware_family='iPhone', hardware_type='SE'), DeviceType(hardware_family='iPad', hardware_type='(5th generation)'), DeviceType(hardware_family='iPhone', hardware_type='7'), ] SDK = apple_additions().get_sdk( 'iphonesimulator') if apple_additions() else 'iphonesimulator' @staticmethod def _version_from_name(name): if len(name.split('-')) > 2 and name.split('-')[2].isdigit(): return Version.from_string(name.split('-')[2]) return None @memoized def device_version(self): if self.get_option('version'): return Version.from_string(self.get_option('version')) return IOSSimulatorPort._version_from_name( self._name) if IOSSimulatorPort._version_from_name( self._name) else self.host.platform.xcode_sdk_version( 'iphonesimulator') def clean_up_test_run(self): super(IOSSimulatorPort, self).clean_up_test_run() _log.debug("clean_up_test_run") SimulatedDeviceManager.tear_down(self.host) def environment_for_api_tests(self): no_prefix = super(IOSSimulatorPort, self).environment_for_api_tests() result = {} SIMCTL_ENV_PREFIX = 'SIMCTL_CHILD_' for value in no_prefix: if not value.startswith(SIMCTL_ENV_PREFIX): result[SIMCTL_ENV_PREFIX + value] = no_prefix[value] else: result[value] = no_prefix[value] return result def setup_environ_for_server(self, server_name=None): _log.debug("setup_environ_for_server") env = super(IOSSimulatorPort, self).setup_environ_for_server(server_name) if server_name == self.driver_name(): if self.get_option('leaks'): env['MallocStackLogging'] = '1' env['__XPC_MallocStackLogging'] = '1' env['MallocScribble'] = '1' env['__XPC_MallocScribble'] = '1' return env def operating_system(self): return 'ios-simulator' def reset_preferences(self): _log.debug("reset_preferences") SimulatedDeviceManager.tear_down(self.host) @property @memoized def developer_dir(self): return self._executive.run_command(['xcode-select', '--print-path']).rstrip() def logging_patterns_to_strip(self): return [] def stderr_patterns_to_strip(self): return []
def _apple_baseline_path(self, platform): return self._filesystem.join(apple_additions().layout_tests_path(), platform)
def _driver_class(self): if apple_additions(): return apple_additions().ios_device_driver() return super(IOSDevicePort, self)._driver_class()
def path_to_crash_logs(self): if not apple_additions(): raise RuntimeError(self.NO_ON_DEVICE_TESTING) return apple_additions().ios_crash_log_path()
def default_child_processes(self): if apple_additions(): return apple_additions().ios_device_default_child_processes(self) return 1
def _device_for_worker_number_map(self): if not apple_additions(): raise RuntimeError(self.NO_ON_DEVICE_TESTING) return apple_additions().ios_device_for_worker_number_map(self)
def clean_up_test_run(self): super(IOSDevicePort, self).clean_up_test_run() apple_additions().ios_device_clean_up_test_run(self, self._path_to_driver(), self._build_path())
class IOSDevicePort(IOSPort): port_name = 'ios-device' ARCHITECTURES = ['armv7', 'armv7s', 'arm64'] DEFAULT_ARCHITECTURE = 'arm64' VERSION_FALLBACK_ORDER = ['ios-7', 'ios-8', 'ios-9', 'ios-10'] SDK = apple_additions().ios_device_SDK() if apple_additions( ) else 'iphoneos' NO_ON_DEVICE_TESTING = 'On-device testing is not supported on this machine' @memoized def default_child_processes(self): if apple_additions(): return apple_additions().ios_device_default_child_processes(self) return 1 def using_multiple_devices(self): return True def _device_for_worker_number_map(self): if not apple_additions(): raise RuntimeError(self.NO_ON_DEVICE_TESTING) return apple_additions().ios_device_for_worker_number_map(self) def _driver_class(self): if apple_additions(): return apple_additions().ios_device_driver() return super(IOSDevicePort, self)._driver_class() @classmethod def determine_full_port_name(cls, host, options, port_name): if port_name == cls.port_name: iphoneos_sdk_version = host.platform.xcode_sdk_version(cls.SDK) if not iphoneos_sdk_version: raise Exception("Please install the iOS SDK.") major_version_number = iphoneos_sdk_version.split('.')[0] port_name = port_name + '-' + major_version_number return port_name def path_to_crash_logs(self): if not apple_additions(): raise RuntimeError(self.NO_ON_DEVICE_TESTING) return apple_additions().ios_crash_log_path() def _look_for_all_crash_logs_in_log_dir(self, newer_than): log_list = {} for device in self._device_for_worker_number_map(): crash_log = CrashLogs( device, self.path_to_crash_logs(), crash_logs_to_skip=self._crash_logs_to_skip_for_host.get( device, [])) log_list.update( crash_log.find_all_logs(include_errors=True, newer_than=newer_than)) return log_list def _get_crash_log(self, name, pid, stdout, stderr, newer_than, time_fn=None, sleep_fn=None, wait_for_log=True, target_host=None): if target_host: return super(IOSDevicePort, self)._get_crash_log(name, pid, stdout, stderr, newer_than, time_fn=time_fn, sleep_fn=sleep_fn, wait_for_log=wait_for_log, target_host=target_host) # We need to search every device since one was not specified. for device in self._device_for_worker_number_map(): stderr_out, crashlog = super(IOSDevicePort, self)._get_crash_log( name, pid, stdout, stderr, newer_than, time_fn=time_fn, sleep_fn=sleep_fn, wait_for_log=False, target_host=device) if crashlog: return (stderr, crashlog) return (stderr, None) @memoized def ios_version(self): if not apple_additions(): raise RuntimeError(self.NO_ON_DEVICE_TESTING) # FIXME: We should replace --runtime with something which makes sense for both Simulator and Device # https://bugs.webkit.org/show_bug.cgi?id=173775 if len(self._device_for_worker_number_map()) == 0: raise RuntimeError('No devices are available') version = None for device in self._device_for_worker_number_map(): if not version: version = device.platform.os_version else: if device.platform.os_version != version: raise RuntimeError( 'Multiple connected devices have different iOS versions' ) return version # FIXME: These need device implementations <rdar://problem/30497991>. def check_for_leaks(self, process_name, process_pid): pass # 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 []) def operating_system(self): return 'ios-device' def _create_devices(self, device_class): if not apple_additions(): raise RuntimeError(self.NO_ON_DEVICE_TESTING) if not self._device_for_worker_number_map(): raise RuntimeError('No devices are available for testing') if self.default_child_processes() < self.child_processes(): raise RuntimeError( 'Not enought connected devices for {} processes'.format( self.child_processes())) def clean_up_test_run(self): super(IOSDevicePort, self).clean_up_test_run() apple_additions().ios_device_clean_up_test_run(self, self._path_to_driver(), self._build_path())
def default_baseline_search_path(self): wk_string = 'wk1' if self.get_option('webkit_test_runner'): wk_string = 'wk2' # If we don't have a specified version, that means we using the port without an SDK. # This usually means we're doing some type of testing.In this case, don't add version fallbacks expectations = [] if apple_additions() and self.ios_version(): apple_name = VersionNameMap.map(self.host.platform).to_name( self.ios_version(), platform=IOSPort.port_name, table='internal').lower().replace(' ', '') else: apple_name = None if self.ios_version(): if apple_name: expectations.append( self._apple_baseline_path('{}-{}-{}'.format( self.port_name, apple_name, wk_string))) expectations.append( self._webkit_baseline_path('{}-{}-{}'.format( self.port_name, self.ios_version().major, wk_string))) if apple_name: expectations.append( self._apple_baseline_path('{}-{}'.format( self.port_name, apple_name))) expectations.append( self._webkit_baseline_path('{}-{}'.format( self.port_name, self.ios_version().major))) if apple_additions(): expectations.append( self._apple_baseline_path('{}-{}'.format( self.port_name, wk_string))) expectations.append( self._webkit_baseline_path('{}-{}'.format(self.port_name, wk_string))) if apple_additions(): expectations.append(self._apple_baseline_path(self.port_name)) expectations.append(self._webkit_baseline_path(self.port_name)) if self.ios_version(): if apple_name: expectations.append( self._apple_baseline_path('{}-{}'.format( IOSPort.port_name, apple_name))) expectations.append( self._webkit_baseline_path('{}-{}'.format( IOSPort.port_name, self.ios_version().major))) if apple_additions(): expectations.append( self._apple_baseline_path('{}-{}'.format( IOSPort.port_name, wk_string))) expectations.append( self._webkit_baseline_path('{}-{}'.format(IOSPort.port_name, wk_string))) if apple_additions(): expectations.append(self._apple_baseline_path(IOSPort.port_name)) expectations.append(self._webkit_baseline_path(IOSPort.port_name)) if self.get_option('webkit_test_runner'): expectations.append(self._webkit_baseline_path('wk2')) return expectations
def default_baseline_search_path(self, device_type=None): wk_string = 'wk1' if self.get_option('webkit_test_runner'): wk_string = 'wk2' versions_to_fallback = [] if self.device_version().major == self.CURRENT_VERSION.major: versions_to_fallback = [self.CURRENT_VERSION] elif self.device_version(): temp_version = Version(self.device_version().major) while temp_version != self.CURRENT_VERSION: versions_to_fallback.append( Version.from_iterable(temp_version)) if temp_version < self.CURRENT_VERSION: temp_version.major += 1 else: temp_version.major -= 1 runtime_type = 'simulator' if 'simulator' in self.SDK else 'device' hardware_family = device_type.hardware_family.lower( ) if device_type and device_type.hardware_family else None hardware_type = device_type.hardware_type.lower( ) if device_type and device_type.hardware_type else None base_variants = [] if hardware_family and hardware_type: base_variants.append(u'{}-{}-{}'.format(hardware_family, hardware_type, runtime_type)) if hardware_family: base_variants.append(u'{}-{}'.format(hardware_family, runtime_type)) base_variants.append(u'{}-{}'.format(IOSPort.port_name, runtime_type)) if hardware_family and hardware_type: base_variants.append(u'{}-{}'.format(hardware_family, hardware_type)) if hardware_family: base_variants.append(hardware_family) base_variants.append(IOSPort.port_name) expectations = [] for variant in base_variants: for version in versions_to_fallback: apple_name = None if apple_additions(): apple_name = VersionNameMap.map( self.host.platform).to_name(version, platform=IOSPort.port_name, table=INTERNAL_TABLE) if apple_name: expectations.append( self._apple_baseline_path(u'{}-{}-{}'.format( variant, apple_name.lower().replace(' ', ''), wk_string))) expectations.append( self._webkit_baseline_path(u'{}-{}-{}'.format( variant, version.major, wk_string))) if apple_name: expectations.append( self._apple_baseline_path(u'{}-{}'.format( variant, apple_name.lower().replace(' ', '')))) expectations.append( self._webkit_baseline_path(u'{}-{}'.format( variant, version.major))) if apple_additions(): expectations.append( self._apple_baseline_path(u'{}-{}'.format( variant, wk_string))) expectations.append( self._webkit_baseline_path(u'{}-{}'.format(variant, wk_string))) if apple_additions(): expectations.append(self._apple_baseline_path(variant)) expectations.append(self._webkit_baseline_path(variant)) if self.get_option('webkit_test_runner'): expectations.append(self._webkit_baseline_path('wk2')) return expectations
def _driver_class(self): if apple_additions(): return apple_additions().device_driver() return super(WatchDevicePort, self)._driver_class()
class WatchDevicePort(WatchPort): port_name = 'watchos-device' ARCHITECTURES = ['armv7k', 'arm64e', 'arm64_32'] DEFAULT_ARCHITECTURE = 'armv7k' SDK = apple_additions().get_sdk( 'watchos') if apple_additions() else 'watchos' DEVICE_MANAGER = apple_additions().device_manager() if apple_additions( ) else None NO_ON_DEVICE_TESTING = 'On-device testing is not supported in this configuration' NO_DEVICE_MANAGER = NO_ON_DEVICE_TESTING def _driver_class(self): if apple_additions(): return apple_additions().device_driver() return super(WatchDevicePort, self)._driver_class() @classmethod def determine_full_port_name(cls, host, options, port_name): if port_name == cls.port_name: watchos_sdk_version = host.platform.xcode_sdk_version(cls.SDK) if not watchos_sdk_version: raise Exception("Please install the watchOS SDK.") port_name = port_name + '-' + str(watchos_sdk_version.major) return port_name def path_to_crash_logs(self): if not apple_additions(): raise RuntimeError(self.NO_ON_DEVICE_TESTING) return apple_additions().device_crash_log_path() def _look_for_all_crash_logs_in_log_dir(self, newer_than): log_list = {} for device in self.devices(): crash_log = CrashLogs( device, self.path_to_crash_logs(), crash_logs_to_skip=self._crash_logs_to_skip_for_host.get( device, [])) log_list.update(crash_log.find_all_logs(newer_than=newer_than)) return log_list def _get_crash_log(self, name, pid, stdout, stderr, newer_than, time_fn=None, sleep_fn=None, wait_for_log=True, target_host=None): if target_host: return super(WatchDevicePort, self)._get_crash_log(name, pid, stdout, stderr, newer_than, time_fn=time_fn, sleep_fn=sleep_fn, wait_for_log=wait_for_log, target_host=target_host) # We need to search every device since one was not specified. for device in self.devices(): stderr_out, crashlog = super(WatchDevicePort, self)._get_crash_log( name, pid, stdout, stderr, newer_than, time_fn=time_fn, sleep_fn=sleep_fn, wait_for_log=False, target_host=device) if crashlog: return (stderr, crashlog) return (stderr, None) @memoized def device_version(self): if self.get_option('version'): return Version.from_string(self.get_option('version')) if not self.DEVICE_MANAGER: raise RuntimeError(self.NO_ON_DEVICE_TESTING) if not self.DEVICE_MANAGER.available_devices(host=self.host): raise RuntimeError('No devices are available') version = None for device in self.DEVICE_MANAGER.available_devices(host=self.host): if not device.platform.is_watchos(): continue if not version: version = device.platform.os_version else: if device.platform.os_version != version: raise RuntimeError( 'Multiple connected devices have different watchOS versions' ) return version # FIXME: These need device implementations <rdar://problem/30497991>. def check_for_leaks(self, process_name, process_id): pass def operating_system(self): return 'watchos-device' def clean_up_test_run(self): super(WatchDevicePort, self).clean_up_test_run() apple_additions().device_clean_up_test_run(self, self._path_to_driver(), self._build_path())
class IOSDevicePort(IOSPort): port_name = 'ios-device' ARCHITECTURES = ['armv7', 'armv7s', 'arm64'] DEFAULT_ARCHITECTURE = 'arm64' VERSION_FALLBACK_ORDER = ['ios-7', 'ios-8', 'ios-9', 'ios-10'] SDK = apple_additions().ios_device_SDK() if apple_additions( ) else 'iphoneos' NO_ON_DEVICE_TESTING = 'On-device testing is not supported on this machine' @memoized def default_child_processes(self): if apple_additions(): return apple_additions().ios_device_default_child_processes(self) return 1 def using_multiple_devices(self): return True def _device_for_worker_number_map(self): if not apple_additions(): raise RuntimeError(self.NO_ON_DEVICE_TESTING) return apple_additions().ios_device_for_worker_number_map(self) def _driver_class(self): if apple_additions(): return apple_additions().ios_device_driver() return super(IOSDevicePort, self)._driver_class() @classmethod def determine_full_port_name(cls, host, options, port_name): if port_name == cls.port_name: iphoneos_sdk_version = host.platform.xcode_sdk_version(cls.SDK) if not iphoneos_sdk_version: raise Exception("Please install the iOS SDK.") major_version_number = iphoneos_sdk_version.split('.')[0] port_name = port_name + '-' + major_version_number return port_name # FIXME: These need device implementations <rdar://problem/30497991>. def path_to_crash_logs(self): raise NotImplementedError def check_for_leaks(self, process_name, process_pid): pass def look_for_new_crash_logs(self, crashed_processes, start_time): return {} def look_for_new_samples(self, unresponsive_processes, start_time): return {} def sample_process(self, name, pid, target_host=None): pass # 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 []) def operating_system(self): return 'ios-device' def _get_crash_log(self, name, pid, stdout, stderr, newer_than, time_fn=None, sleep_fn=None, wait_for_log=True): return (stderr, None) def _create_devices(self, device_class): if not apple_additions(): raise RuntimeError(self.NO_ON_DEVICE_TESTING) if not self._device_for_worker_number_map(): raise RuntimeError('No devices are available for testing') if self.default_child_processes() < self.child_processes(): raise RuntimeError( 'Not enought connected devices for {} processes'.format( self.child_processes())) def clean_up_test_run(self): super(IOSDevicePort, self).clean_up_test_run() apple_additions().ios_device_clean_up_test_run(self, self._path_to_driver(), self._build_path())