def get_port_for_run(args): options, parsed_args = run_webkit_tests.parse_args(args) test_port = ImageDiffTestPort(options=options, user=mocktool.MockUser()) res = passing_run(args, port_obj=test_port, tests_included=True) self.assertTrue(res) return test_port
def __init__(self, port_name=None, user=None, filesystem=None, **kwargs): if not port_name or port_name == 'test': port_name = 'test-mac-leopard' user = user or mocktool.MockUser() filesystem = filesystem or unit_test_filesystem() base.Port.__init__(self, port_name=port_name, filesystem=filesystem, user=user, **kwargs) self._results_directory = None assert filesystem._tests self._tests = filesystem._tests self._operating_system = 'mac' if port_name.startswith('test-win'): self._operating_system = 'win' elif port_name.startswith('test-linux'): self._operating_system = 'linux' version_map = { 'test-win-xp': 'xp', 'test-win-win7': 'win7', 'test-win-vista': 'vista', 'test-mac-leopard': 'leopard', 'test-mac-snowleopard': 'snowleopard', 'test-linux-x86': '', } self._version = version_map[port_name] self._expectations_path = LAYOUT_TEST_DIR + '/platform/test/test_expectations.txt'
def test_host_port_and_filesystem(options, expectations): filesystem = unit_test_filesystem() host_port_obj = port.get('test', options, filesystem=filesystem, user=mocktool.MockUser()) expectations_path = host_port_obj.path_to_test_expectations_file() filesystem.write_text_file(expectations_path, expectations) return (host_port_obj, filesystem)
def test_lint_test_files__errors(self): options, parsed_args = parse_args(['--lint-test-files']) user = mocktool.MockUser() port_obj = port.get(options.platform, options=options, user=user) port_obj.test_expectations = lambda: "# syntax error" res, out, err = run_and_capture(port_obj, options, parsed_args) self.assertEqual(res, -1) self.assertTrue(out.empty()) self.assertTrue(any(['Lint failed' in msg for msg in err.get()]))
def get_tests_run(extra_args=None, tests_included=False, flatten_batches=False, filesystem=None, include_reference_html=False): extra_args = extra_args or [] if not tests_included: # Not including http tests since they get run out of order (that # behavior has its own test, see test_get_test_file_queue) extra_args = ['passes', 'failures'] + extra_args options, parsed_args = parse_args(extra_args, tests_included=True) user = mocktool.MockUser() test_batches = [] class RecordingTestDriver(TestDriver): def __init__(self, port, worker_number): TestDriver.__init__(self, port, worker_number) self._current_test_batch = None def poll(self): # So that we don't create a new driver for every test return None def stop(self): self._current_test_batch = None def run_test(self, test_input): if self._current_test_batch is None: self._current_test_batch = [] test_batches.append(self._current_test_batch) test_name = test_input.test_name # In case of reftest, one test calls the driver's run_test() twice. # We should not add a reference html used by reftests to tests unless include_reference_html parameter # is explicitly given. if include_reference_html or not is_reference_html_file( test_input.test_name): self._current_test_batch.append(test_name) return TestDriver.run_test(self, test_input) class RecordingTestPort(TestPort): def create_driver(self, worker_number): return RecordingTestDriver(self, worker_number) recording_port = RecordingTestPort(options=options, user=user, filesystem=filesystem) run_and_capture(recording_port, options, parsed_args) if flatten_batches: return list(itertools.chain(*test_batches)) return test_batches
def passing_run(extra_args=None, port_obj=None, record_results=False, tests_included=False, filesystem=None): options, parsed_args = parse_args(extra_args, record_results, tests_included) if not port_obj: port_obj = port.get(port_name=options.platform, options=options, user=mocktool.MockUser(), filesystem=filesystem) res = run_webkit_tests.run(port_obj, options, parsed_args) return res == 0
def logging_run(extra_args=None, port_obj=None, record_results=False, tests_included=False, filesystem=None): options, parsed_args = parse_args(extra_args=extra_args, record_results=record_results, tests_included=tests_included, print_nothing=False) user = mocktool.MockUser() if not port_obj: port_obj = port.get(port_name=options.platform, options=options, user=user, filesystem=filesystem) res, buildbot_output, regular_output = run_and_capture( port_obj, options, parsed_args) return (res, buildbot_output, regular_output, user)
def passing_run(extra_args=None, port_obj=None, record_results=False, tests_included=False, filesystem=None): options, parsed_args = parse_args(extra_args, record_results, tests_included) if not port_obj: port_obj = port.get(port_name=options.platform, options=options, user=mocktool.MockUser(), filesystem=filesystem) buildbot_output = array_stream.ArrayStream() regular_output = array_stream.ArrayStream() res = run_webkit_tests.run(port_obj, options, parsed_args, buildbot_output=buildbot_output, regular_output=regular_output) return res == 0 and regular_output.empty() and buildbot_output.empty()