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, 5, 3) AutoInstall.register(Package('fasteners', Version(0, 15, 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'
'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'
def test_baseline_search_path(self): self._assert_search_path(['win-xp', 'win-vista', 'win-7sp0', 'win-8', 'win-8.1', 'win-win10', 'win', 'mac'], Version.from_name('XP')) self._assert_search_path(['win-vista', 'win-7sp0', 'win-8', 'win-8.1', 'win-win10', 'win', 'mac'], Version.from_name('Vista')) self._assert_search_path(['win-7sp0', 'win-8', 'win-8.1', 'win-win10', 'win', 'mac'], Version.from_name('7sp0')) self._assert_search_path(['win-wk2', 'win-xp', 'win-vista', 'win-7sp0', 'win-8', 'win-8.1', 'win-win10', 'win', 'mac-wk2', 'mac'], Version.from_name('XP'), use_webkit2=True) self._assert_search_path(['win-wk2', 'win-vista', 'win-7sp0', 'win-8', 'win-8.1', 'win-win10', 'win', 'mac-wk2', 'mac'], Version.from_name('Vista'), use_webkit2=True) self._assert_search_path(['win-wk2', 'win-7sp0', 'win-8', 'win-8.1', 'win-win10', 'win', 'mac-wk2', 'mac'], Version.from_name('7sp0'), use_webkit2=True)
def _win_version(self): version = self._win_version_str() match_object = re.search( r'(?P<major>\d+)\.(?P<minor>\d+)\.(?P<build>\d+)', version) assert match_object, 'cmd returned an unexpected version string: ' + version return Version.from_iterable(match_object.groups())
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 _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)
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)))
# logging configuration code. # # We do not execute any version-checking code or logging configuration # code in this file so that callers can opt-in as they want. This also # allows different callers to choose different initialization code, # as necessary. import os import sys 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]))) AutoInstall.register(Package('coverage', Version(5, 2, 1))) AutoInstall.register(Package('selenium', Version(3, 141, 0))) AutoInstall.register(Package('toml', Version(0, 10, 1))) AutoInstall.register(Package('webkitscmpy', Version(0, 0, 1)), local=True)
def _maybe_add_webkitcorepy_path(): # Hopefully we're beside webkitcorepy, otherwise webkitcorepy will need to be installed. libraries_path = os.path.dirname(os.path.dirname(os.path.abspath(os.path.dirname(__file__)))) webkitcorepy_path = os.path.join(libraries_path, 'webkitcorepy') 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, 1, 1) AutoInstall.register(Package('click'), Version(7, 1, 2)) AutoInstall.register(Package('flask'), Version(1, 1, 2)) AutoInstall.register(Package('itsdangerous'), Version(2, 0, 0)) AutoInstall.register(Package('jinja2'), Version(3, 0, 0)) AutoInstall.register(Package('markupsafe'), Version(2, 0, 0)) AutoInstall.register(Package('werkzeug'), Version(1, 0, 1)) name = 'webkitflaskpy'
class WinPort(ApplePort): port_name = "win" VERSION_MIN = Version(5, 1) VERSION_MAX = Version(10) ARCHITECTURES = ['x86', 'x86_64'] DEFAULT_ARCHITECTURE = 'x86_64' CRASH_LOG_PREFIX = "CrashLog" if sys.platform.startswith('win'): POST_MORTEM_DEBUGGER_KEY = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug' WOW64_POST_MORTEM_DEBUGGER_KEY = r'SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug' WINDOWS_ERROR_REPORTING_KEY = r'SOFTWARE\Microsoft\Windows\Windows Error Reporting' WOW64_WINDOWS_ERROR_REPORTING_KEY = r'SOFTWARE\Wow6432Node\Microsoft\Windows\Windows Error Reporting' _HKLM = _winreg.HKEY_LOCAL_MACHINE _HKCU = _winreg.HKEY_CURRENT_USER _REG_DWORD = _winreg.REG_DWORD _REG_SZ = _winreg.REG_SZ else: POST_MORTEM_DEBUGGER_KEY = "/%s/SOFTWARE/Microsoft/Windows NT/CurrentVersion/AeDebug/%s" WOW64_POST_MORTEM_DEBUGGER_KEY = "/%s/SOFTWARE/Wow6432Node/Microsoft/Windows NT/CurrentVersion/AeDebug/%s" WINDOWS_ERROR_REPORTING_KEY = "/%s/SOFTWARE/Microsoft/Windows/Windows Error Reporting/%s" WOW64_WINDOWS_ERROR_REPORTING_KEY = "/%s/SOFTWARE/Wow6432Node/Microsoft/Windows/Windows Error Reporting/%s" _HKLM = "HKLM" _HKCU = "HKCU" _REG_DWORD = "-d" _REG_SZ = "-s" previous_debugger_values = {} previous_wow64_debugger_values = {} previous_error_reporting_values = {} previous_wow64_error_reporting_values = {} def __init__(self, host, port_name, **kwargs): ApplePort.__init__(self, host, port_name, **kwargs) if len(port_name.split('-')) > 1: self._os_version = VersionNameMap.map(host.platform).from_name( port_name.split('-')[1])[1] else: self._os_version = self.host.platform.os_version def do_text_results_differ(self, expected_text, actual_text): # Sanity was restored in WebKitTestRunner, so we don't need this hack there. if not self.get_option('webkit_test_runner'): # Windows does not have an EDITING DELEGATE, so strip those messages to make more tests pass. # It's possible other ports might want this, and if so, this could move down into WebKitPort. delegate_regexp = re.compile("^EDITING DELEGATE: .*?\n", re.MULTILINE) expected_text = delegate_regexp.sub("", expected_text) actual_text = delegate_regexp.sub("", actual_text) return ApplePort.do_text_results_differ(self, expected_text, actual_text) def default_baseline_search_path(self, **kwargs): version_name_map = VersionNameMap.map(self.host.platform) if self._os_version < self.VERSION_MIN or self._os_version > self.VERSION_MAX: fallback_versions = [self._os_version] if self._os_version else [] else: sorted_versions = sorted( version_name_map.mapping_for_platform( platform=self.port_name).values()) fallback_versions = sorted_versions[sorted_versions. index(self._os_version):] fallback_names = [ 'win-' + version_name_map.to_name( version, platform=self.port_name).lower().replace(' ', '') for version in fallback_versions ] fallback_names.append('win') # FIXME: The AppleWin port falls back to AppleMac for some results. Eventually we'll have a shared 'apple' port. if self.get_option('webkit_test_runner'): fallback_names.insert(0, 'win-wk2') fallback_names.append('mac-wk2') # Note we do not add 'wk2' here, even though it's included in _skipped_search_paths(). # FIXME: Perhaps we should get this list from MacPort? fallback_names.append('mac') result = list(map(self._webkit_baseline_path, fallback_names)) if apple_additions() and getattr(apple_additions(), "layout_tests_path", None): result.insert( 0, self._filesystem.join(apple_additions().layout_tests_path(), self.port_name)) return result def setup_environ_for_server(self, server_name=None): env = super(WinPort, self).setup_environ_for_server(server_name) env['XML_CATALOG_FILES'] = '' # work around missing /etc/catalog <rdar://problem/4292995> return env def environment_for_api_tests(self): env = super(WinPort, self).environment_for_api_tests() for variable in ['SYSTEMROOT', 'WEBKIT_LIBRARIES']: self._copy_value_from_environ_if_set(env, variable) return env def operating_system(self): return 'win' def _port_flag_for_scripts(self): if self.architecture() == 'x86_64': return '--64-bit' return None def show_results_html_file(self, results_filename): self._run_script( 'run-safari', [abspath_to_uri(SystemHost().platform, results_filename)]) def _build_path(self, *comps): """Returns the full path to the test driver (DumpRenderTree).""" root_directory = self.get_option('_cached_root') or self.get_option( 'root') if not root_directory: ApplePort._build_path(self, *comps) # Sets option _cached_root binary_directory = 'bin32' if self.architecture() == 'x86_64': binary_directory = 'bin64' root_directory = self._filesystem.join( self.get_option('_cached_root'), binary_directory) self.set_option('_cached_root', root_directory) return self._filesystem.join(root_directory, *comps) def is_cygwin(self): """Return whether current platform is Cygwin or not""" return self.host.platform.is_cygwin() # Note: These are based on the stock XAMPP locations for these files. def _uses_apache(self): return True def _path_to_apache(self): root = os.environ.get('XAMPP_ROOT', 'C:\\xampp') path = self._filesystem.join(root, 'apache', 'bin', 'httpd.exe') if self._filesystem.exists(path): return path _log.error( 'Could not find apache in the expected location. (path=%s)' % path) return None def _path_to_lighttpd(self): return "/usr/sbin/lighttpd" def _path_to_lighttpd_modules(self): return "/usr/lib/lighttpd" def _path_to_lighttpd_php(self): return "/usr/bin/php-cgi" def _path_to_default_image_diff(self): return self._build_path('ImageDiff.exe') API_TEST_BINARY_NAMES = [ 'TestWTF.exe', 'TestWebCore.exe', 'TestWebKitLegacy.exe' ] def path_to_api_test_binaries(self): return { binary.split('.')[0]: self._build_path(binary) for binary in self.API_TEST_BINARY_NAMES } def test_search_path(self, **kwargs): test_fallback_names = [ path for path in self.baseline_search_path() if not path.startswith(self._webkit_baseline_path('mac')) ] return list(map(self._webkit_baseline_path, test_fallback_names)) def _ntsd_location(self): if 'PROGRAMFILES' not in os.environ: return None possible_paths = [ self._filesystem.join(os.environ['PROGRAMFILES'], "Windows Kits", "10", "Debuggers", "x64", "ntsd.exe"), self._filesystem.join(os.environ['PROGRAMFILES'], "Windows Kits", "8.1", "Debuggers", "x64", "ntsd.exe"), self._filesystem.join(os.environ['PROGRAMFILES'], "Windows Kits", "8.0", "Debuggers", "x64", "ntsd.exe") ] if self.architecture() == 'x86_64': possible_paths.append( self._filesystem.join( "{0} (x86)".format(os.environ['PROGRAMFILES']), "Windows Kits", "10", "Debuggers", "x64", "ntsd.exe")) possible_paths.append( self._filesystem.join( "{0} (x86)".format(os.environ['PROGRAMFILES']), "Windows Kits", "8.1", "Debuggers", "x64", "ntsd.exe")) possible_paths.append( self._filesystem.join( "{0} (x86)".format(os.environ['PROGRAMFILES']), "Windows Kits", "8.0", "Debuggers", "x64", "ntsd.exe")) possible_paths.append( self._filesystem.join( "{0} (x86)".format(os.environ['PROGRAMFILES']), "Debugging Tools for Windows (x64)", "ntsd.exe")) else: possible_paths.append( self._filesystem.join(os.environ['PROGRAMFILES'], "Debugging Tools for Windows (x86)", "ntsd.exe")) possible_paths.append( self._filesystem.join(os.environ['SYSTEMROOT'], "system32", "ntsd.exe")) if 'ProgramW6432' in os.environ: possible_paths.append( self._filesystem.join(os.environ['ProgramW6432'], "Windows Kits", "10", "Debuggers", "x64", "ntsd.exe")) possible_paths.append( self._filesystem.join(os.environ['ProgramW6432'], "Windows Kits", "8.1", "Debuggers", "x64", "ntsd.exe")) possible_paths.append( self._filesystem.join(os.environ['ProgramW6432'], "Windows Kits", "8.0", "Debuggers", "x64", "ntsd.exe")) possible_paths.append( self._filesystem.join(os.environ['ProgramW6432'], "Debugging Tools for Windows (x64)", "ntsd.exe")) for path in possible_paths: expanded_path = self._filesystem.expanduser(path) _log.debug("Considering '%s'" % expanded_path) if self._filesystem.exists(expanded_path): _log.debug("Using ntsd located in '%s'" % path) return expanded_path return None def create_debugger_command_file(self): debugger_temp_directory = str(self._filesystem.mkdtemp()) command_file = self._filesystem.join(debugger_temp_directory, "debugger-commands.txt") commands = ''.join([ '.logopen /t "%s\\%s.txt"\n' % (cygpath(self.results_directory()), self.CRASH_LOG_PREFIX), '.srcpath "%s"\n' % cygpath(self._webkit_finder.webkit_base()), '!analyze -vv\n', '~*kpn\n', 'q\n' ]) self._filesystem.write_text_file(command_file, commands) return command_file def read_registry_value(self, reg_path, arch, root, key): if sys.platform.startswith('win'): _log.debug("Trying to read %s\\%s" % (reg_path, key)) try: registry_key = _winreg.OpenKey(root, reg_path) value = _winreg.QueryValueEx(registry_key, key) _winreg.CloseKey(registry_key) except WindowsError as ex: _log.debug("Unable to read %s\\%s: %s" % (reg_path, key, str(ex))) return ['', self._REG_SZ] else: registry_key = reg_path % (root, key) _log.debug("Reading %s" % (registry_key)) read_registry_command = ["regtool", arch, "get", registry_key] int_value = self._executive.run_command(read_registry_command, ignore_errors=True) # regtool doesn't return the type of the entry, so need this ugly hack: if reg_path in (self.WINDOWS_ERROR_REPORTING_KEY, self.WOW64_WINDOWS_ERROR_REPORTING_KEY): _log.debug("I got {0}".format(int_value)) try: value = [int(int_value), self._REG_DWORD] except: value = [0, self._REG_DWORD] else: value = [int_value.rstrip(), self._REG_SZ] _log.debug("I got back ({0}) of type ({1})".format(value[0], value[1])) return value def write_registry_value(self, reg_path, arch, root, key, regType, value): if sys.platform.startswith('win'): _log.debug("Trying to write %s\\%s = %s" % (reg_path, key, value)) try: registry_key = _winreg.OpenKey(root, reg_path, 0, _winreg.KEY_WRITE) except WindowsError: try: _log.debug("Key doesn't exist -- must create it.") registry_key = _winreg.CreateKeyEx(root, reg_path, 0, _winreg.KEY_WRITE) except WindowsError as ex: _log.error( "Error setting (%s) %s\key: %s to value: %s. Error=%s." % (arch, root, key, value, str(ex))) _log.error( "You many need to adjust permissions on the %s\\%s key." % (reg_path, key)) return False _log.debug("Writing {0} of type {1} to {2}\\{3}".format( value, regType, registry_key, key)) _winreg.SetValueEx(registry_key, key, 0, regType, value) _winreg.CloseKey(registry_key) else: registry_key = reg_path % (root, key) _log.debug("Writing to %s" % registry_key) set_reg_value_command = [ "regtool", arch, "set", regType, str(registry_key), str(value) ] rc = self._executive.run_command(set_reg_value_command, return_exit_code=True) if rc == 2: add_reg_value_command = [ "regtool", arch, "add", regType, str(registry_key) ] rc = self._executive.run_command(add_reg_value_command, return_exit_code=True) if rc == 0: rc = self._executive.run_command(set_reg_value_command, return_exit_code=True) if rc: _log.warn( "Error setting (%s) %s\key: %s to value: %s. Error=%s." % (arch, root, key, value, str(rc))) _log.warn( "You many need to adjust permissions on the %s key." % registry_key) return False # On Windows Vista/7 with UAC enabled, regtool will fail to modify the registry, but will still # return a successful exit code. So we double-check here that the value we tried to write to the # registry was really written. check_value = self.read_registry_value(reg_path, arch, root, key) if check_value[0] != value or check_value[1] != regType: _log.warn( "Reg update reported success, but value of key %s did not change." % key) _log.warn("Wanted to set it to ({0}, {1}), but got {2})".format( value, regType, check_value)) _log.warn( "You many need to adjust permissions on the %s\\%s key." % (reg_path, key)) return False return True def setup_crash_log_saving(self): if '_NT_SYMBOL_PATH' not in os.environ: _log.warning( "The _NT_SYMBOL_PATH environment variable is not set. Using Microsoft Symbol Server." ) os.environ[ '_NT_SYMBOL_PATH'] = 'SRV*http://msdl.microsoft.com/download/symbols' # Add build path to symbol path os.environ['_NT_SYMBOL_PATH'] += ";" + self._build_path() ntsd_path = self._ntsd_location() if not ntsd_path: _log.warning("Can't find ntsd.exe. Crash logs will not be saved.") return None # If we used -c (instead of -cf) we could pass the commands directly on the command line. But # when the commands include multiple quoted paths (e.g., for .logopen and .srcpath), Windows # fails to invoke the post-mortem debugger at all (perhaps due to a bug in Windows's command # line parsing). So we save the commands to a file instead and tell the debugger to execute them # using -cf. command_file = self.create_debugger_command_file() if not command_file: return None debugger_options = '"{0}" -p %ld -e %ld -g -noio -lines -cf "{1}"'.format( cygpath(ntsd_path), cygpath(command_file)) registry_settings = { 'Debugger': [debugger_options, self._REG_SZ], 'Auto': ["1", self._REG_SZ] } for key, value in registry_settings.items(): for arch in ["--wow32", "--wow64"]: self.previous_debugger_values[( arch, self._HKLM, key)] = self.read_registry_value( self.POST_MORTEM_DEBUGGER_KEY, arch, self._HKLM, key) self.previous_wow64_debugger_values[( arch, self._HKLM, key)] = self.read_registry_value( self.WOW64_POST_MORTEM_DEBUGGER_KEY, arch, self._HKLM, key) self.write_registry_value(self.POST_MORTEM_DEBUGGER_KEY, arch, self._HKLM, key, value[1], value[0]) self.write_registry_value(self.WOW64_POST_MORTEM_DEBUGGER_KEY, arch, self._HKLM, key, value[1], value[0]) def restore_crash_log_saving(self): for key, value in self.previous_debugger_values.items(): self.write_registry_value(self.POST_MORTEM_DEBUGGER_KEY, key[0], key[1], key[2], value[1], value[0]) for key, value in self.previous_wow64_debugger_values.items(): self.write_registry_value(self.WOW64_POST_MORTEM_DEBUGGER_KEY, key[0], key[1], key[2], value[1], value[0]) def prevent_error_dialogs(self): registry_settings = { 'DontShowUI': [1, self._REG_DWORD], 'Disabled': [1, self._REG_DWORD] } for key, value in registry_settings.items(): for root in [self._HKLM, self._HKCU]: for arch in ["--wow32", "--wow64"]: self.previous_error_reporting_values[( arch, root, key)] = self.read_registry_value( self.WINDOWS_ERROR_REPORTING_KEY, arch, root, key) self.previous_wow64_error_reporting_values[( arch, root, key)] = self.read_registry_value( self.WOW64_WINDOWS_ERROR_REPORTING_KEY, arch, root, key) self.write_registry_value(self.WINDOWS_ERROR_REPORTING_KEY, arch, root, key, value[1], value[0]) self.write_registry_value( self.WOW64_WINDOWS_ERROR_REPORTING_KEY, arch, root, key, value[1], value[0]) def allow_error_dialogs(self): for key, value in self.previous_error_reporting_values.items(): self.write_registry_value(self.WINDOWS_ERROR_REPORTING_KEY, key[0], key[1], key[2], value[1], value[0]) for key, value in self.previous_wow64_error_reporting_values.items(): self.write_registry_value(self.WOW64_WINDOWS_ERROR_REPORTING_KEY, key[0], key[1], key[2], value[1], value[0]) def delete_sem_locks(self): os.system("rm -rf /dev/shm/sem.*") def delete_preference_files(self): try: preferences_files = self._filesystem.join( os.environ['APPDATA'], "Apple Computer/Preferences", "com.apple.DumpRenderTree*") filelist = glob.glob(preferences_files) for file in filelist: self._filesystem.remove(file) except: _log.warn("Failed to delete preference files.") 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_type) def clean_up_test_run(self): self.allow_error_dialogs() self.restore_crash_log_saving() super(WinPort, self).clean_up_test_run() def path_to_crash_logs(self): return self.results_directory() def _get_crash_log(self, name, pid, stdout, stderr, newer_than, time_fn=None, sleep_fn=None, wait_for_log=True, target_host=None): # Note that we do slow-spin here and wait, since it appears the time # ReportCrash takes to actually write and flush the file varies when there are # lots of simultaneous crashes going on. # FIXME: Should most of this be moved into CrashLogs()? time_fn = time_fn or time.time sleep_fn = sleep_fn or time.sleep crash_log = '' crash_logs = CrashLogs( target_host or self.host, self.path_to_crash_logs(), crash_logs_to_skip=self._crash_logs_to_skip_for_host.get( target_host or self.host, [])) now = time_fn() # FIXME: delete this after we're sure this code is working ... _log.debug('looking for crash log for %s:%s' % (name, str(pid))) deadline = now + 5 * int(self.get_option('child_processes', 1)) while not crash_log and now <= deadline: crash_log = crash_logs.find_newest_log(name, pid, include_errors=True, newer_than=newer_than) if not wait_for_log: break if not crash_log or not [ line for line in crash_log.splitlines() if line.startswith('quit:') ]: sleep_fn(0.1) now = time_fn() if not crash_log: return (stderr, None) return (stderr, crash_log) def look_for_new_crash_logs(self, crashed_processes, start_time): """Since crash logs can take a long time to be written out if the system is under stress do a second pass at the end of the test run. crashes: test_name -> pid, process_name tuple of crashed process start_time: time the tests started at. We're looking for crash logs after that time. """ crash_logs = {} for (test_name, process_name, pid) in crashed_processes: # Passing None for output. This is a second pass after the test finished so # if the output had any logging we would have already collected it. crash_log = self._get_crash_log(process_name, pid, None, None, start_time, wait_for_log=False)[1] if crash_log: crash_logs[test_name] = crash_log return crash_logs def check_httpd(self): if not super(WinPort, self).check_httpd(): return False path = self._path_to_apache() if not path: return False # To launch Apache as a daemon, service installation is required. exit_code = self._executive.run_command([path, '-k', 'install', '-T'], return_exit_code=True) # 0=success, 2=already installed, 720005=permission error, etc. if exit_code not in (0, 2): _log.error( 'Could not install httpd as a service. Perhaps you forgot to run as adminstrator? (exit code={})' .format(exit_code)) return False return True
class MacTest(darwin_testcase.DarwinTest): os_name = 'mac' os_version = Version.from_name('Lion') port_name = 'mac-lion' port_maker = MacPort # 2 minor versions from the current version should always be a future version. FUTURE_VERSION = Version.from_iterable(MacPort.CURRENT_VERSION) FUTURE_VERSION.minor += 2 def test_version(self): port = self.make_port() self.assertIsNotNone(port.version_name()) def test_versions(self): # Note: these tests don't need to be exhaustive as long as we get path coverage. self.assert_name('mac', 'snowleopard', 'mac-snowleopard') self.assert_name('mac-snowleopard', 'leopard', 'mac-snowleopard') self.assert_name('mac-snowleopard', 'lion', 'mac-snowleopard') self.assert_name('mac', 'lion', 'mac-lion') self.assert_name('mac-lion', 'lion', 'mac-lion') self.assert_name('mac', 'mountainlion', 'mac-mountainlion') self.assert_name('mac-mountainlion', 'lion', 'mac-mountainlion') self.assert_name('mac', 'mavericks', 'mac-mavericks') self.assert_name('mac-mavericks', 'mountainlion', 'mac-mavericks') self.assert_name('mac', 'yosemite', 'mac-yosemite') self.assert_name('mac-yosemite', 'mavericks', 'mac-yosemite') self.assert_name('mac', 'elcapitan', 'mac-elcapitan') self.assert_name('mac-elcapitan', 'mavericks', 'mac-elcapitan') self.assert_name('mac-elcapitan', 'yosemite', 'mac-elcapitan') self.assert_name('mac', 'sierra', 'mac-sierra') self.assert_name('mac-sierra', 'yosemite', 'mac-sierra') self.assert_name('mac-sierra', 'elcapitan', 'mac-sierra') self.assert_name('mac', 'highsierra', 'mac-highsierra') self.assert_name('mac-highsierra', 'elcapitan', 'mac-highsierra') self.assert_name('mac-highsierra', 'sierra', 'mac-highsierra') self.assert_name('mac', 'mojave', 'mac-mojave') self.assert_name('mac-mojave', 'sierra', 'mac-mojave') self.assert_name('mac-mojave', 'highsierra', 'mac-mojave') self.assertRaises(AssertionError, self.assert_name, 'mac-tiger', 'leopard', 'mac-leopard') def test_setup_environ_for_server(self): port = self.make_port( options=MockOptions(leaks=True, guard_malloc=True)) env = port.setup_environ_for_server(port.driver_name()) self.assertEqual(env['MallocStackLogging'], '1') self.assertEqual(env['MallocScribble'], '1') self.assertEqual( env['DYLD_INSERT_LIBRARIES'], '/usr/lib/libgmalloc.dylib:/mock-build/libWebCoreTestShim.dylib') def test_show_results_html_file(self): port = self.make_port() # Delay setting a should_log executive to avoid logging from MacPort.__init__. port._executive = MockExecutive(should_log=True) expected_logs = "MOCK popen: ['Tools/Scripts/run-safari', '--release', '--no-saved-state', '-NSOpen', 'test.html'], cwd=/mock-checkout\n" OutputCapture().assert_outputs(self, port.show_results_html_file, ["test.html"], expected_logs=expected_logs) def test_operating_system(self): self.assertEqual('mac', self.make_port().operating_system()) def test_default_child_processes(self): port = self.make_port(port_name='mac-lion') # MockPlatformInfo only has 2 mock cores. The important part is that 2 > 1. self.assertEqual(port.default_child_processes(), 2) bytes_for_drt = 200 * 1024 * 1024 port.host.platform.total_bytes_memory = lambda: bytes_for_drt expected_logs = "This machine could support 2 child processes, but only has enough memory for 1.\n" child_processes = OutputCapture().assert_outputs( self, port.default_child_processes, (), expected_logs=expected_logs) self.assertEqual(child_processes, 1) # Make sure that we always use one process, even if we don't have the memory for it. port.host.platform.total_bytes_memory = lambda: bytes_for_drt - 1 expected_logs = "This machine could support 2 child processes, but only has enough memory for 1.\n" child_processes = OutputCapture().assert_outputs( self, port.default_child_processes, (), expected_logs=expected_logs) self.assertEqual(child_processes, 1) def test_32bit(self): port = self.make_port(options=MockOptions(architecture='x86')) def run_script(script, args=None, env=None): self.args = args port._run_script = run_script self.assertEqual(port.architecture(), 'x86') port._build_driver() self.assertEqual(self.args, ['ARCHS=i386']) def test_64bit(self): port = self.make_port(options=MockOptions(architecture='x86_64')) self.assertEqual(port.architecture(), 'x86_64') def run_script(script, args=None, env=None): self.args = args port._run_script = run_script port._build_driver() self.assertEqual(self.args, ['ARCHS=x86_64']) def test_arm(self): port = self.make_port(options=MockOptions(architecture='arm64e')) self.assertEqual(port.architecture(), 'arm64') def run_script(script, args=None, env=None): self.args = args port._run_script = run_script port._build_driver() self.assertEqual(self.args, ['ARCHS=arm64']) def test_default(self): port = self.make_port() self.assertEqual(port.architecture(), port.host.platform.architecture()) def run_script(script, args=None, env=None): self.args = args port._run_script = run_script port._build_driver() self.assertEqual( self.args, ['ARCHS={}'.format(port.host.platform.architecture())]) def test_sdk_name(self): port = self.make_port() self.assertEqual(port.SDK, 'macosx') def test_xcrun(self): def throwing_run_command(args): print(args) raise ScriptError("MOCK script error") port = self.make_port() port._executive = MockExecutive2(run_command_fn=throwing_run_command) expected_stdout = "['xcrun', '--sdk', 'macosx', '-find', 'test']\n" OutputCapture().assert_outputs(self, port.xcrun_find, args=['test', 'falling'], expected_stdout=expected_stdout) def test_layout_test_searchpath_with_apple_additions(self): with port_testcase.bind_mock_apple_additions(): search_path = self.make_port().default_baseline_search_path() self.assertEqual(search_path[0], '/additional_testing_path/mac-add-lion-wk1') self.assertEqual(search_path[1], '/mock-checkout/LayoutTests/platform/mac-lion-wk1') self.assertEqual(search_path[2], '/additional_testing_path/mac-add-lion') self.assertEqual(search_path[3], '/mock-checkout/LayoutTests/platform/mac-lion') self.assertEqual(search_path[4], '/additional_testing_path/mac-add-mountainlion-wk1') self.assertEqual( search_path[5], '/mock-checkout/LayoutTests/platform/mac-mountainlion-wk1') def test_big_sur_baseline_search_path(self): search_path = self.make_port( port_name='macos-big-sur').default_baseline_search_path() self.assertEqual( search_path[0], '/mock-checkout/LayoutTests/platform/mac-catalina-wk1') self.assertEqual(search_path[1], '/mock-checkout/LayoutTests/platform/mac-catalina') self.assertEqual(search_path[2], '/mock-checkout/LayoutTests/platform/mac-wk1') self.assertEqual(search_path[3], '/mock-checkout/LayoutTests/platform/mac') def test_factory_with_future_version(self): port = self.make_port(options=MockOptions(webkit_test_runner=True), os_version=MacTest.FUTURE_VERSION, os_name='mac', port_name='mac') self.assertEqual(port.driver_name(), 'WebKitTestRunner') self.assertEqual( port.version_name(), VersionNameMap().to_name(MacPort.CURRENT_VERSION, platform=MacPort.port_name)) port = self.make_port(options=MockOptions(webkit_test_runner=False), os_version=MacTest.FUTURE_VERSION, os_name='mac', port_name='mac') self.assertEqual(port.driver_name(), 'DumpRenderTree') self.assertEqual( port.version_name(), VersionNameMap().to_name(MacPort.CURRENT_VERSION, platform=MacPort.port_name)) port = self.make_port(options=MockOptions(webkit_test_runner=False), os_version=MacTest.FUTURE_VERSION, os_name='mac', port_name='mac-wk2') self.assertEqual(port.driver_name(), 'WebKitTestRunner') self.assertEqual( port.version_name(), VersionNameMap().to_name(MacPort.CURRENT_VERSION, platform=MacPort.port_name)) port = self.make_port(options=MockOptions(webkit_test_runner=True), os_version=MacTest.FUTURE_VERSION, os_name='mac', port_name='mac-wk2') self.assertEqual(port.driver_name(), 'WebKitTestRunner') self.assertEqual( port.version_name(), VersionNameMap().to_name(MacPort.CURRENT_VERSION, platform=MacPort.port_name)) def test_factory_with_future_version_and_apple_additions(self): with port_testcase.bind_mock_apple_additions(): port = self.make_port(options=MockOptions(webkit_test_runner=True), os_version=MacTest.FUTURE_VERSION, os_name='mac', port_name='mac') self.assertEqual(port.driver_name(), 'WebKitTestRunner') self.assertEqual(port.version_name(), None) port = self.make_port( options=MockOptions(webkit_test_runner=False), os_version=MacTest.FUTURE_VERSION, os_name='mac', port_name='mac') self.assertEqual(port.driver_name(), 'DumpRenderTree') self.assertEqual(port.version_name(), None) port = self.make_port( options=MockOptions(webkit_test_runner=False), os_version=MacTest.FUTURE_VERSION, os_name='mac', port_name='mac-wk2') self.assertEqual(port.driver_name(), 'WebKitTestRunner') self.assertEqual(port.version_name(), None) port = self.make_port(options=MockOptions(webkit_test_runner=True), os_version=MacTest.FUTURE_VERSION, os_name='mac', port_name='mac-wk2') self.assertEqual(port.driver_name(), 'WebKitTestRunner') self.assertEqual(port.version_name(), None) def test_factory_with_portname_version(self): port = self.make_port(options=MockOptions(webkit_test_runner=False), port_name='mac-mountainlion') self.assertEqual(port.driver_name(), 'DumpRenderTree') self.assertEqual(port.version_name(), 'Mountain Lion') port = self.make_port(options=MockOptions(webkit_test_runner=True), port_name='mac-mountainlion') self.assertEqual(port.driver_name(), 'WebKitTestRunner') self.assertEqual(port.version_name(), 'Mountain Lion') port = self.make_port(options=MockOptions(webkit_test_runner=True), port_name='mac-mountainlion-wk2') self.assertEqual(port.driver_name(), 'WebKitTestRunner') self.assertEqual(port.version_name(), 'Mountain Lion') port = self.make_port(options=MockOptions(webkit_test_runner=False), port_name='mac-mountainlion-wk2') self.assertEqual(port.driver_name(), 'WebKitTestRunner') self.assertEqual(port.version_name(), 'Mountain Lion') def test_factory_with_portname_wk2(self): port = self.make_port(options=MockOptions(webkit_test_runner=False), port_name='mac') self.assertEqual(port.driver_name(), 'DumpRenderTree') port = self.make_port(options=MockOptions(webkit_test_runner=True), port_name='mac') self.assertEqual(port.driver_name(), 'WebKitTestRunner') port = self.make_port(options=MockOptions(webkit_test_runner=True), port_name='mac-wk2') self.assertEqual(port.driver_name(), 'WebKitTestRunner') port = self.make_port(options=MockOptions(webkit_test_runner=False), port_name='mac-wk2') self.assertEqual(port.driver_name(), 'WebKitTestRunner') def test_configuration_for_upload(self): port = self.make_port() self.assertEqual( dict( platform='mac', is_simulator=False, architecture='x86_64', version='10.7', version_name='Lion', sdk='17A405', style='release', ), port.configuration_for_upload(), )
def xcode_sdk_version(self, sdk_name): return Version(8, 1)
def xcode_version(self): return Version(8, 0)
def test_unmapped_version(self): self.assertEqual('iPhone running iOS', str(DeviceType.from_string('iPhone', Version(9))))
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'
def test_string(self): self.assertEqual(str(Version(1, 2, 3)), '1.2.3') self.assertEqual(str(Version(1, 2, 0)), '1.2') self.assertEqual(str(Version(1, 2)), '1.2') self.assertEqual(str(Version(0, 0, 3)), '0.0.3')
def svn_version(self): return Version.from_string(self._run_svn(['--version', '--quiet']))
def test_contained_in(self): self.assertTrue(Version(11, 1) in Version(11)) self.assertTrue(Version(11, 1, 2) in Version(11, 1)) self.assertFalse(Version(11) in Version(11, 1)) self.assertFalse(Version(11) in Version(11, 1, 2)) self.assertFalse(Version(11, 1) in Version(11, 1, 2)) self.assertTrue(Version(11) in Version(11)) self.assertTrue(Version(11, 1) in Version(11, 1)) self.assertTrue(Version(11, 1, 2) in Version(11, 1, 2)) self.assertTrue(Version(11) in Version(11, 0)) self.assertTrue(Version(11, 0) in Version(11)) self.assertTrue(Version(11) in Version(11, 0, 0)) self.assertTrue(Version(11, 0, 0) in Version(11)) self.assertTrue(Version(11, 1) in Version(11, 1, 0)) self.assertTrue(Version(11, 1, 0) in Version(11, 1))
def device_version(self): if self.get_option('version'): return Version.from_string(self.get_option('version')) return WatchSimulatorPort._version_from_name(self._name) or self.host.platform.xcode_sdk_version('watchsimulator')
def test_compare_versions(self): self.assertEqual(Version(1, 2, 3), Version(1, 2, 3)) self.assertGreater(Version(1, 2, 4), Version(1, 2, 3)) self.assertGreater(Version(1, 3, 2), Version(1, 2, 3)) self.assertGreater(Version(2, 1, 1), Version(1, 2, 3)) self.assertNotEqual(Version(1, 2, 3), None)
def xcode_version(self): if not self.xcode_sdk_version('macosx'): raise NotImplementedError return Version.from_string( self._executive.run_command(['xcodebuild', '-version']).split()[1])
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 _version_from_name(name): if len(name.split('-')) > 2 and name.split('-')[2].isdigit(): return Version.from_string(name.split('-')[2]) return None
def test_from_tuple(self): v = v = Version.from_iterable((1, 2, 3)) self.assertEqual(v.major, 1) self.assertEqual(v.minor, 2) self.assertEqual(v.tiny, 3)
def __init__(self, runtime_dict): self.build_version = runtime_dict['buildversion'] self.os_variant = runtime_dict['name'].split(' ')[0] self.version = Version.from_string(runtime_dict['version']) self.identifier = runtime_dict['identifier'] self.name = runtime_dict['name']
def test_len(self): self.assertEqual(len(Version(1, 2, 3, 4, 5)), 5) self.assertEqual(len(Version()), 5)
class WinPortTest(port_testcase.PortTestCase): os_name = 'win' os_version = Version.from_name('XP') port_name = 'win-xp' port_maker = WinPort def test_show_results_html_file(self): port = self.make_port() port._executive = MockExecutive(should_log=True) capture = OutputCapture() capture.capture_output() port.show_results_html_file('test.html') _, _, logs = capture.restore_output() # We can't know for sure what path will be produced by cygpath, but we can assert about # everything else. self.assertTrue(logs.startswith("MOCK run_command: ['Tools/Scripts/run-safari', '--release', '")) self.assertTrue(logs.endswith("test.html'], cwd=/mock-checkout\n")) def _assert_search_path(self, expected_search_paths, version, use_webkit2=False): port = self.make_port(port_name='win', os_version=version, options=MockOptions(webkit_test_runner=use_webkit2)) absolute_search_paths = list(map(port._webkit_baseline_path, expected_search_paths)) self.assertEqual(port.baseline_search_path(), absolute_search_paths) def test_baseline_search_path(self): self._assert_search_path(['win-xp', 'win-vista', 'win-7sp0', 'win-8', 'win-8.1', 'win-win10', 'win', 'mac'], Version.from_name('XP')) self._assert_search_path(['win-vista', 'win-7sp0', 'win-8', 'win-8.1', 'win-win10', 'win', 'mac'], Version.from_name('Vista')) self._assert_search_path(['win-7sp0', 'win-8', 'win-8.1', 'win-win10', 'win', 'mac'], Version.from_name('7sp0')) self._assert_search_path(['win-wk2', 'win-xp', 'win-vista', 'win-7sp0', 'win-8', 'win-8.1', 'win-win10', 'win', 'mac-wk2', 'mac'], Version.from_name('XP'), use_webkit2=True) self._assert_search_path(['win-wk2', 'win-vista', 'win-7sp0', 'win-8', 'win-8.1', 'win-win10', 'win', 'mac-wk2', 'mac'], Version.from_name('Vista'), use_webkit2=True) self._assert_search_path(['win-wk2', 'win-7sp0', 'win-8', 'win-8.1', 'win-win10', 'win', 'mac-wk2', 'mac'], Version.from_name('7sp0'), use_webkit2=True) def _assert_version(self, port_name, expected_version): host = MockSystemHost(os_name='win', os_version=expected_version) port = WinPort(host, port_name=port_name) self.assertEqual(port.version_name(), VersionNameMap.map().to_name(expected_version, platform='win', table=PUBLIC_TABLE)) def test_versions(self): self._assert_version('win-xp', Version.from_name('XP')) self._assert_version('win-vista', Version.from_name('Vista')) self._assert_version('win-7sp0', Version.from_name('7sp0')) self.assertRaises(AssertionError, self._assert_version, 'win-me', Version.from_name('Vista')) def test_compare_text(self): expected = "EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification\nfoo\nEDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification\n" port = self.make_port() self.assertFalse(port.do_text_results_differ(expected, "foo\n")) self.assertTrue(port.do_text_results_differ(expected, "foo")) self.assertTrue(port.do_text_results_differ(expected, "bar")) # This hack doesn't exist in WK2. port._options = MockOptions(webkit_test_runner=True) self.assertTrue(port.do_text_results_differ(expected, "foo\n")) def test_operating_system(self): self.assertEqual('win', self.make_port().operating_system()) def test_expectations_files(self): self.assertEqual(len(self.make_port().expectations_files()), 3) self.assertEqual(len(self.make_port(options=MockOptions(webkit_test_runner=True, configuration='Release')).expectations_files()), 5) def test_get_crash_log(self): # Win crash logs are tested elsewhere, so here we just make sure we don't crash. def fake_time_cb(): times = [0, 20, 40] return lambda: times.pop(0) port = self.make_port(port_name='win') port._get_crash_log('DumpRenderTree', 1234, '', '', 0, time_fn=fake_time_cb(), sleep_fn=lambda delay: None) def test_layout_test_searchpath_with_apple_additions(self): with port_testcase.bind_mock_apple_additions(): search_path = self.make_port().default_baseline_search_path() self.assertEqual(search_path[0], '/additional_testing_path/win') self.assertEqual(search_path[1], '/mock-checkout/LayoutTests/platform/win-xp')
# Keep this file free of any code or import statements that could # cause either an error to occur or a log message to be logged. # This ensures that calling code can import initialization code from # webkitpy before any errors or log messages due to code in this file. # Initialization code can include things like version-checking code and # logging configuration code. # # We do not execute any version-checking code or logging configuration # code in this file so that callers can opt-in as they want. This also # allows different callers to choose different initialization code, # as necessary. import os import sys 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]))) AutoInstall.register(Package('coverage', Version(5, 2, 1))) AutoInstall.register(Package('toml', Version(0, 10, 1)))
def test_versions(self): self._assert_version('win-xp', Version.from_name('XP')) self._assert_version('win-vista', Version.from_name('Vista')) self._assert_version('win-7sp0', Version.from_name('7sp0')) self.assertRaises(AssertionError, self._assert_version, 'win-me', Version.from_name('Vista'))
class WatchPort(DevicePort): port_name = 'watchos' CURRENT_VERSION = Version(5) DEVICE_TYPE = DeviceType(software_variant='watchOS') def __init__(self, *args, **kwargs): super(WatchPort, self).__init__(*args, **kwargs) if self.get_option('webkit_test_runner', False) == False: raise RuntimeError('DumpRenderTree is not supported on this platform.') def driver_name(self): if self.get_option('driver_name'): return self.get_option('driver_name') return 'WebKitTestRunnerApp.app' def version_name(self): if self._os_version is None: return None return VersionNameMap.map(self.host.platform).to_name(self._os_version, platform=WatchPort.port_name) def test_expectations_file_position(self): return 4 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