def test_all_platforms(self): expectations = "BUGX REBASELINE : failures/expected/image.html = IMAGE" options = test_options() host, host_port_obj, filesystem = test_host_port_and_filesystem( options, expectations) url_fetcher = test_url_fetcher(filesystem) zip_factory = test_zip_factory() # FIXME: SCM module doesn't handle paths that aren't relative to the checkout_root consistently. filesystem.chdir("/test.checkout") oc = outputcapture.OutputCapture() oc.capture_output() res = rebaseline_chromium_webkit_tests.real_main( host, options, options, host_port_obj, host_port_obj, url_fetcher, zip_factory) oc.restore_output() # We expect to have written 38 files over the course of this rebaseline: # *) 6*3 files in /__im_tmp/ for the archived members of the 6 ports # *) 2*3 files in /test.checkout for actually differing baselines # *) 1 file in /test.checkout for the updated test_expectations file # *) 2*4 files in /tmp for the old/new baselines for the two actual ports # *) 2 files in /tmp for the text diffs for the two ports # *) 2 files in /tmp for the image diffs for the two ports # *) 1 file in /tmp for the rebaseline results html file # FIXME: These numbers depend on MockSCM.exists() returning True for all files. self.assertEqual(res, 0) self.assertEqual(len(filesystem.written_files), 38)
def test_all_platforms(self): expectations = "BUGX REBASELINE : failures/expected/image.html = IMAGE" options = test_options() host_port_obj, filesystem = test_host_port_and_filesystem( options, expectations) url_fetcher = test_url_fetcher(filesystem) zip_factory = test_zip_factory() mock_scm = mocktool.MockSCM() oc = outputcapture.OutputCapture() oc.capture_output() res = rebaseline_chromium_webkit_tests.real_main( options, options, host_port_obj, host_port_obj, url_fetcher, zip_factory, mock_scm) oc.restore_output() # We expect to have written 36 files over the course of this rebaseline: # *) 6*3 files in /__im_tmp/ for the archived members of the 6 ports # *) 2*3 files in /test.checkout for actually differing baselines # *) 1 file in /test.checkout for the updated test_expectations file # *) 2*4 files in /tmp for the old/new baselines for the two actual ports # *) 2 files in /tmp for the text diffs for the two ports # *) 1 file in /tmp for the rebaseline results html file self.assertEqual(res, 0) self.assertEqual(len(filesystem.written_files), 36)
def test_setup_environ_for_server_register_cygwin(self): port = self.make_port(options=ChromiumWinTest.RegisterCygwinOption()) port._executive = MockExecutive(should_log=True) expected_stderr = "MOCK run_command: ['/mock-checkout/Source/WebKit/chromium/third_party/cygwin/setup_mount.bat'], cwd=None\n" output = outputcapture.OutputCapture() output.assert_outputs(self, port.setup_environ_for_server, expected_stderr=expected_stderr)
def test_setup_environ_for_server(self): port = self.make_port() port._executive = MockExecutive(should_log=True) output = outputcapture.OutputCapture() orig_environ = port.host.environ.copy() env = output.assert_outputs(self, port.setup_environ_for_server) self.assertEqual(orig_environ["PATH"], port.host.environ.get("PATH")) self.assertNotEqual(env["PATH"], port.host.environ.get("PATH"))
def test_setup_environ_for_server_register_cygwin(self): port = self.make_port( options=MockOptions(register_cygwin=True, results_directory='/')) port._executive = MockExecutive(should_log=True) expected_logs = "MOCK run_command: ['/mock-checkout/third_party/cygwin/setup_mount.bat'], cwd=None\n" output = outputcapture.OutputCapture() output.assert_outputs(self, port.setup_environ_for_server, expected_logs=expected_logs)
def test_setup_environ_for_server(self): port = self.make_port() port._executive = MockExecutive(should_log=True) output = outputcapture.OutputCapture() # FIXME: This test should not use the real os.environ orig_environ = os.environ.copy() env = output.assert_outputs(self, port.setup_environ_for_server) self.assertEqual(orig_environ["PATH"], os.environ["PATH"]) self.assertNotEqual(env["PATH"], os.environ["PATH"])
def test_setup_environ_for_server(self): port = chromium_win.ChromiumWinPort() port._executive = mocktool.MockExecute(True) port.path_from_chromium_base = self._mock_path_from_chromium_base output = outputcapture.OutputCapture() orig_environ = os.environ.copy() env = output.assert_outputs(self, port.setup_environ_for_server) self.assertEqual(orig_environ["PATH"], os.environ["PATH"]) self.assertNotEqual(env["PATH"], os.environ["PATH"])
def test_pretty_patch_os_error(self): port = Port(executive=executive_mock.MockExecutive2(exception=OSError)) oc = outputcapture.OutputCapture() oc.capture_output() self.assertEqual(port.pretty_patch_text("patch.txt"), port._pretty_patch_error_html) # This tests repeated calls to make sure we cache the result. self.assertEqual(port.pretty_patch_text("patch.txt"), port._pretty_patch_error_html) oc.restore_output()
def run_and_capture(port_obj, options, parsed_args, shared_port=True): if shared_port: port_obj.host.port_factory.get = lambda *args, **kwargs: port_obj oc = outputcapture.OutputCapture() try: oc.capture_output() logging_stream = StringIO.StringIO() run_details = run_webkit_tests.run(port_obj, options, parsed_args, logging_stream=logging_stream) finally: oc.restore_output() return (run_details, logging_stream)
def test_setup_environ_for_server_register_cygwin(self): port = self.make_port(options=ChromiumWinTest.RegisterCygwinOption()) if not port: return port._executive = mocktool.MockExecutive(should_log=True) port.path_from_chromium_base = self._mock_path_from_chromium_base self._port = port setup_mount = self._mock_path_from_chromium_base("third_party", "cygwin", "setup_mount.bat") expected_stderr = "MOCK run_command: %s, cwd=None\n" % [setup_mount] output = outputcapture.OutputCapture() output.assert_outputs(self, port.setup_environ_for_server, expected_stderr=expected_stderr)
def test_setup_environ_for_server_register_cygwin(self): sys.platform = "win32" port = chromium_win.ChromiumWinPort( options=ChromiumWinTest.RegisterCygwinOption()) port._executive = mocktool.MockExecute(True) port.path_from_chromium_base = self._mock_path_from_chromium_base setup_mount = self._mock_path_from_chromium_base( "third_party", "cygwin", "setup_mount.bat") expected_stderr = "MOCK run_command: %s\n" % [setup_mount] output = outputcapture.OutputCapture() output.assert_outputs(self, port.setup_environ_for_server, expected_stderr=expected_stderr)
def test_setup_environ_for_server(self): port = self.make_port() if not port: return port._executive = mocktool.MockExecutive(should_log=True) self._port = port port.path_from_chromium_base = self._mock_path_from_chromium_base output = outputcapture.OutputCapture() orig_environ = os.environ.copy() env = output.assert_outputs(self, port.setup_environ_for_server) self.assertEqual(orig_environ["PATH"], os.environ["PATH"]) self.assertNotEqual(env["PATH"], os.environ["PATH"])
def run_and_capture(port_obj, options, parsed_args): oc = outputcapture.OutputCapture() try: oc.capture_output() 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) finally: oc.restore_output() return (res, buildbot_output, regular_output)
def test_timeout(self): # Because the timeout shows up as a wedged thread, this also tests # log_wedged_worker(). oc = outputcapture.OutputCapture() stdout, stderr = oc.capture_output() logger = message_broker._log astream = array_stream.ArrayStream() handler = TestHandler(astream) logger.addHandler(handler) interrupted = self.run_one_thread('Timeout') stdout, stderr = oc.restore_output() self.assertFalse(interrupted) logger.handlers.remove(handler) self.assertTrue( 'All remaining threads are wedged, bailing out.' in astream.get())
def test_build_dumprendertree__failure(self): c = self.make_config(exit_code=-1) # FIXME: Build failures should log errors. However, the message we # get depends on how we're being called; as a standalone test, # we'll get the "no handlers found" message. As part of # test-webkitpy, we get the actual message. Really, we need # outputcapture to install its own handler. oc = outputcapture.OutputCapture() oc.capture_output() self.assertFalse(c.build_dumprendertree('Debug')) oc.restore_output() oc.capture_output() self.assertFalse(c.build_dumprendertree('Release')) oc.restore_output()
def test_log_wedged_worker(self): starting_queue = self.queue() stopping_queue = self.queue() self.make_broker(starting_queue, stopping_queue) oc = outputcapture.OutputCapture() oc.capture_output() try: worker = self._broker.start_worker(0) starting_queue.get() worker.log_wedged_worker('test_name') stopping_queue.put('') self._broker.post_message('stop') self._broker.run_message_loop() worker.join(0.5) self.assertFalse(worker.is_alive()) self.assertTrue(self.is_done()) finally: oc.restore_output()
def test_log_wedged_thread(self): oc = outputcapture.OutputCapture() oc.capture_output() logger = run_webkit_tests._log astream = array_stream.ArrayStream() handler = TestHandler(astream) logger.addHandler(handler) starting_queue = Queue.Queue() stopping_queue = Queue.Queue() child_thread = TestThread(starting_queue, stopping_queue) child_thread.start() msg = starting_queue.get() run_webkit_tests._log_wedged_thread(child_thread) stopping_queue.put('') child_thread.join(timeout=1.0) self.assertFalse(astream.empty()) self.assertFalse(child_thread.isAlive()) oc.restore_output()
def get_test_results(args, host=None): options, parsed_args = parse_args(args, tests_included=True) host = host or MockHost() port_obj = host.port_factory.get(port_name=options.platform, options=options) oc = outputcapture.OutputCapture() oc.capture_output() logging_stream = StringIO.StringIO() try: run_details = run_webkit_tests.run(port_obj, options, parsed_args, logging_stream=logging_stream) finally: oc.restore_output() all_results = [] if run_details.initial_results: all_results.extend(run_details.initial_results.all_results) if run_details.retry_results: all_results.extend(run_details.retry_results.all_results) return all_results
def test_timeout(self): oc = outputcapture.OutputCapture() oc.capture_output() interrupted = self.run_one_thread('Timeout') self.assertFalse(interrupted) oc.restore_output()
def test_default_configuration__unknown(self): # Ignore the warning about an unknown configuration value. oc = outputcapture.OutputCapture() oc.capture_output() self.assert_configuration('Unknown', 'Unknown') oc.restore_output()