Diff
Modified: trunk/Tools/ChangeLog (104738 => 104739)
--- trunk/Tools/ChangeLog 2012-01-11 21:23:20 UTC (rev 104738)
+++ trunk/Tools/ChangeLog 2012-01-11 21:36:24 UTC (rev 104739)
@@ -1,3 +1,56 @@
+2012-01-11 Dirk Pranke <[email protected]>
+
+ webkitpy: webkitpy.layout_tests.port tests should only use MockSystemHost, not MockHost
+ https://bugs.webkit.org/show_bug.cgi?id=76084
+
+ Reviewed by Adam Barth.
+
+ This will help make it easier to catch layering violations. This
+ change just refactors test code; there are no changes to
+ production code.
+
+ * Scripts/webkitpy/layout_tests/port/base_unittest.py:
+ (PortTest.make_port):
+ (PortTest.test_find_no_paths_specified):
+ (PortTest.test_find_one_test):
+ (PortTest.test_find_glob):
+ (PortTest.test_find_with_skipped_directories):
+ (PortTest.test_find_with_skipped_directories_2):
+ (PortTest.test_parse_reftest_list):
+ (PortTest.test_httpd_returns_error_code):
+ (PortTest.test_virtual_methods):
+ * Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py:
+ (ChromiumGpuTest.assert_port_works):
+ (ChromiumGpuTest._assert_baseline_path):
+ (ChromiumGpuTest.test_graphics_type):
+ (ChromiumGpuTest.test_default_tests_paths.test_paths):
+ (ChromiumGpuTest.test_test_files):
+ (ChromiumGpuTest.test_test_files.test_paths):
+ (ChromiumGpuTest):
+ * Scripts/webkitpy/layout_tests/port/chromium_linux_unittest.py:
+ (ChromiumLinuxPortTest.assert_architecture):
+ (ChromiumLinuxPortTest.test_check_illegal_port_names):
+ (ChromiumLinuxPortTest.test_determine_architecture_fails):
+ * Scripts/webkitpy/layout_tests/port/driver_unittest.py:
+ (DriverTest.make_port):
+ (DriverTest):
+ (DriverTest.assertVirtual):
+ (DriverTest._assert_wrapper):
+ (DriverTest.test_virtual_driver_methods):
+ * Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py:
+ (MockDRTPortTest.make_port):
+ (MockDRTPortTest.test_port_name_in_constructor):
+ (MockDRTTest.assertTest):
+ (MockDRTTest.test_main):
+ (MockChromiumDRTTest.test_pixeltest__fails):
+ * Scripts/webkitpy/layout_tests/port/qt_unittest.py:
+ (QtPortTest._assert_search_path):
+ * Scripts/webkitpy/layout_tests/port/webkit_unittest.py:
+ (TestWebKitPort.__init__):
+ (WebKitPortUnitTests.test_default_options):
+ (test_runtime_feature_list):
+ (test_test_expectations):
+
2012-01-11 Ojan Vafai <[email protected]>
Style skipped tests in the flakiness dashboard
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py (104738 => 104739)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py 2012-01-11 21:23:20 UTC (rev 104738)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py 2012-01-11 21:36:24 UTC (rev 104739)
@@ -40,19 +40,22 @@
from webkitpy.thirdparty.mock import Mock
from webkitpy.tool.mocktool import MockOptions
from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2
-from webkitpy.common.host_mock import MockHost
+from webkitpy.common.system.systemhost_mock import MockSystemHost
from webkitpy.layout_tests.port import Port, Driver, DriverOutput
-from webkitpy.layout_tests.port.test import TestPort
+from webkitpy.layout_tests.port.test import add_unit_tests_to_mock_filesystem, TestPort
import config
import config_mock
class PortTest(unittest.TestCase):
- def make_port(self, executive=None, **kwargs):
- host = MockHost()
+ def make_port(self, executive=None, with_tests=False, **kwargs):
+ host = MockSystemHost()
if executive:
host.executive = executive
+ if with_tests:
+ add_unit_tests_to_mock_filesystem(host.filesystem)
+ return TestPort(host, **kwargs)
return Port(host, **kwargs)
def test_default_child_processes(self):
@@ -284,28 +287,28 @@
self.assertTrue(port.uses_test_expectations_file())
def test_find_no_paths_specified(self):
- port = TestPort(MockHost())
+ port = self.make_port(with_tests=True)
layout_tests_dir = port.layout_tests_dir()
tests = port.tests([])
self.assertNotEqual(len(tests), 0)
def test_find_one_test(self):
- port = TestPort(MockHost())
+ port = self.make_port(with_tests=True)
tests = port.tests(['failures/expected/image.html'])
self.assertEqual(len(tests), 1)
def test_find_glob(self):
- port = TestPort(MockHost())
+ port = self.make_port(with_tests=True)
tests = port.tests(['failures/expected/im*'])
self.assertEqual(len(tests), 2)
def test_find_with_skipped_directories(self):
- port = TestPort(MockHost())
+ port = self.make_port(with_tests=True)
tests = port.tests('userscripts')
self.assertTrue('userscripts/resources/iframe.html' not in tests)
def test_find_with_skipped_directories_2(self):
- port = TestPort(MockHost())
+ port = self.make_port(with_tests=True)
tests = port.tests(['userscripts/resources'])
self.assertEqual(tests, set([]))
@@ -325,7 +328,7 @@
self.assertFalse(Port._is_test_file(filesystem, '', 'notref-foo.xhr'))
def test_parse_reftest_list(self):
- port = TestPort(MockHost())
+ port = self.make_port(with_tests=True)
port.host.filesystem.files['bar/reftest.list'] = "\n".join(["== test.html test-ref.html",
"",
"# some comment",
@@ -360,14 +363,11 @@
_, _, logs = capture.restore_output()
self.assertEqual('httpd seems broken. Cannot run http tests.\n', logs)
-
-class VirtualTest(unittest.TestCase):
- """Tests that various methods expected to be virtual are."""
def assertVirtual(self, method, *args, **kwargs):
self.assertRaises(NotImplementedError, method, *args, **kwargs)
def test_virtual_methods(self):
- port = Port(MockHost())
+ port = Port(MockSystemHost())
self.assertVirtual(port.baseline_path)
self.assertVirtual(port.baseline_search_path)
self.assertVirtual(port.check_build, None)
@@ -387,29 +387,6 @@
self.assertVirtual(port._path_to_lighttpd_php)
self.assertVirtual(port._path_to_wdiff)
- def test_virtual_driver_methods(self):
- driver = Driver(Port(MockHost()), None, pixel_tests=False)
- self.assertVirtual(driver.run_test, None)
- self.assertVirtual(driver.stop)
- self.assertVirtual(driver.cmd_line)
-
-# FIXME: This should be moved to driver_unittest.py or just deleted.
-class DriverTest(unittest.TestCase):
-
- def _assert_wrapper(self, wrapper_string, expected_wrapper):
- wrapper = Driver(Port(MockHost()), None, pixel_tests=False)._command_wrapper(wrapper_string)
- self.assertEqual(wrapper, expected_wrapper)
-
- def test_command_wrapper(self):
- self._assert_wrapper(None, [])
- self._assert_wrapper("valgrind", ["valgrind"])
-
- # Validate that shlex works as expected.
- command_with_spaces = "valgrind --smc-check=\"check with spaces!\" --foo"
- expected_parse = ["valgrind", "--smc-check=check with spaces!", "--foo"]
- self._assert_wrapper(command_with_spaces, expected_parse)
-
-
if __name__ == '__main__':
unittest.main()
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py (104738 => 104739)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py 2012-01-11 21:23:20 UTC (rev 104738)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py 2012-01-11 21:36:24 UTC (rev 104739)
@@ -27,8 +27,8 @@
import sys
import unittest
-from webkitpy.common.host_mock import MockHost
from webkitpy.common.system.filesystem_mock import MockFileSystem
+from webkitpy.common.system.systemhost_mock import MockSystemHost
from webkitpy.layout_tests.port import chromium_gpu
from webkitpy.layout_tests.port import port_testcase
from webkitpy.layout_tests.port.factory import PortFactory
@@ -51,7 +51,7 @@
self.assert_port_works('chromium-gpu-win', 'chromium-gpu', 'cygwin')
def assert_port_works(self, port_name, input_name=None, platform=None):
- host = MockHost()
+ host = MockSystemHost()
host.filesystem = FileSystem() # FIXME: This test should not use a real filesystem!
# test that we got the right port
@@ -91,8 +91,7 @@
self.assertFalse(path in files)
def _assert_baseline_path(self, port_name, baseline_path):
- host = MockHost()
- port = host.port_factory.get(port_name)
+ port = PortFactory(MockSystemHost()).get(port_name)
self.assertEquals(port.name(), port_name)
self.assertEquals(port.baseline_path(), port._webkit_baseline_path(baseline_path))
@@ -102,21 +101,19 @@
self._assert_baseline_path('chromium-gpu-win-win7', 'chromium-gpu-win')
def test_graphics_type(self):
- host = MockHost()
- port = host.port_factory.get('chromium-gpu-mac')
+ port = PortFactory(MockSystemHost()).get('chromium-gpu-mac')
self.assertEquals('gpu', port.graphics_type())
def test_default_tests_paths(self):
- host = MockHost()
def test_paths(port_name):
- return chromium_gpu._default_tests_paths(host.port_factory.get(port_name))
+ return chromium_gpu._default_tests_paths(PortFactory(MockSystemHost()).get(port_name))
self.assertEqual(test_paths('chromium-gpu-linux'), ['media', 'fast/canvas', 'canvas/philip'])
self.assertEqual(test_paths('chromium-gpu-mac-leopard'), ['fast/canvas', 'canvas/philip'])
def test_test_files(self):
- host = MockHost()
+ host = MockSystemHost()
files = {
'/mock-checkout/LayoutTests/canvas/philip/test.html': '',
'/mock-checkout/LayoutTests/fast/canvas/test.html': '',
@@ -127,7 +124,7 @@
host.filesystem = MockFileSystem(files)
def test_paths(port_name):
- return host.port_factory.get(port_name).tests([])
+ return PortFactory(host).get(port_name).tests([])
self.assertEqual(test_paths('chromium-gpu-linux'), set(['canvas/philip/test.html', 'fast/canvas/test.html', 'media/test.html']))
self.assertEqual(test_paths('chromium-gpu-mac-leopard'), set(['canvas/philip/test.html', 'fast/canvas/test.html']))
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_linux_unittest.py (104738 => 104739)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_linux_unittest.py 2012-01-11 21:23:20 UTC (rev 104738)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_linux_unittest.py 2012-01-11 21:36:24 UTC (rev 104739)
@@ -29,7 +29,7 @@
import unittest
from webkitpy.common.system import executive_mock
-from webkitpy.common.host_mock import MockHost
+from webkitpy.common.system.systemhost_mock import MockSystemHost
from webkitpy.layout_tests.port import chromium_linux
from webkitpy.layout_tests.port import port_testcase
@@ -39,7 +39,7 @@
port_maker = chromium_linux.ChromiumLinuxPort
def assert_architecture(self, port_name=None, file_output=None, expected_architecture=None):
- host = MockHost()
+ host = MockSystemHost()
host.filesystem.exists = lambda x: 'DumpRenderTree' in x
if file_output:
host.executive = executive_mock.MockExecutive2(file_output)
@@ -67,16 +67,16 @@
def test_check_illegal_port_names(self):
# FIXME: Check that, for now, these are illegal port names.
# Eventually we should be able to do the right thing here.
- self.assertRaises(AssertionError, chromium_linux.ChromiumLinuxPort, MockHost(), port_name='chromium-x86-linux')
- self.assertRaises(AssertionError, chromium_linux.ChromiumLinuxPort, MockHost(), port_name='chromium-linux-x86-gpu')
+ self.assertRaises(AssertionError, chromium_linux.ChromiumLinuxPort, MockSystemHost(), port_name='chromium-x86-linux')
+ self.assertRaises(AssertionError, chromium_linux.ChromiumLinuxPort, MockSystemHost(), port_name='chromium-linux-x86-gpu')
def test_determine_architecture_fails(self):
# Test that we default to 'x86' if the driver doesn't exist.
- port = chromium_linux.ChromiumLinuxPort(MockHost())
+ port = chromium_linux.ChromiumLinuxPort(MockSystemHost())
self.assertEquals(port.architecture(), 'x86_64')
# Test that we default to 'x86' on an unknown architecture.
- host = MockHost()
+ host = MockSystemHost()
host.filesystem.exists = lambda x: True
host.executive = executive_mock.MockExecutive2('win32')
port = chromium_linux.ChromiumLinuxPort(host)
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/driver_unittest.py (104738 => 104739)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/driver_unittest.py 2012-01-11 21:23:20 UTC (rev 104738)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/driver_unittest.py 2012-01-11 21:36:24 UTC (rev 104739)
@@ -30,19 +30,28 @@
import unittest
from webkitpy.common.system.path import abspath_to_uri
-from webkitpy.common.host_mock import MockHost
+from webkitpy.common.system.systemhost_mock import MockSystemHost
from webkitpy.layout_tests.port import Port, Driver, DriverOutput
class DriverTest(unittest.TestCase):
def make_port(self):
- return Port(MockHost())
+ return Port(MockSystemHost())
+ def assertVirtual(self, method, *args, **kwargs):
+ self.assertRaises(NotImplementedError, method, *args, **kwargs)
+
def _assert_wrapper(self, wrapper_string, expected_wrapper):
- wrapper = Driver(Port(MockHost()), None, pixel_tests=False)._command_wrapper(wrapper_string)
+ wrapper = Driver(self.make_port(), None, pixel_tests=False)._command_wrapper(wrapper_string)
self.assertEqual(wrapper, expected_wrapper)
+ def test_virtual_driver_methods(self):
+ driver = Driver(self.make_port(), None, pixel_tests=False)
+ self.assertVirtual(driver.run_test, None)
+ self.assertVirtual(driver.stop)
+ self.assertVirtual(driver.cmd_line)
+
def test_command_wrapper(self):
self._assert_wrapper(None, [])
self._assert_wrapper("valgrind", ["valgrind"])
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py (104738 => 104739)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py 2012-01-11 21:23:20 UTC (rev 104738)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py 2012-01-11 21:36:24 UTC (rev 104739)
@@ -33,20 +33,21 @@
import unittest
from webkitpy.common import newstringio
-
+from webkitpy.common.system.systemhost_mock import MockSystemHost
from webkitpy.layout_tests.port import mock_drt
from webkitpy.layout_tests.port import port_testcase
from webkitpy.layout_tests.port import test
+from webkitpy.layout_tests.port.factory import PortFactory
+from webkitpy.tool import mocktool
-from webkitpy.common.host_mock import MockHost
-from webkitpy.tool import mocktool
mock_options = mocktool.MockOptions(configuration='Release')
class MockDRTPortTest(port_testcase.PortTestCase):
def make_port(self, options=mock_options):
- host = MockHost()
+ host = MockSystemHost()
+ test.add_unit_tests_to_mock_filesystem(host.filesystem)
if sys.platform == 'win32':
# We use this because the 'win' port doesn't work yet.
return mock_drt.MockDRTPort(host, port_name='mock-chromium-win', options=options)
@@ -57,7 +58,7 @@
pass
def test_port_name_in_constructor(self):
- self.assertTrue(mock_drt.MockDRTPort(MockHost(), port_name='mock-test'))
+ self.assertTrue(mock_drt.MockDRTPort(MockSystemHost(), port_name='mock-test'))
def test_check_sys_deps(self):
pass
@@ -139,8 +140,9 @@
def assertTest(self, test_name, pixel_tests, expected_checksum=None, drt_output=None, host=None):
port_name = 'test'
- host = host or MockHost()
- port = host.port_factory.get(port_name)
+ host = host or MockSystemHost()
+ test.add_unit_tests_to_mock_filesystem(host.filesystem)
+ port = PortFactory(host).get(port_name)
drt_input, drt_output = self.make_input_output(port, test_name,
pixel_tests, expected_checksum, drt_output)
@@ -161,7 +163,8 @@
self.assertEqual(stderr.getvalue(), '')
def test_main(self):
- host = MockHost()
+ host = MockSystemHost()
+ test.add_unit_tests_to_mock_filesystem(host.filesystem)
stdin = newstringio.StringIO()
stdout = newstringio.StringIO()
stderr = newstringio.StringIO()
@@ -234,8 +237,8 @@
'#EOF\n']
def test_pixeltest__fails(self):
- host = MockHost()
- url = '' % host.port_factory.get('test').layout_tests_dir()
+ host = MockSystemHost()
+ url = '' % PortFactory(host).get('test').layout_tests_dir()
self.assertTest('failures/expected/checksum.html', pixel_tests=True,
expected_checksum='wrong-checksum',
drt_output=[url + '\n',
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/qt_unittest.py (104738 => 104739)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/qt_unittest.py 2012-01-11 21:23:20 UTC (rev 104738)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/qt_unittest.py 2012-01-11 21:36:24 UTC (rev 104739)
@@ -28,13 +28,12 @@
import unittest
-from webkitpy.common.system.executive_mock import MockExecutive2
+from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2
from webkitpy.common.system.outputcapture import OutputCapture
-from webkitpy.layout_tests.port.qt import QtPort
+from webkitpy.common.system.systemhost_mock import MockSystemHost
from webkitpy.layout_tests.port import port_testcase
+from webkitpy.layout_tests.port.qt import QtPort
from webkitpy.tool.mocktool import MockOptions
-from webkitpy.common.system.executive_mock import MockExecutive
-from webkitpy.common.host_mock import MockHost
class QtPortTest(port_testcase.PortTestCase):
@@ -44,7 +43,7 @@
# 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.
- host = MockHost()
+ host = MockSystemHost()
host.executive = MockExecutive2(self._qt_version(qt_version))
port = QtPort(host, sys_platform=sys_platform, options=MockOptions(webkit_test_runner=use_webkit2, platform='qt'))
absolute_search_paths = map(port._webkit_baseline_path, search_paths)
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit_unittest.py (104738 => 104739)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit_unittest.py 2012-01-11 21:23:20 UTC (rev 104738)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit_unittest.py 2012-01-11 21:36:24 UTC (rev 104739)
@@ -28,10 +28,10 @@
import logging
import unittest
-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.common.system.outputcapture import OutputCapture
+from webkitpy.common.system.systemhost_mock import MockSystemHost
from webkitpy.layout_tests.models.test_configuration import TestConfiguration
from webkitpy.layout_tests.port import port_testcase
from webkitpy.layout_tests.port.webkit import WebKitPort, WebKitDriver
@@ -46,7 +46,7 @@
**kwargs):
self.symbols_string = symbols_string # Passing "" disables all staticly-detectable features.
self.feature_list = feature_list # Passing [] disables all runtime-detectable features.
- host = host or MockHost()
+ host = host or MockSystemHost()
WebKitPort.__init__(self, host=host, **kwargs)
def all_test_configurations(self):
@@ -69,13 +69,13 @@
def test_default_options(self):
# The WebKit ports override new-run-webkit-test default options.
options = MockOptions(pixel_tests=None, time_out_ms=None)
- port = WebKitPort(MockHost(), options=options)
+ port = WebKitPort(MockSystemHost(), options=options)
self.assertEquals(port._options.pixel_tests, False)
self.assertEquals(port._options.time_out_ms, 35000)
# Note that we don't override options if specified by the user.
options = MockOptions(pixel_tests=True, time_out_ms=6000)
- port = WebKitPort(MockHost(), options=options)
+ port = WebKitPort(MockSystemHost(), options=options)
self.assertEquals(port._options.pixel_tests, True)
self.assertEquals(port._options.time_out_ms, 6000)
@@ -125,7 +125,7 @@
self.assertEqual(result_directories, expected_directories)
def test_runtime_feature_list(self):
- port = WebKitPort(MockHost())
+ port = WebKitPort(MockSystemHost())
port._executive.run_command = lambda command, cwd=None, error_handler=None: "Nonsense"
# runtime_features_list returns None when its results are meaningless (it couldn't run DRT or parse the output, etc.)
self.assertEquals(port._runtime_feature_list(), None)
@@ -156,7 +156,7 @@
def test_test_expectations(self):
# Check that we read the expectations file
- host = MockHost()
+ host = MockSystemHost()
host.filesystem.write_text_file('/mock-checkout/LayoutTests/platform/testwebkitport/test_expectations.txt',
'BUG_TESTEXPECTATIONS SKIP : fast/html/article-element.html = FAIL\n')
port = TestWebKitPort(host=host)