def test_build_driver(self): output = OutputCapture() port = TestWebKitPort() # Delay setting _executive to avoid logging during construction port._executive = MockExecutive(should_log=True) port._options = MockOptions( configuration="Release" ) # This should not be necessary, but I think TestWebKitPort is actually reading from disk (and thus detects the current configuration). expected_stderr = "MOCK run_command: ['Tools/Scripts/build-dumprendertree', '--release'], cwd=/mock-checkout\n" self.assertTrue( output.assert_outputs(self, port._build_driver, expected_stderr=expected_stderr)) # Make sure when passed --webkit-test-runner web build the right tool. port._options = MockOptions(webkit_test_runner=True, configuration="Release") expected_stderr = "MOCK run_command: ['Tools/Scripts/build-webkittestrunner', '--release'], cwd=/mock-checkout\n" self.assertTrue( output.assert_outputs(self, port._build_driver, expected_stderr=expected_stderr)) # Make sure that failure to build returns False. port._executive = MockExecutive(should_log=True, should_throw=True) expected_stderr = "MOCK run_command: ['Tools/Scripts/build-webkittestrunner', '--release'], cwd=/mock-checkout\n" self.assertFalse( output.assert_outputs(self, port._build_driver, expected_stderr=expected_stderr))
def test_show_results_html_file(self): port = self.make_port() port._executive = MockExecutive(should_log=True) expected_stderr = "MOCK run_command: ['Tools/Scripts/run-launcher', '--release', '--gtk', 'file://test.html'], cwd=/mock-checkout\n" OutputCapture().assert_outputs(self, port.show_results_html_file, ["test.html"], expected_stderr=expected_stderr)
def test_show_results_html_file(self): port = self.make_port() port._executive = MockExecutive(should_log=True) expected_stderr = "MOCK: user.open_url: test.html\n" OutputCapture().assert_outputs(self, port.show_results_html_file, ["test.html"], expected_stderr=expected_stderr)
def __init__(self, symbol_list=None, feature_list=None, expectations_file=None, skips_file=None, executive=None, filesystem=None, user=None, **kwargs): self.symbol_list = symbol_list self.feature_list = feature_list executive = executive or MockExecutive(should_log=False) filesystem = filesystem or MockFileSystem() user = user or MockUser() WebKitPort.__init__(self, executive=executive, filesystem=filesystem, user=MockUser(), **kwargs)
def make_port(self, options=mock_options): """This routine should be used for tests that should only be run when we can create a full, valid port object.""" maker = self.port_maker(sys.platform) if not maker: return None return maker(options=options, filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())
def setUp(self): self.filesystem = MockFileSystem() self.http_lock = HttpLock(None, "WebKitTestHttpd.lock.", "WebKitTest.lock", filesystem=self.filesystem, executive=MockExecutive()) # FIXME: Shouldn't we be able to get these values from the http_lock object directly? self.lock_file_path_prefix = self.filesystem.join( self.http_lock._lock_path, self.http_lock._lock_file_prefix) self.lock_file_name = self.lock_file_path_prefix + "0"
def _assert_search_path(self, search_paths, sys_platform, use_webkit2=False): # FIXME: Port constructors should not "parse" the port name, but # rather be passed components (directly or via setters). Once # we fix that, this method will need a re-write. port = QtPort(sys_platform=sys_platform, options=MockOptions(webkit_test_runner=use_webkit2), filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive()) absolute_search_paths = map(port._webkit_baseline_path, search_paths) self.assertEquals(port.baseline_search_path(), absolute_search_paths)
def _assert_search_path(self, expected_search_paths, version, use_webkit2=False): port = WinPort(os_version_string=version, options=MockOptions(webkit_test_runner=use_webkit2), filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive()) absolute_search_paths = map(port._webkit_baseline_path, expected_search_paths) self.assertEquals(port.baseline_search_path(), absolute_search_paths)
def test_create_zip(self): workspace = Workspace(None, MockExecutive(should_log=True)) expected_stderr = "MOCK run_command: ['zip', '-r', '/zip/path', '/source/path']\n" class MockZipFile(object): def __init__(self, path): self.filename = path archive = OutputCapture().assert_outputs( self, workspace.create_zip, ["/zip/path", "/source/path", MockZipFile], expected_stderr=expected_stderr) self.assertEqual(archive.filename, "/zip/path")
def assert_port(self, port_name, expected_port, port_obj=None): """Helper assert for port_name. Args: port_name: port name to get port object. expected_port: class of expected port object. port_obj: optional port object """ port_obj = port_obj or factory.get(port_name=port_name, filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive()) self.assertTrue(isinstance(port_obj, expected_port))
def assert_platform_port(self, platform, options, expected_port): """Helper assert for platform and options. Args: platform: sys.platform. options: options to get port object. expected_port: class of expected port object. """ orig_platform = sys.platform sys.platform = platform self.assertTrue( isinstance( factory.get(options=options, filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive()), expected_port)) sys.platform = orig_platform
def assert_name(self, port_name, os_version_string, expected): port = MacPort(port_name=port_name, os_version_string=os_version_string, filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive()) self.assertEquals(expected, port.name())
def __init__(self): self._filesystem = MockFileSystem() self._executive = MockExecutive()
def __init__(self): self.tool = MockTool() self.tool.executive = MockExecutive(should_log=True) self.tool.filesystem.files[ TestPortFactory.path_to_test_expectations_file()] = ""
def _assert_version(self, port_name, expected_version): port = WinPort(port_name=port_name, filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive()) self.assertEquals(port.version(), expected_version)
def test_runtime_feature_list(self): port = WebKitPort(executive=MockExecutive()) port._executive.run_command = lambda command, cwd=None, error_handler=None: "Nonsense" self.assertEquals(port._runtime_feature_list(), []) port._executive.run_command = lambda command, cwd=None, error_handler=None: "SupportedFeatures:foo bar" self.assertEquals(port._runtime_feature_list(), ['foo', 'bar'])
def test_tests_from_skipped_file_contents(self): port = MacPort(filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive()) self.assertEqual(port._tests_from_skipped_file_contents(self.example_skipped_file), self.example_skipped_tests)
def assert_skipped_file_search_paths(self, port_name, expected_paths): port = MacPort(port_name=port_name, filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive()) self.assertEqual(port._skipped_file_search_paths(), expected_paths)
def test_show_results_html_file(self): port = MacPort(filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive()) # Delay setting a should_log executive to avoid logging from MacPort.__init__. port._executive = MockExecutive(should_log=True) expected_stderr = "MOCK run_command: ['Tools/Scripts/run-safari', '--release', '-NSOpen', 'test.html'], cwd=/mock-checkout\n" OutputCapture().assert_outputs(self, port.show_results_html_file, ["test.html"], expected_stderr=expected_stderr)
def test_rebaseline_expectations(self): command = RebaselineExpectations() tool = MockTool() tool.executive = MockExecutive(should_log=True) command.bind_to_tool(tool) expected_stdout = """Retrieving results for chromium-cg-mac-leopard from Webkit Mac10.5 (CG). userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-cg-mac-snowleopard from Webkit Mac10.6 (CG). userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-gpu-cg-mac-leopard from Webkit Mac10.5 (CG) - GPU. Retrieving results for chromium-gpu-cg-mac-snowleopard from Webkit Mac10.6 (CG) - GPU. Retrieving results for chromium-gpu-win-win7 from Webkit Win7 - GPU. Retrieving results for chromium-gpu-win-xp from Webkit Win - GPU. Retrieving results for chromium-linux-x86 from Webkit Linux 32. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-linux-x86_64 from Webkit Linux. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-mac-leopard from Webkit Mac10.5. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-mac-snowleopard from Webkit Mac10.6. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-win-vista from Webkit Vista. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-win-win7 from Webkit Win7. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-win-xp from Webkit Win. userscripts/another-test.html userscripts/images.svg Optimizing baselines for userscripts/another-test.html. Optimizing baselines for userscripts/images.svg. """ expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5 (CG)', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5 (CG)', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6 (CG)', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6 (CG)', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux 32', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux 32', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Vista', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Vista', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win7', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win7', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'optimize-baselines', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'optimize-baselines', 'userscripts/images.svg'], cwd=/mock-checkout """ command._tests_to_rebaseline = lambda port: [] if not port.name().find( '-gpu-') == -1 else [ 'userscripts/another-test.html', 'userscripts/images.svg' ] OutputCapture().assert_outputs(self, command.execute, [MockTool(), None, None], expected_stdout=expected_stdout, expected_stderr=expected_stderr)
def _make_checkout(self): return Checkout(scm=MockSCM(), filesystem=MockFileSystem(), executive=MockExecutive())
def test_tests_for_other_platforms(self): platforms = ['mac', 'chromium-linux', 'mac-snowleopard'] port = MacPort(port_name='mac-snowleopard', filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive()) platform_dir_paths = map(port._webkit_baseline_path, platforms) # Replace our empty mock file system with one which has our expected platform directories. port._filesystem = MockFileSystem(dirs=platform_dir_paths) dirs_to_skip = port._tests_for_other_platforms() self.assertTrue('platform/chromium-linux' in dirs_to_skip) self.assertFalse('platform/mac' in dirs_to_skip) self.assertFalse('platform/mac-snowleopard' in dirs_to_skip)
def test_version(self): port = MacPort(filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive()) self.assertTrue(port.version())
def test_rollout_updates_working_copy(self): rollout = Rollout() tool = MockTool() tool.executive = MockExecutive(should_log=True) expected_stderr = "MOCK run_and_throw_if_fail: ['mock-update-webkit'], cwd=/mock-checkout\n" OutputCapture().assert_outputs(self, rollout._update_working_copy, [tool], expected_stderr=expected_stderr)