Diff
Modified: trunk/Tools/ChangeLog (99780 => 99781)
--- trunk/Tools/ChangeLog 2011-11-10 00:11:52 UTC (rev 99780)
+++ trunk/Tools/ChangeLog 2011-11-10 00:24:08 UTC (rev 99781)
@@ -1,5 +1,37 @@
2011-11-09 Eric Seidel <[email protected]>
+ Remove the concept of platform-dependent unittests
+ https://bugs.webkit.org/show_bug.cgi?id=71963
+
+ Reviewed by Adam Barth.
+
+ These have been the source of never-ending sadness.
+ We'd change behavior and forget to update results in
+ some unittests because they were only run on certain platforms.
+ This change removes a large source of these platform-dependent
+ unittests, which was caused by the port_maker stuff.
+
+ It's possible that this change will break test-webkitpy
+ on some platforms, but that will be a one-time cost.
+ I will fix the breakage by removing the platform-dependantness
+ of any such broken tests.
+
+ * Scripts/webkitpy/layout_tests/port/base_unittest.py:
+ * Scripts/webkitpy/layout_tests/port/chromium_linux_unittest.py:
+ * Scripts/webkitpy/layout_tests/port/chromium_mac_unittest.py:
+ * Scripts/webkitpy/layout_tests/port/chromium_unittest.py:
+ * Scripts/webkitpy/layout_tests/port/chromium_win.py:
+ * Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py:
+ * Scripts/webkitpy/layout_tests/port/efl_unittest.py:
+ * Scripts/webkitpy/layout_tests/port/gtk_unittest.py:
+ * Scripts/webkitpy/layout_tests/port/mac_unittest.py:
+ * Scripts/webkitpy/layout_tests/port/port_testcase.py:
+ * Scripts/webkitpy/layout_tests/port/qt_unittest.py:
+ * Scripts/webkitpy/layout_tests/port/webkit_unittest.py:
+ * Scripts/webkitpy/layout_tests/port/win_unittest.py:
+
+2011-11-09 Eric Seidel <[email protected]>
+
Make the Port object have a Host
https://bugs.webkit.org/show_bug.cgi?id=71961
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py (99780 => 99781)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py 2011-11-10 00:11:52 UTC (rev 99780)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py 2011-11-10 00:24:08 UTC (rev 99781)
@@ -48,9 +48,9 @@
class PortTest(unittest.TestCase):
- def make_port(self, *args, **kwargs):
- kwargs.setdefault('host', MockHost())
- return Port(*args, **kwargs)
+ def make_port(self, host=None, **kwargs):
+ host = host or MockHost()
+ return Port(host, **kwargs)
def test_format_wdiff_output_as_html(self):
output = "OUTPUT %s %s %s" % (Port._WDIFF_DEL, Port._WDIFF_ADD, Port._WDIFF_END)
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_linux_unittest.py (99780 => 99781)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_linux_unittest.py 2011-11-10 00:11:52 UTC (rev 99780)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_linux_unittest.py 2011-11-10 00:24:08 UTC (rev 99781)
@@ -36,13 +36,9 @@
class ChromiumLinuxPortTest(port_testcase.PortTestCase):
- def port_maker(self, platform):
- if not platform.startswith('linux'):
- return None
- return chromium_linux.ChromiumLinuxPort
+ port_maker = chromium_linux.ChromiumLinuxPort
- def assert_architecture(self, port_name=None, file_output=None,
- expected_architecture=None):
+ def assert_architecture(self, port_name=None, file_output=None, expected_architecture=None):
host = MockHost()
host.filesystem.exists = lambda x: 'DumpRenderTree' in x
if file_output:
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_mac_unittest.py (99780 => 99781)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_mac_unittest.py 2011-11-10 00:11:52 UTC (rev 99780)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_mac_unittest.py 2011-11-10 00:24:08 UTC (rev 99781)
@@ -36,23 +36,17 @@
class ChromiumMacPortTest(port_testcase.PortTestCase):
- def port_maker(self, platform):
- # FIXME: This platform check should be removed!
- if platform != 'darwin':
- return None
- return chromium_mac.ChromiumMacPort
+ port_maker = chromium_mac.ChromiumMacPort
def test_check_wdiff(self):
- port = chromium_mac.ChromiumMacPort(MockHost())
- self.assertTrue(port.check_wdiff())
+ self.assertTrue(self.make_port().check_wdiff())
def assert_name(self, port_name, os_version_string, expected):
- port = chromium_mac.ChromiumMacPort(MockHost(), port_name=port_name, os_version_string=os_version_string)
+ port = self.make_port(port_name=port_name, os_version_string=os_version_string)
self.assertEquals(expected, port.name())
def test_versions(self):
- port = chromium_mac.ChromiumMacPort(MockHost())
- self.assertTrue(port.name() in ('chromium-cg-mac-leopard', 'chromium-cg-mac-snowleopard', 'chromium-cg-mac-lion', 'chromium-cg-mac-future'))
+ self.assertTrue(self.make_port().name() in ('chromium-cg-mac-leopard', 'chromium-cg-mac-snowleopard', 'chromium-cg-mac-lion', 'chromium-cg-mac-future'))
self.assert_name(None, '10.5.3', 'chromium-cg-mac-leopard')
self.assert_name('chromium-cg-mac', '10.5.3', 'chromium-cg-mac-leopard')
@@ -76,23 +70,20 @@
self.assertRaises(AssertionError, self.assert_name, None, '10.4.1', 'should-raise-assertion-so-this-value-does-not-matter')
def test_baseline_path(self):
- port = chromium_mac.ChromiumMacPort(MockHost(), port_name='chromium-mac-leopard')
+ port = self.make_port(port_name='chromium-mac-leopard')
self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-mac-leopard'))
- port = chromium_mac.ChromiumMacPort(MockHost(), port_name='chromium-mac-snowleopard')
+ port = self.make_port(port_name='chromium-mac-snowleopard')
self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-mac-snowleopard'))
- port = chromium_mac.ChromiumMacPort(MockHost(), port_name='chromium-mac-lion')
+ port = self.make_port(port_name='chromium-mac-lion')
self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-mac'))
def test_graphics_type(self):
- port = chromium_mac.ChromiumMacPort(MockHost(), port_name='chromium-cg-mac')
- self.assertEquals('cpu-cg', port.graphics_type())
- port = chromium_mac.ChromiumMacPort(MockHost(), port_name='chromium-mac')
- self.assertEquals('cpu', port.graphics_type())
+ self.assertEquals('cpu-cg', self.make_port(port_name='chromium-cg-mac').graphics_type())
+ self.assertEquals('cpu', self.make_port(port_name='chromium-mac').graphics_type())
# For now, Mac defaults to cpu-cg graphics type.
- port = chromium_mac.ChromiumMacPort(MockHost())
- self.assertEquals('cpu-cg', port.graphics_type())
+ self.assertEquals('cpu-cg', self.make_port().graphics_type())
if __name__ == '__main__':
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py (99780 => 99781)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py 2011-11-10 00:11:52 UTC (rev 99780)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py 2011-11-10 00:24:08 UTC (rev 99781)
@@ -117,8 +117,7 @@
class ChromiumPortTest(port_testcase.PortTestCase):
- def port_maker(self, platform):
- return chromium.ChromiumPort
+ port_maker = chromium.ChromiumPort
def test_all_test_configurations(self):
"""Validate the complete set of configurations this port knows about."""
@@ -276,8 +275,6 @@
def test_overrides_and_builder_names(self):
port = self.make_port()
- if not port:
- return
filesystem = MockFileSystem()
port._filesystem = filesystem
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win.py (99780 => 99781)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win.py 2011-11-10 00:11:52 UTC (rev 99780)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win.py 2011-11-10 00:24:08 UTC (rev 99781)
@@ -55,8 +55,6 @@
class ChromiumWinPort(chromium.ChromiumPort):
- """Chromium Win implementation of the Port class."""
-
# FIXME: Figure out how to unify this with base.TestConfiguration.all_systems()?
SUPPORTED_VERSIONS = ('xp', 'vista', 'win7')
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py (99780 => 99781)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py 2011-11-10 00:11:52 UTC (rev 99780)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py 2011-11-10 00:24:08 UTC (rev 99781)
@@ -32,6 +32,7 @@
from webkitpy.common.system import outputcapture
from webkitpy.common.host_mock import MockHost
+from webkitpy.common.system.executive_mock import MockExecutive
from webkitpy.common.system.filesystem_mock import MockFileSystem
from webkitpy.layout_tests.port import chromium_win
@@ -51,25 +52,16 @@
sys.platform = self.orig_platform
self._port = None
- def port_maker(self, platform):
- if platform not in ('cygwin', 'win32'):
- return None
- return chromium_win.ChromiumWinPort
+ port_maker = chromium_win.ChromiumWinPort
def _mock_path_from_chromium_base(self, *comps):
return self._port._filesystem.join("/chromium/src", *comps)
def test_uses_apache(self):
- port = self.make_port()
- if not port:
- return
+ self.assertFalse(self.make_port()._uses_apache())
- self.assertFalse(port._uses_apache())
-
def test_setup_environ_for_server(self):
port = self.make_port()
- if not port:
- return
port._executive = MockExecutive(should_log=True)
self._port = port
@@ -82,14 +74,16 @@
def test_setup_environ_for_server_register_cygwin(self):
port = self.make_port(options=ChromiumWinTest.RegisterCygwinOption())
- if not port:
- return
port._executive = 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]
+ # FIXME: This is kinda lame, we only run setup_mount on win32 platforms, so we only expect the run_command output there.
+ if sys.platform != "win32":
+ expected_stderr = ""
+ else:
+ 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)
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/efl_unittest.py (99780 => 99781)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/efl_unittest.py 2011-11-10 00:11:52 UTC (rev 99780)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/efl_unittest.py 2011-11-10 00:24:08 UTC (rev 99781)
@@ -33,8 +33,7 @@
class EflPortTest(port_testcase.PortTestCase):
- def port_maker(self, platform):
- return EflPort
+ port_maker = EflPort
def test_show_results_html_file(self):
port = self.make_port()
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/gtk_unittest.py (99780 => 99781)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/gtk_unittest.py 2011-11-10 00:11:52 UTC (rev 99780)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/gtk_unittest.py 2011-11-10 00:24:08 UTC (rev 99781)
@@ -35,8 +35,7 @@
class GtkPortTest(port_testcase.PortTestCase):
- def port_maker(self, platform):
- return GtkPort
+ port_maker = GtkPort
def test_show_results_html_file(self):
port = self.make_port()
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/mac_unittest.py (99780 => 99781)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/mac_unittest.py 2011-11-10 00:11:52 UTC (rev 99780)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/mac_unittest.py 2011-11-10 00:24:08 UTC (rev 99781)
@@ -36,14 +36,10 @@
class MacTest(port_testcase.PortTestCase):
- def port_maker(self, platform):
- # FIXME: This platform check should no longer be necessary and should be removed as soon as possible.
- if platform != 'darwin':
- return None
- return MacPort
+ port_maker = MacPort
def assert_skipped_file_search_paths(self, port_name, expected_paths):
- port = MacPort(MockHost(), port_name=port_name)
+ port = self.make_port(port_name=port_name)
self.assertEqual(port._skipped_file_search_paths(), expected_paths)
def test_skipped_file_search_paths(self):
@@ -74,11 +70,11 @@
]
def test_tests_from_skipped_file_contents(self):
- port = MacPort(MockHost())
+ port = self.make_port()
self.assertEqual(port._tests_from_skipped_file_contents(self.example_skipped_file), self.example_skipped_tests)
def assert_name(self, port_name, os_version_string, expected):
- port = MacPort(MockHost(), port_name=port_name, os_version_string=os_version_string)
+ port = self.make_port(port_name=port_name, os_version_string=os_version_string)
self.assertEquals(expected, port.name())
def test_tests_for_other_platforms(self):
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py (99780 => 99781)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py 2011-11-10 00:11:52 UTC (rev 99780)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py 2011-11-10 00:24:08 UTC (rev 99781)
@@ -47,7 +47,6 @@
from webkitpy.tool.mocktool import MockOptions
from webkitpy.common.system.executive_mock import MockExecutive
from webkitpy.common.host_mock import MockHost
-mock_options = MockOptions(configuration='Release')
class PortTestCase(unittest.TestCase):
@@ -55,26 +54,16 @@
HTTP_PORTS = (8000, 8080, 8443)
WEBSOCKET_PORTS = (8880,)
- def port_maker(self, platform):
- """Override to return the class object of the port to be tested,
- or None if a valid port object cannot be constructed on the specified
- platform."""
- raise NotImplementedError()
+ # Subclasses override this to point to their Port subclass.
+ port_maker = None
- 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
+ def make_port(self, host=None, options=None, **kwargs):
+ host = host or MockHost()
+ options = options or MockOptions(configuration='Release')
+ return self.port_maker(host, options=options, **kwargs)
- return maker(options=options, host=MockHost())
-
def test_default_worker_model(self):
port = self.make_port()
- if not port:
- return
-
if multiprocessing:
self.assertEqual(port.default_worker_model(), 'processes')
else:
@@ -82,8 +71,6 @@
def test_driver_cmd_line(self):
port = self.make_port()
- if not port:
- return
self.assertTrue(len(port.driver_cmd_line()))
options = MockOptions(additional_drt_flag=['--foo=bar', '--foo=baz'])
@@ -93,12 +80,8 @@
self.assertTrue('--foo=baz' in cmd_line)
def test_uses_apache(self):
- port = self.make_port()
- if not port:
- return
+ self.assertTrue(self.make_port()._uses_apache())
- self.assertTrue(port._uses_apache())
-
def assert_servers_are_down(self, host, ports):
for port in ports:
try:
@@ -122,31 +105,23 @@
def integration_test_http_lock(self):
port = self.make_port()
- if not port:
- return
# Only checking that no exception is raised.
port.acquire_http_lock()
port.release_http_lock()
def integration_test_check_sys_deps(self):
port = self.make_port()
- if not port:
- return
# Only checking that no exception is raised.
port.check_sys_deps(True)
def integration_test_helper(self):
port = self.make_port()
- if not port:
- return
# Only checking that no exception is raised.
port.start_helper()
port.stop_helper()
def integration_test_http_server__normal(self):
port = self.make_port()
- if not port:
- return
self.assert_servers_are_down('localhost', self.HTTP_PORTS)
port.start_http_server()
self.assert_servers_are_up('localhost', self.HTTP_PORTS)
@@ -155,8 +130,6 @@
def integration_test_http_server__fails(self):
port = self.make_port()
- if not port:
- return
# Test that if a port isn't available, the call fails.
for port_number in self.HTTP_PORTS:
test_socket = socket.socket()
@@ -187,8 +160,6 @@
# Test that calling start() on two different ports causes the
# first port to be treated as stale and killed.
port = self.make_port()
- if not port:
- return
# Test that if a port isn't available, the call fails.
port.start_http_server()
new_port = self.make_port()
@@ -212,9 +183,7 @@
def integration_test_image_diff(self):
port = self.make_port()
- if not port:
- return
-
+ # FIXME: This test will never run since we are using a MockFilesystem for these tests!?!?
if not port.check_image_diff():
# The port hasn't been built - don't run the tests.
return
@@ -237,8 +206,6 @@
def test_diff_image__missing_both(self):
port = self.make_port()
- if not port:
- return
self.assertFalse(port.diff_image(None, None)[0])
self.assertFalse(port.diff_image(None, '')[0])
self.assertFalse(port.diff_image('', None)[0])
@@ -246,35 +213,24 @@
def test_diff_image__missing_actual(self):
port = self.make_port()
- if not port:
- return
self.assertTrue(port.diff_image(None, 'foo')[0])
self.assertTrue(port.diff_image('', 'foo')[0])
def test_diff_image__missing_expected(self):
port = self.make_port()
- if not port:
- return
self.assertTrue(port.diff_image('foo', None)[0])
self.assertTrue(port.diff_image('foo', '')[0])
def test_check_build(self):
port = self.make_port()
- if not port:
- return
port.check_build(needs_http=True)
def test_check_wdiff(self):
port = self.make_port()
- if not port:
- return
port.check_wdiff()
def integration_test_websocket_server__normal(self):
port = self.make_port()
- if not port:
- return
-
self.assert_servers_are_down('localhost', self.WEBSOCKET_PORTS)
port.start_websocket_server()
self.assert_servers_are_up('localhost', self.WEBSOCKET_PORTS)
@@ -283,8 +239,6 @@
def integration_test_websocket_server__fails(self):
port = self.make_port()
- if not port:
- return
# Test that start() fails if a port isn't available.
for port_number in self.WEBSOCKET_PORTS:
@@ -309,8 +263,6 @@
def integration_test_websocket_server__two_servers(self):
port = self.make_port()
- if not port:
- return
# Test that calling start() on two different ports causes the
# first port to be treated as stale and killed.
@@ -336,21 +288,15 @@
def test_test_configuration(self):
port = self.make_port()
- if not port:
- return
self.assertTrue(port.test_configuration())
def test_all_test_configurations(self):
port = self.make_port()
- if not port:
- return
self.assertTrue(len(port.all_test_configurations()) > 0)
self.assertTrue(port.test_configuration() in port.all_test_configurations(), "%s not in %s" % (port.test_configuration(), port.all_test_configurations()))
def integration_test_http_server__loop(self):
port = self.make_port()
- if not port:
- return
i = 0
while i < 10:
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/qt_unittest.py (99780 => 99781)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/qt_unittest.py 2011-11-10 00:11:52 UTC (rev 99780)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/qt_unittest.py 2011-11-10 00:24:08 UTC (rev 99781)
@@ -39,8 +39,7 @@
class QtPortTest(port_testcase.PortTestCase):
- def port_maker(self, platform):
- return QtPort
+ port_maker = QtPort
def _assert_search_path(self, search_paths, sys_platform, use_webkit2=False, qt_version='4.7'):
# FIXME: Port constructors should not "parse" the port name, but
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit_unittest.py (99780 => 99781)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit_unittest.py 2011-11-10 00:11:52 UTC (rev 99780)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit_unittest.py 2011-11-10 00:24:08 UTC (rev 99781)
@@ -80,8 +80,7 @@
class WebKitPortTest(port_testcase.PortTestCase):
- def port_maker(self, platform):
- return TestWebKitPort
+ port_maker = TestWebKitPort
def test_check_build(self):
pass
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/win_unittest.py (99780 => 99781)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/win_unittest.py 2011-11-10 00:11:52 UTC (rev 99780)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/win_unittest.py 2011-11-10 00:24:08 UTC (rev 99781)
@@ -41,8 +41,7 @@
class WinPortTest(port_testcase.PortTestCase):
- def port_maker(self, platform):
- return WinPort
+ port_maker = WinPort
def test_show_results_html_file(self):
port = self.make_port()