def __init__(self, port, options, printer): """Initialize test runner data structures. Args: port: an object implementing port-specific options: a dictionary of command line options printer: a Printer object to record updates to. """ self._port = port self._filesystem = port.host.filesystem self._options = options self._printer = printer self._expectations = None self.HTTP_SUBDIR = 'http' + port.TEST_PATH_SEPARATOR self.WEBSOCKET_SUBDIR = 'websocket' + port.TEST_PATH_SEPARATOR self.web_platform_test_subdir = self._port.web_platform_test_server_doc_root( ) self.LAYOUT_TESTS_DIRECTORY = 'LayoutTests' # disable wss server. need to install pyOpenSSL on buildbots. # self._websocket_secure_server = websocket_server.PyWebSocket( # options.results_directory, use_tls=True, port=9323) self._results_directory = self._port.results_directory() self._finder = LayoutTestFinder(self._port, self._options) self._runner = LayoutTestRunner(self._options, self._port, self._printer, self._results_directory, self._test_is_slow)
def __init__(self, port, options, printer): """Initialize test runner data structures. Args: port: an object implementing port-specific options: a dictionary of command line options printer: a Printer object to record updates to. """ self._port = port self._filesystem = port.host.filesystem self._options = options self._printer = printer self._expectations = None self.HTTP_SUBDIR = 'http' + port.TEST_PATH_SEPARATOR self.PERF_SUBDIR = 'perf' self.WEBSOCKET_SUBDIR = 'websocket' + port.TEST_PATH_SEPARATOR self.LAYOUT_TESTS_DIRECTORY = 'LayoutTests' self._http_server_started = False self._websockets_server_started = False self._results_directory = self._port.results_directory() self._finder = LayoutTestFinder(self._port, self._options) self._runner = LayoutTestRunner(self._options, self._port, self._printer, self._results_directory, self._test_is_slow)
def __init__(self, port, options, printer): """Initialize test runner data structures. Args: port: An object implementing platform-specific functionality. options: An options argument which contains command line options. printer: A Printer object to record updates to. """ self._port = port self._filesystem = port.host.filesystem self._options = options self._printer = printer self._expectations = None self.HTTP_SUBDIR = 'http' + port.TEST_PATH_SEPARATOR self.INSPECTOR_SUBDIR = 'inspector' + port.TEST_PATH_SEPARATOR self.PERF_SUBDIR = 'perf' self.WEBSOCKET_SUBDIR = 'websocket' + port.TEST_PATH_SEPARATOR self.LAYOUT_TESTS_DIRECTORY = 'LayoutTests' self.ARCHIVED_RESULTS_LIMIT = 25 self._http_server_started = False self._wptserve_started = False self._websockets_server_started = False self._results_directory = self._port.results_directory() self._finder = LayoutTestFinder(self._port, self._options) self._runner = LayoutTestRunner(self._options, self._port, self._printer, self._results_directory, self._test_is_slow)
def test_touched_but_skipped_test(self): host = MockHost() port = MockPort(host) expectations_dict = OrderedDict() expectations_dict[ 'expectations'] = 'test1.html [ Skip ]\ntest3.html [ Skip ]\n' port.expectations_dict = lambda: expectations_dict port.test_exists = lambda test: True paths = [ 'LayoutTests/test0.html', 'LayoutTests/test1.html', 'LayoutTests/test2-expected.txt', 'LayoutTests/test3-expected.txt' ] host.filesystem.write_text_file( '/test.checkout/LayoutTests/test2.html', 'This is a test to be runned') host.filesystem.write_text_file( '/test.checkout/LayoutTests/test3.html', 'This is a test to be skipped') touched_tests = LayoutTestFinder( port, optparse.Values({ 'skipped': 'always', 'skip_failing_tests': False, 'http': True })).find_touched_tests(paths) self.assertItemsEqual(touched_tests, ['test0.html', 'test2.html'])
def __init__(self, port, options, printer): """Initialize test runner data structures. Args: port: an object implementing port-specific options: a dictionary of command line options printer: a Printer object to record updates to. """ self._port = port self._filesystem = port.host.filesystem self._options = options self._printer = printer self._expectations = None self.HTTP_SUBDIR = 'http' + port.TEST_PATH_SEPARATOR self.WEBSOCKET_SUBDIR = 'websocket' + port.TEST_PATH_SEPARATOR self.web_platform_test_subdir = self._port.web_platform_test_server_doc_root( ) self.LAYOUT_TESTS_DIRECTORY = 'LayoutTests' self._results_directory = self._port.results_directory() self._finder = LayoutTestFinder(self._port, self._options) self._runner = LayoutTestRunner(self._options, self._port, self._printer, self._results_directory, self._test_is_slow) test_options_json_path = self._port.path_from_webkit_base( self.LAYOUT_TESTS_DIRECTORY, "tests-options.json") self._tests_options = json.loads( self._filesystem.read_text_file(test_options_json_path) ) if self._filesystem.exists(test_options_json_path) else {}
def execute(self, options, args, tool): if not args and not options.all: print("You must either specify one or more test paths or --all.") return default_port = tool.port_factory.get() if options.platform: port_names = fnmatch.filter(tool.port_factory.all_port_names(), options.platform) if not port_names: print("No port names match '%s'" % options.platform) else: port_names = [default_port.name()] # FIXME: make real_tests() a public method. finder = LayoutTestFinder(default_port, None) tests = sorted(finder._real_tests(args)) for port_name in port_names: if port_name != port_names[0]: print() print("// For %s" % port_name) port = tool.port_factory.get(port_name) for test_name in tests: self._print_baselines( options, port_name, test_name, port.expected_baselines_by_extension(test_name))
def __init__(self, port, options, printer): """Initialize test runner data structures. Args: port: an object implementing port-specific options: a dictionary of command line options printer: a Printer object to record updates to. """ self._port = port fs = port.host.filesystem self._filesystem = fs self._options = options self._printer = printer self._expectations = OrderedDict() self._results_directory = self._port.results_directory() self._finder = LayoutTestFinder(self._port, self._options) self._runner = None self._tests_options = {} test_options_json_path = fs.join(self._port.layout_tests_dir(), "tests-options.json") if fs.exists(test_options_json_path): with fs.open_binary_file_for_reading(test_options_json_path) as fd: try: self._tests_options = json.load(fd) except (ValueError, IOError): pass
def touched_files(self, touched_files, fs=None): host = MockHost() if fs: host.filesystem = fs else: fs = host.filesystem port = MockPort(host) return (fs, LayoutTestFinder(port, optparse.Values({'skipped': 'always', 'skip_failing_tests': False, 'http': True})).find_touched_tests(touched_files))
def _new_or_modified_tests(self): touched_files = self._tool.scm().changed_files() touched_files.extend(self._tool.scm().untracked_files()) if not touched_files: return None configuration = "Debug" if (self._options.build_style == "debug") else "Release" port = Host().port_factory.get(self._tool.deprecated_port().port_flag_name, optparse.Values({'configuration': configuration})) return LayoutTestFinder(port, optparse.Values({'skipped': 'always', 'skip_failing_tests': False, 'http': True})).find_touched_tests(touched_files)
def execute(self, options, args, tool): if not options.paths and not args and not options.all: print("You must either specify one or more test paths or --all.") return if options.platform: port_names = fnmatch.filter(tool.port_factory.all_port_names(), options.platform) if not port_names: default_port = tool.port_factory.get(options.platform) if default_port: port_names = [default_port.name()] else: print("No port names match '%s'" % options.platform) return else: default_port = tool.port_factory.get(port_names[0]) else: default_port = tool.port_factory.get(options=options) port_names = [default_port.name()] if options.paths: files = default_port.expectations_files() layout_tests_dir = default_port.layout_tests_dir() for file in files: if file.startswith(layout_tests_dir): file = file.replace(layout_tests_dir, 'LayoutTests') print(file) return finder = LayoutTestFinder(default_port, None) tests = finder.find_tests_by_path(args) test_files = {test.test_path for test in tests} for port_name in port_names: model = self._model(options, port_name, test_files) tests_to_print = self._filter_tests(options, model, test_files) lines = [ model.get_expectation_line(test) for test in sorted(tests_to_print) ] if port_name != port_names[0]: print() print('\n'.join(self._format_lines(options, port_name, lines)))
def __init__(self, port, options, printer): """Initializes test runner data structures. Args: port: An object implementing platform-specific functionality. options: An options argument which contains command line options. printer: A Printer object to record updates to. """ self._port = port self._filesystem = port.host.filesystem self._options = options self._printer = printer self._expectations = None self._http_server_started = False self._wptserve_started = False self._websockets_server_started = False self._results_directory = self._port.results_directory() self._finder = LayoutTestFinder(self._port, self._options) self._path_finder = PathFinder(port.host.filesystem) self._runner = LayoutTestRunner(self._options, self._port, self._printer, self._results_directory, self._test_is_slow)
def make_finder(self): host = MockHost(create_stub_repository_files=True) add_unit_tests_to_mock_filesystem(host.filesystem) port = TestPort(host) return LayoutTestFinder(port, None)