Changeset 99773 in webkit
- Timestamp:
- Nov 9, 2011 3:40:48 PM (12 years ago)
- Location:
- trunk/Tools
- Files:
-
- 40 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r99770 r99773 1 2011-11-09 Eric Seidel <eric@webkit.org> 2 3 Make the Port object have a Host 4 https://bugs.webkit.org/show_bug.cgi?id=71961 5 6 Reviewed by Adam Barth. 7 8 This has been a long time coming. 9 Now that Port has a Host object, it's very easy 10 to write unittests which use a properly mocked Port. 11 Soon we will remove the executive, filesystem and user 12 members of Port and get everything through the Host. 13 14 Note how in many callsites we're actually removing 15 explicit mocks, since we're now always going to get the 16 correct Executive/User/FileSystem from the 17 Host and callsites don't need to be careful to pass each one. 18 19 This is prep-work for adding a new Environment member to 20 Host and needing to be able to access the Environment 21 member from Port functions w/o needing to pass an Environment 22 object (or appropriate Mock) every place we create a Port object. 23 Now that we have a single Host object to reach out through, its 24 simple to add additional functionality (like Environment) while 25 keeping our unittests properly mocked. 26 27 * Scripts/webkitpy/common/host.py: 28 * Scripts/webkitpy/common/net/credentials_unittest.py: 29 * Scripts/webkitpy/layout_tests/controllers/manager_unittest.py: 30 * Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py: 31 * Scripts/webkitpy/layout_tests/port/apple.py: 32 * Scripts/webkitpy/layout_tests/port/base.py: 33 * Scripts/webkitpy/layout_tests/port/base_unittest.py: 34 * Scripts/webkitpy/layout_tests/port/chromium.py: 35 * Scripts/webkitpy/layout_tests/port/chromium_gpu.py: 36 * Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py: 37 * Scripts/webkitpy/layout_tests/port/chromium_linux.py: 38 * Scripts/webkitpy/layout_tests/port/chromium_linux_unittest.py: 39 * Scripts/webkitpy/layout_tests/port/chromium_mac.py: 40 * Scripts/webkitpy/layout_tests/port/chromium_mac_unittest.py: 41 * Scripts/webkitpy/layout_tests/port/chromium_unittest.py: 42 * Scripts/webkitpy/layout_tests/port/chromium_win.py: 43 * Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py: 44 * Scripts/webkitpy/layout_tests/port/dryrun.py: 45 * Scripts/webkitpy/layout_tests/port/efl.py: 46 * Scripts/webkitpy/layout_tests/port/factory.py: 47 * Scripts/webkitpy/layout_tests/port/google_chrome.py: 48 * Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py: 49 * Scripts/webkitpy/layout_tests/port/gtk.py: 50 * Scripts/webkitpy/layout_tests/port/mac.py: 51 * Scripts/webkitpy/layout_tests/port/mac_unittest.py: 52 * Scripts/webkitpy/layout_tests/port/mock_drt.py: 53 * Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py: 54 * Scripts/webkitpy/layout_tests/port/port_testcase.py: 55 * Scripts/webkitpy/layout_tests/port/qt.py: 56 * Scripts/webkitpy/layout_tests/port/qt_unittest.py: 57 * Scripts/webkitpy/layout_tests/port/test.py: 58 * Scripts/webkitpy/layout_tests/port/webkit.py: 59 * Scripts/webkitpy/layout_tests/port/webkit_unittest.py: 60 * Scripts/webkitpy/layout_tests/port/win.py: 61 * Scripts/webkitpy/layout_tests/port/win_unittest.py: 62 * Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py: 63 * Scripts/webkitpy/to_be_moved/rebaseline_chromium_webkit_tests_unittest.py: 64 * Scripts/webkitpy/tool/servers/rebaselineserver.py: 65 * Scripts/webkitpy/tool/servers/rebaselineserver_unittest.py: 66 1 67 2011-11-09 Dominic Mazzoni <dmazzoni@google.com> 2 68 -
trunk/Tools/Scripts/webkitpy/common/host.py
r99326 r99773 61 61 # In order to instantiate a port correctly, we have to pass it at least an executive, user, scm, and filesystem 62 62 # so for now we just pass along the whole Host object. 63 # FIXME: PortFactory doesn't belong on this Host object if Port is going to have a Host (circular dependency). 63 64 self.port_factory = PortFactory(self) 64 65 -
trunk/Tools/Scripts/webkitpy/common/net/credentials_unittest.py
r99140 r99773 38 38 from webkitpy.tool.mocktool import MockOptions 39 39 from webkitpy.common.system.executive_mock import MockExecutive 40 from webkitpy.common.system.user_mock import MockUser41 40 42 41 -
trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py
r99233 r99773 48 48 from webkitpy.tool.mocktool import MockOptions 49 49 from webkitpy.common.system.executive_mock import MockExecutive 50 from webkitpy.common.system.user_mock import MockUser51 50 from webkitpy.common.host_mock import MockHost 52 51 … … 189 188 options, args = run_webkit_tests.parse_args(['--platform=test', '--print=nothing', 'http/tests/passes', 'passes']) 190 189 host = MockHost() 191 port = host.port_factory.get(port_name=options.platform, options=options , user=MockUser(), executive=MockExecutive())190 port = host.port_factory.get(port_name=options.platform, options=options) 192 191 run_webkit_tests._set_up_derived_options(port, options) 193 192 printer = printing.Printer(port, options, StringIO.StringIO(), StringIO.StringIO(), configure_logging=True) -
trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py
r99233 r99773 53 53 multiprocessing = None 54 54 55 from webkitpy. layout_tests.port.factory import PortFactory55 from webkitpy.common.host import Host # FIXME: This should not be needed! 56 56 from webkitpy.layout_tests.controllers import message_broker 57 57 from webkitpy.layout_tests.views import printing … … 253 253 def run(self): 254 254 options = self._options 255 # FIXME: This should get the PortFactory from the Host. 256 port_obj = PortFactory().get(self._platform_name, options) 255 # FIXME: This should get the Host from the owner of this object 256 # so this function can be properly mocked! 257 host = Host() 258 port_obj = host.port_factory.get(self._platform_name, options) 257 259 258 260 # The unix multiprocessing implementation clones the -
trunk/Tools/Scripts/webkitpy/layout_tests/port/apple.py
r93176 r99773 57 57 return port_name[len(self.port_name + '-'):] 58 58 59 def __init__(self, port_name=None, os_version_string=None, **kwargs):59 def __init__(self, host, port_name=None, os_version_string=None, **kwargs): 60 60 port_name = port_name or self.port_name 61 WebKitPort.__init__(self, port_name=port_name, **kwargs)61 WebKitPort.__init__(self, host, port_name=port_name, **kwargs) 62 62 63 63 # FIXME: This sort of parsing belongs in factory.py! -
trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py
r98877 r99773 48 48 multiprocessing = None 49 49 50 from webkitpy.common import system51 50 from webkitpy.common.system import logutils 52 51 from webkitpy.common.system import path 53 from webkitpy.common.system.executive import Executive, ScriptError 54 from webkitpy.common.system.user import User 52 from webkitpy.common.system.executive import ScriptError 55 53 from webkitpy.layout_tests import read_checksum_from_png 56 54 from webkitpy.layout_tests.models.test_configuration import TestConfiguration … … 68 66 """Fake implementation of optparse.Values. Cloned from webkitpy.tool.mocktool.MockOptions.""" 69 67 70 def __init__(self, * *kwargs):68 def __init__(self, *args, **kwargs): 71 69 # The caller can set option values using keyword arguments. We don't 72 70 # set any values by default because we don't know how this … … 89 87 ALL_BUILD_TYPES = ('debug', 'release') 90 88 91 def __init__(self, port_name=None, options=None, 89 def __init__(self, host, 90 port_name=None, options=None, 92 91 executive=None, 93 92 user=None, … … 108 107 self.options = options or DummyOptions() 109 108 110 self.executive = executive or Executive() 111 self.user = user or User() 112 self.filesystem = filesystem or system.filesystem.FileSystem() 109 self.host = host 110 111 # FIXME: Remove thes accessors once all callers have moved to using self.host. 112 self.executive = executive or self.host.executive 113 self.user = user or self.host.user 114 self.filesystem = filesystem or self.host.filesystem 113 115 self.config = config or port_config.Config(self.executive, self.filesystem) 114 116 -
trunk/Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py
r99140 r99773 40 40 from webkitpy.tool.mocktool import MockOptions 41 41 from webkitpy.common.system.executive_mock import MockExecutive 42 from webkitpy.common.system.user_mock import MockUser 43 42 from webkitpy.common.host_mock import MockHost 44 43 45 44 from webkitpy.layout_tests.port import Port, Driver, DriverOutput … … 51 50 class PortTest(unittest.TestCase): 52 51 def make_port(self, *args, **kwargs): 53 kwargs.setdefault('filesystem', MockFileSystem()) 54 kwargs.setdefault('user', MockUser()) 55 kwargs.setdefault('executive', MockExecutive()) 52 kwargs.setdefault('host', MockHost()) 56 53 return Port(*args, **kwargs) 57 54 … … 285 282 286 283 def test_virtual_methods(self): 287 port = Port( )284 port = Port(MockHost()) 288 285 self.assertVirtual(port.baseline_path) 289 286 self.assertVirtual(port.baseline_search_path) -
trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium.py
r99006 r99773 89 89 } 90 90 91 def __init__(self, **kwargs):92 Port.__init__(self, **kwargs)91 def __init__(self, host, **kwargs): 92 Port.__init__(self, host, **kwargs) 93 93 # All sub-classes override this, but we need an initial value for testing. 94 94 self._version = 'xp' -
trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_gpu.py
r99068 r99773 34 34 35 35 36 def get( platform=None, port_name='chromium-gpu', **kwargs):36 def get(host, platform=None, port_name='chromium-gpu', **kwargs): 37 37 """Some tests have slightly different results when run while using 38 38 hardware acceleration. In those cases, we prepend an additional directory … … 50 50 51 51 if port_name.startswith('chromium-gpu-linux'): 52 return ChromiumGpuLinuxPort( port_name=port_name, **kwargs)52 return ChromiumGpuLinuxPort(host, port_name=port_name, **kwargs) 53 53 if port_name.startswith('chromium-gpu-cg-mac'): 54 return ChromiumGpuCgMacPort( port_name=port_name, **kwargs)54 return ChromiumGpuCgMacPort(host, port_name=port_name, **kwargs) 55 55 if port_name.startswith('chromium-gpu-mac'): 56 return ChromiumGpuMacPort( port_name=port_name, **kwargs)56 return ChromiumGpuMacPort(host, port_name=port_name, **kwargs) 57 57 if port_name.startswith('chromium-gpu-win'): 58 return ChromiumGpuWinPort( port_name=port_name, **kwargs)58 return ChromiumGpuWinPort(host, port_name=port_name, **kwargs) 59 59 raise NotImplementedError('unsupported port: %s' % port_name) 60 60 … … 91 91 92 92 class ChromiumGpuLinuxPort(chromium_linux.ChromiumLinuxPort): 93 def __init__(self, port_name='chromium-gpu-linux', **kwargs):94 chromium_linux.ChromiumLinuxPort.__init__(self, port_name=port_name, **kwargs)93 def __init__(self, host, port_name='chromium-gpu-linux', **kwargs): 94 chromium_linux.ChromiumLinuxPort.__init__(self, host, port_name=port_name, **kwargs) 95 95 _set_gpu_options(self) 96 96 … … 105 105 106 106 class ChromiumGpuCgMacPort(chromium_mac.ChromiumMacPort): 107 def __init__(self, port_name='chromium-gpu-cg-mac', **kwargs):108 chromium_mac.ChromiumMacPort.__init__(self, port_name=port_name, **kwargs)107 def __init__(self, host, port_name='chromium-gpu-cg-mac', **kwargs): 108 chromium_mac.ChromiumMacPort.__init__(self, host, port_name=port_name, **kwargs) 109 109 _set_gpu_options(self, graphics_type='gpu-cg') 110 110 … … 118 118 119 119 class ChromiumGpuMacPort(chromium_mac.ChromiumMacPort): 120 def __init__(self, port_name='chromium-gpu-mac', **kwargs):121 chromium_mac.ChromiumMacPort.__init__(self, port_name=port_name, **kwargs)120 def __init__(self, host, port_name='chromium-gpu-mac', **kwargs): 121 chromium_mac.ChromiumMacPort.__init__(self, host, port_name=port_name, **kwargs) 122 122 _set_gpu_options(self) 123 123 … … 131 131 132 132 class ChromiumGpuWinPort(chromium_win.ChromiumWinPort): 133 def __init__(self, port_name='chromium-gpu-win', **kwargs):134 chromium_win.ChromiumWinPort.__init__(self, port_name=port_name, **kwargs)133 def __init__(self, host, port_name='chromium-gpu-win', **kwargs): 134 chromium_win.ChromiumWinPort.__init__(self, host, port_name=port_name, **kwargs) 135 135 _set_gpu_options(self) 136 136 -
trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py
r99233 r99773 59 59 60 60 def assert_port_works(self, port_name, input_name=None, platform=None): 61 host = MockHost() 62 host.filesystem = FileSystem() # FIXME: This test should not use a real filesystem! 63 61 64 # test that we got the right port 62 65 mock_options = MockOptions(accelerated_compositing=None, … … 65 68 child_processes=None) 66 69 if input_name and platform: 67 port = chromium_gpu.get(platform=platform, port_name=input_name, 68 options=mock_options) 70 port = chromium_gpu.get(host, platform=platform, port_name=input_name, options=mock_options) 69 71 else: 70 port = chromium_gpu.get( port_name=port_name, options=mock_options)72 port = chromium_gpu.get(host, port_name=port_name, options=mock_options) 71 73 self.assertTrue(port._options.accelerated_compositing) 72 74 self.assertTrue(port._options.accelerated_2d_canvas) -
trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_linux.py
r90697 r99773 28 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 29 30 """Chromium Linux implementation of the Port interface."""31 32 30 import logging 33 34 31 import chromium 35 32 … … 59 56 } 60 57 61 def __init__(self, port_name=None, **kwargs):58 def __init__(self, host, port_name=None, **kwargs): 62 59 port_name = port_name or 'chromium-linux' 63 chromium.ChromiumPort.__init__(self, port_name=port_name, **kwargs)60 chromium.ChromiumPort.__init__(self, host, port_name=port_name, **kwargs) 64 61 # We re-set the port name once the base object is fully initialized 65 62 # in order to be able to find the DRT binary properly. -
trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_linux_unittest.py
r89031 r99773 30 30 31 31 from webkitpy.common.system import executive_mock 32 from webkitpy.common. system import filesystem_mock32 from webkitpy.common.host_mock import MockHost 33 33 34 34 from webkitpy.layout_tests.port import chromium_linux … … 44 44 def assert_architecture(self, port_name=None, file_output=None, 45 45 expected_architecture=None): 46 filesystem = filesystem_mock.MockFileSystem() 47 filesystem.exists = lambda x: 'DumpRenderTree' in x 48 executive = None 46 host = MockHost() 47 host.filesystem.exists = lambda x: 'DumpRenderTree' in x 49 48 if file_output: 50 executive = executive_mock.MockExecutive2(file_output)49 host.executive = executive_mock.MockExecutive2(file_output) 51 50 52 port = chromium_linux.ChromiumLinuxPort(port_name=port_name, 53 executive=executive, filesystem=filesystem) 51 port = chromium_linux.ChromiumLinuxPort(host, port_name=port_name) 54 52 self.assertEquals(port.architecture(), expected_architecture) 55 53 if expected_architecture == 'x86': … … 74 72 # FIXME: Check that, for now, these are illegal port names. 75 73 # Eventually we should be able to do the right thing here. 76 self.assertRaises(AssertionError, chromium_linux.ChromiumLinuxPort, 77 port_name='chromium-x86-linux') 78 self.assertRaises(AssertionError, chromium_linux.ChromiumLinuxPort, 79 port_name='chromium-linux-x86-gpu') 74 self.assertRaises(AssertionError, chromium_linux.ChromiumLinuxPort, MockHost(), port_name='chromium-x86-linux') 75 self.assertRaises(AssertionError, chromium_linux.ChromiumLinuxPort, MockHost(), port_name='chromium-linux-x86-gpu') 80 76 81 77 def test_determine_architecture_fails(self): 82 78 # Test that we default to 'x86' if the driver doesn't exist. 83 filesystem = filesystem_mock.MockFileSystem() 84 port = chromium_linux.ChromiumLinuxPort(filesystem=filesystem) 79 port = chromium_linux.ChromiumLinuxPort(MockHost()) 85 80 self.assertEquals(port.architecture(), 'x86_64') 86 81 87 82 # Test that we default to 'x86' on an unknown architecture. 88 filesystem = filesystem_mock.MockFileSystem() 89 filesystem.exists = lambda x: True 90 executive = executive_mock.MockExecutive2('win32') 91 port = chromium_linux.ChromiumLinuxPort(filesystem=filesystem, 92 executive=executive) 83 host = MockHost() 84 host.filesystem.exists = lambda x: True 85 host.executive = executive_mock.MockExecutive2('win32') 86 port = chromium_linux.ChromiumLinuxPort(host) 93 87 self.assertEquals(port.architecture(), 'x86_64') 94 88 95 89 # Test that we raise errors if something weird happens. 96 filesystem = filesystem_mock.MockFileSystem() 97 filesystem.exists = lambda x: True 98 executive = executive_mock.MockExecutive2(exception=AssertionError) 99 self.assertRaises(AssertionError, chromium_linux.ChromiumLinuxPort, 100 filesystem=filesystem, executive=executive) 90 host.executive = executive_mock.MockExecutive2(exception=AssertionError) 91 self.assertRaises(AssertionError, chromium_linux.ChromiumLinuxPort, host) 101 92 102 93 -
trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_mac.py
r99068 r99773 110 110 } 111 111 112 def __init__(self, port_name=None, os_version_string=None, **kwargs):112 def __init__(self, host, port_name=None, os_version_string=None, **kwargs): 113 113 # We're a little generic here because this code is reused by the 114 114 # 'google-chrome' port as well as the 'mock-' and 'dryrun-' ports. 115 115 port_name = port_name or 'chromium-cg-mac' 116 chromium.ChromiumPort.__init__(self, port_name=port_name, **kwargs)116 chromium.ChromiumPort.__init__(self, host, port_name=port_name, **kwargs) 117 117 if port_name.endswith('-mac'): 118 118 self._version = mac.os_version(os_version_string, self.SUPPORTED_OS_VERSIONS) -
trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_mac_unittest.py
r99068 r99773 30 30 31 31 from webkitpy.thirdparty.mock import Mock 32 from webkitpy.common.host_mock import MockHost 32 33 33 34 from webkitpy.layout_tests.port import chromium_mac … … 37 38 class ChromiumMacPortTest(port_testcase.PortTestCase): 38 39 def port_maker(self, platform): 40 # FIXME: This platform check should be removed! 39 41 if platform != 'darwin': 40 42 return None … … 42 44 43 45 def test_check_wdiff(self): 44 port = chromium_mac.ChromiumMacPort( )46 port = chromium_mac.ChromiumMacPort(MockHost()) 45 47 self.assertTrue(port.check_wdiff()) 46 48 47 49 def assert_name(self, port_name, os_version_string, expected): 48 port = chromium_mac.ChromiumMacPort(port_name=port_name, 49 os_version_string=os_version_string) 50 port = chromium_mac.ChromiumMacPort(MockHost(), port_name=port_name, os_version_string=os_version_string) 50 51 self.assertEquals(expected, port.name()) 51 52 52 53 def test_versions(self): 53 port = chromium_mac.ChromiumMacPort( )54 port = chromium_mac.ChromiumMacPort(MockHost()) 54 55 self.assertTrue(port.name() in ('chromium-cg-mac-leopard', 'chromium-cg-mac-snowleopard', 'chromium-cg-mac-lion', 'chromium-cg-mac-future')) 55 56 … … 76 77 77 78 def test_baseline_path(self): 78 port = chromium_mac.ChromiumMacPort( port_name='chromium-mac-leopard')79 port = chromium_mac.ChromiumMacPort(MockHost(), port_name='chromium-mac-leopard') 79 80 self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-mac-leopard')) 80 81 81 port = chromium_mac.ChromiumMacPort( port_name='chromium-mac-snowleopard')82 port = chromium_mac.ChromiumMacPort(MockHost(), port_name='chromium-mac-snowleopard') 82 83 self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-mac-snowleopard')) 83 84 84 port = chromium_mac.ChromiumMacPort( port_name='chromium-mac-lion')85 port = chromium_mac.ChromiumMacPort(MockHost(), port_name='chromium-mac-lion') 85 86 self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-mac')) 86 87 87 88 def test_graphics_type(self): 88 port = chromium_mac.ChromiumMacPort( port_name='chromium-cg-mac')89 port = chromium_mac.ChromiumMacPort(MockHost(), port_name='chromium-cg-mac') 89 90 self.assertEquals('cpu-cg', port.graphics_type()) 90 port = chromium_mac.ChromiumMacPort( port_name='chromium-mac')91 port = chromium_mac.ChromiumMacPort(MockHost(), port_name='chromium-mac') 91 92 self.assertEquals('cpu', port.graphics_type()) 92 93 # For now, Mac defaults to cpu-cg graphics type. 93 port = chromium_mac.ChromiumMacPort( )94 port = chromium_mac.ChromiumMacPort(MockHost()) 94 95 self.assertEquals('cpu-cg', port.graphics_type()) 95 96 -
trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py
r99233 r99773 33 33 from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2 34 34 from webkitpy.common.system.filesystem_mock import MockFileSystem 35 from webkitpy.common. system.user_mock import MockUser35 from webkitpy.common.host_mock import MockHost 36 36 from webkitpy.thirdparty.mock import Mock 37 37 from webkitpy.tool.mocktool import MockOptions … … 123 123 def test_all_test_configurations(self): 124 124 """Validate the complete set of configurations this port knows about.""" 125 port = chromium.ChromiumPort( )125 port = chromium.ChromiumPort(MockHost()) 126 126 self.assertEquals(set(port.all_test_configurations()), set([ 127 127 TestConfiguration('leopard', 'x86', 'debug', 'cpu'), … … 185 185 class TestMacPort(chromium_mac.ChromiumMacPort): 186 186 def __init__(self, options): 187 chromium_mac.ChromiumMacPort.__init__(self, options=options, 188 filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive()) 187 chromium_mac.ChromiumMacPort.__init__(self, MockHost(), options=options) 189 188 190 189 def default_configuration(self): … … 194 193 class TestLinuxPort(chromium_linux.ChromiumLinuxPort): 195 194 def __init__(self, options): 196 chromium_linux.ChromiumLinuxPort.__init__(self, options=options, 197 filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive()) 195 chromium_linux.ChromiumLinuxPort.__init__(self, MockHost(), options=options) 198 196 199 197 def default_configuration(self): … … 203 201 class TestWinPort(chromium_win.ChromiumWinPort): 204 202 def __init__(self, options): 205 chromium_win.ChromiumWinPort.__init__(self, options=options, 206 filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive()) 203 chromium_win.ChromiumWinPort.__init__(self, MockHost(), options=options) 207 204 208 205 def default_configuration(self): -
trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win.py
r99233 r99773 86 86 } 87 87 88 def __init__(self, port_name=None, windows_version=None, **kwargs):88 def __init__(self, host, port_name=None, windows_version=None, **kwargs): 89 89 # We're a little generic here because this code is reused by the 90 90 # 'google-chrome' port as well as the 'mock-' and 'dryrun-' ports. 91 91 port_name = port_name or 'chromium-win' 92 chromium.ChromiumPort.__init__(self, port_name=port_name, **kwargs)92 chromium.ChromiumPort.__init__(self, host, port_name=port_name, **kwargs) 93 93 if port_name.endswith('-win'): 94 94 self._version = os_version(windows_version) -
trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py
r98833 r99773 32 32 33 33 from webkitpy.common.system import outputcapture 34 from webkitpy.common.host_mock import MockHost 34 35 from webkitpy.common.system.filesystem_mock import MockFileSystem 35 from webkitpy.tool import mocktool36 36 37 37 from webkitpy.layout_tests.port import chromium_win … … 72 72 return 73 73 74 port._executive = mocktool.MockExecutive(should_log=True)74 port._executive = MockExecutive(should_log=True) 75 75 self._port = port 76 76 port.path_from_chromium_base = self._mock_path_from_chromium_base … … 86 86 return 87 87 88 port._executive = mocktool.MockExecutive(should_log=True)88 port._executive = MockExecutive(should_log=True) 89 89 port.path_from_chromium_base = self._mock_path_from_chromium_base 90 90 self._port = port … … 95 95 96 96 def assert_name(self, port_name, windows_version, expected): 97 port = chromium_win.ChromiumWinPort(port_name=port_name, 98 windows_version=windows_version) 97 port = chromium_win.ChromiumWinPort(MockHost(), port_name=port_name, windows_version=windows_version) 99 98 self.assertEquals(expected, port.name()) 100 99 101 100 def test_versions(self): 102 port = chromium_win.ChromiumWinPort( )101 port = chromium_win.ChromiumWinPort(MockHost()) 103 102 self.assertTrue(port.name() in ('chromium-win-xp', 'chromium-win-vista', 'chromium-win-win7')) 104 103 … … 127 126 128 127 def test_baseline_path(self): 129 port = chromium_win.ChromiumWinPort( port_name='chromium-win-xp')128 port = chromium_win.ChromiumWinPort(MockHost(), port_name='chromium-win-xp') 130 129 self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-win-xp')) 131 130 132 port = chromium_win.ChromiumWinPort( port_name='chromium-win-vista')131 port = chromium_win.ChromiumWinPort(MockHost(), port_name='chromium-win-vista') 133 132 self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-win-vista')) 134 133 135 port = chromium_win.ChromiumWinPort( port_name='chromium-win-win7')134 port = chromium_win.ChromiumWinPort(MockHost(), port_name='chromium-win-win7') 136 135 self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-win')) 137 136 138 137 def test_build_path(self): 139 mock = MockFileSystem(files={ 140 '/mock-checkout/Source/WebKit/chromium/build/Release/DumpRenderTree.exe': 'exe'}) 138 host = MockHost() 139 host.filesystem = MockFileSystem(files={ 140 '/mock-checkout/Source/WebKit/chromium/build/Release/DumpRenderTree.exe': 'exe', 141 }) 141 142 142 port = chromium_win.ChromiumWinPort( filesystem=mock)143 port = chromium_win.ChromiumWinPort(host) 143 144 self.assertEquals( 144 145 '/mock-checkout/Source/WebKit/chromium/build/Release/DumpRenderTree.exe', -
trunk/Tools/Scripts/webkitpy/layout_tests/port/dryrun.py
r99233 r99773 58 58 """DryRun implementation of the Port interface.""" 59 59 60 def __init__(self, **kwargs):60 def __init__(self, host, **kwargs): 61 61 pfx = 'dryrun-' 62 62 if 'port_name' in kwargs: … … 65 65 else: 66 66 kwargs['port_name'] = None 67 # FIXME: This should get the PortFactory from a Host object. 68 self.__delegate = factory.PortFactory().get(**kwargs) 67 self.__delegate = host.port_factory.get(**kwargs) 69 68 70 69 def __getattr__(self, name): -
trunk/Tools/Scripts/webkitpy/layout_tests/port/efl.py
r98833 r99773 32 32 33 33 from webkitpy.layout_tests.models.test_configuration import TestConfiguration 34 from webkitpy.layout_tests.port import base, builders, server_process, webkit34 from webkitpy.layout_tests.port.webkit import WebKitPort 35 35 36 36 … … 38 38 39 39 40 class EflPort( webkit.WebKitPort):40 class EflPort(WebKitPort): 41 41 port_name = "efl" 42 42 43 def __init__(self, **kwargs):44 webkit.WebKitPort.__init__(self, **kwargs)43 def __init__(self, host, **kwargs): 44 WebKitPort.__init__(self, host, **kwargs) 45 45 self._version = self.port_name 46 46 … … 49 49 50 50 def setup_environ_for_server(self, server_name=None): 51 return webkit.WebKitPort.setup_environ_for_server(self, server_name)51 return WebKitPort.setup_environ_for_server(self, server_name) 52 52 53 53 def _generate_all_test_configurations(self): -
trunk/Tools/Scripts/webkitpy/layout_tests/port/factory.py
r99233 r99773 32 32 import re 33 33 import sys 34 35 from .test import unit_test_filesystem36 34 37 35 from webkitpy.layout_tests.port import builders … … 76 74 return dictionary[key] 77 75 78 def _get_kwargs(self, **kwargs):76 def _get_kwargs(self, host=None, **kwargs): 79 77 port_to_use = self._port_name_from_arguments_and_options(**kwargs) 80 78 … … 85 83 # provided to the port. The unit_test_filesystem has an extra 86 84 # _tests attribute which a bunch of unittests depend on. 85 from .test import unit_test_filesystem 87 86 self._set_default_overriding_none(kwargs, 'filesystem', unit_test_filesystem()) 88 87 elif port_to_use.startswith('dryrun'): … … 125 124 raise NotImplementedError('unsupported port: %s' % port_to_use) 126 125 127 # Make sure that any Ports created by this factory inherit 128 # the executive/user/filesystem from the provided host. 129 # FIXME: Eventually NRWT will use a Host object and Port will no longer store these pointers. 130 if self._host: 131 self._set_default_overriding_none(kwargs, 'executive', self._host.executive) 132 self._set_default_overriding_none(kwargs, 'user', self._host.user) 133 self._set_default_overriding_none(kwargs, 'filesystem', self._host.filesystem) 134 135 return maker(**kwargs) 126 host = host or self._host 127 return maker(host, **kwargs) 136 128 137 129 def all_port_names(self): -
trunk/Tools/Scripts/webkitpy/layout_tests/port/google_chrome.py
r85877 r99773 42 42 return chromium_overrides + port._filesystem.read_text_file(overrides_path) 43 43 44 def GetGoogleChromePort(**kwargs): 44 45 def GetGoogleChromePort(host, **kwargs): 45 46 """Some tests have slightly different results when compiled as Google 46 47 Chrome vs Chromium. In those cases, we prepend an additional directory to … … 55 56 class GoogleChromeLinux32Port(chromium_linux.ChromiumLinuxPort): 56 57 def baseline_search_path(self): 57 paths = chromium_linux.ChromiumLinuxPort.baseline_search_path( 58 self) 59 paths.insert(0, self._webkit_baseline_path( 60 'google-chrome-linux32')) 58 paths = chromium_linux.ChromiumLinuxPort.baseline_search_path(self) 59 paths.insert(0, self._webkit_baseline_path('google-chrome-linux32')) 61 60 return paths 62 61 63 62 def test_expectations_overrides(self): 64 return _test_expectations_overrides(self, 65 chromium_linux.ChromiumLinuxPort) 63 return _test_expectations_overrides(self, chromium_linux.ChromiumLinuxPort) 66 64 67 65 def architecture(self): 68 66 return 'x86' 69 67 70 return GoogleChromeLinux32Port( port_name='chromium-linux-x86', **kwargs)68 return GoogleChromeLinux32Port(host, port_name='chromium-linux-x86', **kwargs) 71 69 elif port_name == 'google-chrome-linux64': 72 70 import chromium_linux … … 74 72 class GoogleChromeLinux64Port(chromium_linux.ChromiumLinuxPort): 75 73 def baseline_search_path(self): 76 paths = chromium_linux.ChromiumLinuxPort.baseline_search_path( 77 self) 78 paths.insert(0, self._webkit_baseline_path( 79 'google-chrome-linux64')) 74 paths = chromium_linux.ChromiumLinuxPort.baseline_search_path(self) 75 paths.insert(0, self._webkit_baseline_path('google-chrome-linux64')) 80 76 return paths 81 77 82 78 def test_expectations_overrides(self): 83 return _test_expectations_overrides(self, 84 chromium_linux.ChromiumLinuxPort) 79 return _test_expectations_overrides(self, chromium_linux.ChromiumLinuxPort) 85 80 86 81 def architecture(self): 87 82 return 'x86_64' 88 83 89 return GoogleChromeLinux64Port( port_name='chromium-linux-x86_64', **kwargs)84 return GoogleChromeLinux64Port(host, port_name='chromium-linux-x86_64', **kwargs) 90 85 elif port_name.startswith('google-chrome-mac'): 91 86 import chromium_mac … … 93 88 class GoogleChromeMacPort(chromium_mac.ChromiumMacPort): 94 89 def baseline_search_path(self): 95 paths = chromium_mac.ChromiumMacPort.baseline_search_path( 96 self) 97 paths.insert(0, self._webkit_baseline_path( 98 'google-chrome-mac')) 90 paths = chromium_mac.ChromiumMacPort.baseline_search_path(self) 91 paths.insert(0, self._webkit_baseline_path('google-chrome-mac')) 99 92 return paths 100 93 101 94 def test_expectations_overrides(self): 102 return _test_expectations_overrides(self, 103 chromium_mac.ChromiumMacPort) 95 return _test_expectations_overrides(self, chromium_mac.ChromiumMacPort) 104 96 105 return GoogleChromeMacPort( **kwargs)97 return GoogleChromeMacPort(host, **kwargs) 106 98 elif port_name.startswith('google-chrome-win'): 107 99 import chromium_win … … 109 101 class GoogleChromeWinPort(chromium_win.ChromiumWinPort): 110 102 def baseline_search_path(self): 111 paths = chromium_win.ChromiumWinPort.baseline_search_path( 112 self) 113 paths.insert(0, self._webkit_baseline_path( 114 'google-chrome-win')) 103 paths = chromium_win.ChromiumWinPort.baseline_search_path(self) 104 paths.insert(0, self._webkit_baseline_path('google-chrome-win')) 115 105 return paths 116 106 117 107 def test_expectations_overrides(self): 118 return _test_expectations_overrides(self, 119 chromium_win.ChromiumWinPort) 108 return _test_expectations_overrides(self, chromium_win.ChromiumWinPort) 120 109 121 return GoogleChromeWinPort( **kwargs)110 return GoogleChromeWinPort(host, **kwargs) 122 111 raise NotImplementedError('unsupported port: %s' % port_name) -
trunk/Tools/Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py
r99233 r99773 29 29 from webkitpy.common.host_mock import MockHost 30 30 from webkitpy.common.system.filesystem_mock import MockFileSystem 31 from webkitpy.common.system.user_mock import MockUser32 31 from webkitpy.common.system.executive_mock import MockExecutive 33 32 … … 48 47 49 48 def _verify_baseline_path(self, expected_path, port_name): 50 port = google_chrome.GetGoogleChromePort(port_name=port_name, options=None, filesystem=MockFileSystem(), executive=MockExecutive(), user=MockUser())49 port = google_chrome.GetGoogleChromePort(port_name=port_name, options=None, host=MockHost()) 51 50 path = port.baseline_search_path()[0] 52 51 self.assertEqual(expected_path, port._filesystem.basename(path)) … … 60 59 chromium_port = host.port_factory.get("chromium-cg-mac") 61 60 chromium_base = chromium_port.path_from_chromium_base() 62 fs = MockFileSystem() 63 port = google_chrome.GetGoogleChromePort(port_name=port_name, options=None, filesystem=fs, executive=MockExecutive(), user=MockUser()) 61 port = google_chrome.GetGoogleChromePort(port_name=port_name, options=None, host=host) 64 62 65 63 expected_chromium_overrides = '// chromium overrides\n' 66 64 expected_chrome_overrides = '// chrome overrides\n' 67 chromium_path = fs.join(chromium_base, 'webkit', 'tools', 'layout_tests', 'test_expectations.txt')68 chrome_path = fs.join(chromium_base, 'webkit', 'tools', 'layout_tests', 'test_expectations_chrome.txt')65 chromium_path = host.filesystem.join(chromium_base, 'webkit', 'tools', 'layout_tests', 'test_expectations.txt') 66 chrome_path = host.filesystem.join(chromium_base, 'webkit', 'tools', 'layout_tests', 'test_expectations_chrome.txt') 69 67 70 fs.files[chromium_path] = expected_chromium_overrides71 fs.files[chrome_path] = None68 host.filesystem.files[chromium_path] = expected_chromium_overrides 69 host.filesystem.files[chrome_path] = None 72 70 actual_chrome_overrides = port.test_expectations_overrides() 73 71 self.assertEqual(expected_chromium_overrides, actual_chrome_overrides) 74 72 75 fs.files[chrome_path] = expected_chrome_overrides73 host.filesystem.files[chrome_path] = expected_chrome_overrides 76 74 actual_chrome_overrides = port.test_expectations_overrides() 77 75 self.assertEqual(actual_chrome_overrides, expected_chromium_overrides + expected_chrome_overrides) -
trunk/Tools/Scripts/webkitpy/layout_tests/port/gtk.py
r99377 r99773 27 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 29 from __future__ import with_statement 30 29 31 """WebKit Gtk implementation of the Port interface.""" 30 32 … … 35 37 36 38 from webkitpy.layout_tests.models.test_configuration import TestConfiguration 37 from webkitpy.layout_tests.port import base, builders, server_process, webkit 39 from webkitpy.layout_tests.port.server_process import ServerProcess 40 from webkitpy.layout_tests.port.webkit import WebKitDriver, WebKitPort 38 41 39 42 … … 41 44 42 45 43 class GtkDriver( webkit.WebKitDriver):46 class GtkDriver(WebKitDriver): 44 47 def start(self): 45 48 display_id = self._worker_number + 1 46 49 run_xvfb = ["Xvfb", ":%d" % (display_id), "-screen", "0", "800x600x24", "-nolisten", "tcp"] 47 devnull = open(os.devnull, 'w') 48 self._xvfb_process = subprocess.Popen(run_xvfb, stderr=devnull) 49 devnull.close() 50 with open(os.devnull, 'w') as devnull: 51 self._xvfb_process = subprocess.Popen(run_xvfb, stderr=devnull) 50 52 server_name = self._port.driver_name() 51 53 environment = self._port.setup_environ_for_server(server_name) 52 54 # We must do this here because the DISPLAY number depends on _worker_number 53 55 environment['DISPLAY'] = ":%d" % (display_id) 54 self._server_process = server_process.ServerProcess(self._port, server_name, self.cmd_line(), environment)56 self._server_process = ServerProcess(self._port, server_name, self.cmd_line(), environment) 55 57 56 58 def stop(self): 57 webkit.WebKitDriver.stop(self) 59 WebKitDriver.stop(self) 60 # FIXME: This should use Executive.kill_process 58 61 os.kill(self._xvfb_process.pid, signal.SIGTERM) 59 62 self._xvfb_process.wait() 60 63 61 64 62 class GtkPort( webkit.WebKitPort):65 class GtkPort(WebKitPort): 63 66 port_name = "gtk" 64 67 65 def __init__(self, **kwargs):66 webkit.WebKitPort.__init__(self, **kwargs)68 def __init__(self, host, **kwargs): 69 WebKitPort.__init__(self, host, **kwargs) 67 70 self._version = self.port_name 68 71 … … 74 77 75 78 def setup_environ_for_server(self, server_name=None): 76 environment = webkit.WebKitPort.setup_environ_for_server(self, server_name)79 environment = WebKitPort.setup_environ_for_server(self, server_name) 77 80 environment['GTK_MODULES'] = 'gail' 78 81 environment['LIBOVERLAY_SCROLLBAR'] = '0' -
trunk/Tools/Scripts/webkitpy/layout_tests/port/mac.py
r98833 r99773 75 75 return os_version(os_version_string) 76 76 77 def __init__(self, **kwargs):78 ApplePort.__init__(self, **kwargs)77 def __init__(self, host, **kwargs): 78 ApplePort.__init__(self, host, **kwargs) 79 79 self._operating_system = 'mac' 80 80 self._leak_detector = LeakDetector(self) -
trunk/Tools/Scripts/webkitpy/layout_tests/port/mac_unittest.py
r99140 r99773 33 33 from webkitpy.tool.mocktool import MockOptions 34 34 from webkitpy.common.system.executive_mock import MockExecutive 35 from webkitpy.common. system.user_mock import MockUser35 from webkitpy.common.host_mock import MockHost 36 36 37 37 … … 44 44 45 45 def assert_skipped_file_search_paths(self, port_name, expected_paths): 46 port = MacPort( port_name=port_name, filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())46 port = MacPort(MockHost(), port_name=port_name) 47 47 self.assertEqual(port._skipped_file_search_paths(), expected_paths) 48 48 … … 75 75 76 76 def test_tests_from_skipped_file_contents(self): 77 port = MacPort( filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())77 port = MacPort(MockHost()) 78 78 self.assertEqual(port._tests_from_skipped_file_contents(self.example_skipped_file), self.example_skipped_tests) 79 79 80 80 def assert_name(self, port_name, os_version_string, expected): 81 port = MacPort( port_name=port_name, os_version_string=os_version_string, filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())81 port = MacPort(MockHost(), port_name=port_name, os_version_string=os_version_string) 82 82 self.assertEquals(expected, port.name()) 83 83 84 84 def test_tests_for_other_platforms(self): 85 85 platforms = ['mac', 'chromium-linux', 'mac-snowleopard'] 86 port = MacPort( port_name='mac-snowleopard', filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())86 port = MacPort(MockHost(), port_name='mac-snowleopard') 87 87 platform_dir_paths = map(port._webkit_baseline_path, platforms) 88 88 # Replace our empty mock file system with one which has our expected platform directories. … … 95 95 96 96 def test_version(self): 97 port = MacPort( filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())97 port = MacPort(MockHost()) 98 98 self.assertTrue(port.version()) 99 99 … … 119 119 120 120 def test_setup_environ_for_server(self): 121 port = MacPort( options=MockOptions(leaks=True, guard_malloc=True))121 port = MacPort(MockHost(), options=MockOptions(leaks=True, guard_malloc=True)) 122 122 env = port.setup_environ_for_server(port.driver_name()) 123 123 self.assertEquals(env['MallocStackLogging'], '1') … … 128 128 # rather be passed components (directly or via setters). Once 129 129 # we fix that, this method will need a re-write. 130 port = MacPort( port_name='mac-%s' % version, options=MockOptions(webkit_test_runner=use_webkit2), filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())130 port = MacPort(MockHost(), port_name='mac-%s' % version, options=MockOptions(webkit_test_runner=use_webkit2)) 131 131 absolute_search_paths = map(port._webkit_baseline_path, search_paths) 132 132 self.assertEquals(port.baseline_search_path(), absolute_search_paths) … … 143 143 144 144 def test_show_results_html_file(self): 145 port = MacPort( filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())145 port = MacPort(MockHost()) 146 146 # Delay setting a should_log executive to avoid logging from MacPort.__init__. 147 147 port._executive = MockExecutive(should_log=True) -
trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt.py
r99233 r99773 35 35 import base64 36 36 import logging 37 import optparse38 import os39 37 import sys 40 38 41 from webkitpy.common.system import filesystem 42 43 from webkitpy.layout_tests.port import base 44 from webkitpy.layout_tests.port.factory import PortFactory 39 from webkitpy.common.host import Host 45 40 from webkitpy.tool.mocktool import MockOptions 46 41 … … 52 47 """MockPort implementation of the Port interface.""" 53 48 54 def __init__(self, **kwargs):49 def __init__(self, host, **kwargs): 55 50 prefix = 'mock-' 56 51 if 'port_name' in kwargs: 57 52 kwargs['port_name'] = kwargs['port_name'][len(prefix):] 58 # FIXME: This should get the PortFactory from a Host object.59 self.__delegate = PortFactory().get(**kwargs)53 self._host = host 54 self.__delegate = host.port_factory.get(**kwargs) 60 55 self.__real_name = prefix + self.__delegate.name() 61 56 … … 77 72 78 73 def _path_to_driver(self): 79 return os.path.abspath(__file__)74 return self._host.filesystem.abspath(__file__) 80 75 81 76 def create_driver(self, worker_number): … … 89 84 cmd = self.__original_driver_cmd_line() 90 85 index = cmd.index(self.__delegate._path_to_driver()) 91 cmd[index:index + 1] = [sys.executable, self._path_to_driver(),92 86 # FIXME: Why does this need to use sys.executable (instead of something mockable)? 87 cmd[index:index + 1] = [sys.executable, self._path_to_driver(), '--platform', self.name()] 93 88 return cmd 94 89 … … 123 118 124 119 125 def main(argv, fs, stdin, stdout, stderr):120 def main(argv, host, stdin, stdout, stderr): 126 121 """Run the tests.""" 127 122 128 123 options, args = parse_options(argv) 129 124 if options.chromium: 130 drt = MockChromiumDRT(options, args, fs, stdin, stdout, stderr)125 drt = MockChromiumDRT(options, args, host, stdin, stdout, stderr) 131 126 else: 132 drt = MockDRT(options, args, fs, stdin, stdout, stderr)127 drt = MockDRT(options, args, host, stdin, stdout, stderr) 133 128 return drt.run() 134 129 … … 175 170 176 171 class MockDRT(object): 177 def __init__(self, options, args, filesystem, stdin, stdout, stderr):172 def __init__(self, options, args, host, stdin, stdout, stderr): 178 173 self._options = options 179 174 self._args = args 180 self._ filesystem = filesystem175 self._host = host 181 176 self._stdout = stdout 182 177 self._stdin = stdin … … 186 181 if options.platform: 187 182 port_name = options.platform 188 # FIXME: This should get the PortFactory from a Host object. 189 self._port = PortFactory().get(port_name, options=options, filesystem=filesystem) 183 self._port = self._host.port_factory.get(port_name, options=options) 190 184 191 185 def run(self): … … 271 265 if self._options.pixel_tests and test_input.checksum: 272 266 self._stdout.write("#MD5:%s\n" % actual_checksum) 273 self._ filesystem.write_binary_file(self._options.pixel_path,267 self._host.filesystem.write_binary_file(self._options.pixel_path, 274 268 actual_image) 275 269 self._stdout.write(actual_text) … … 284 278 285 279 if __name__ == '__main__': 286 fs = filesystem.FileSystem() 287 sys.exit(main(sys.argv[1:], fs, sys.stdin, sys.stdout, sys.stderr)) 280 # FIXME: Why is this using a real Host object instead of MockHost? 281 host = Host() 282 sys.exit(main(sys.argv[1:], host, sys.stdin, sys.stdout, sys.stderr)) -
trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py
r99233 r99773 49 49 if sys.platform == 'win32': 50 50 # We use this because the 'win' port doesn't work yet. 51 return mock_drt.MockDRTPort( port_name='mock-chromium-win', options=options)52 return mock_drt.MockDRTPort( options=options)51 return mock_drt.MockDRTPort(MockHost(), port_name='mock-chromium-win', options=options) 52 return mock_drt.MockDRTPort(MockHost(), options=options) 53 53 54 54 def test_default_worker_model(self): … … 57 57 58 58 def test_port_name_in_constructor(self): 59 self.assertTrue(mock_drt.MockDRTPort( port_name='mock-test'))59 self.assertTrue(mock_drt.MockDRTPort(MockHost(), port_name='mock-test')) 60 60 61 61 def test_check_sys_deps(self): … … 106 106 return ['-'] 107 107 108 def make_drt(self, options, args, filesystem, stdin, stdout, stderr):109 return mock_drt.MockDRT(options, args, filesystem, stdin, stdout, stderr)108 def make_drt(self, options, args, host, stdin, stdout, stderr): 109 return mock_drt.MockDRT(options, args, host, stdin, stdout, stderr) 110 110 111 111 def make_input_output(self, port, test_name, pixel_tests, … … 141 141 port_name = 'test' 142 142 host = MockHost() 143 filesystem = filesystem or test.unit_test_filesystem()144 port = host.port_factory.get(port_name , filesystem=filesystem)143 host.filesystem = filesystem or test.unit_test_filesystem() 144 port = host.port_factory.get(port_name) 145 145 drt_input, drt_output = self.make_input_output(port, test_name, 146 146 pixel_tests, expected_checksum, drt_output) … … 152 152 options, args = mock_drt.parse_options(args) 153 153 154 drt = self.make_drt(options, args, filesystem, stdin, stdout, stderr)154 drt = self.make_drt(options, args, host, stdin, stdout, stderr) 155 155 res = drt.run() 156 156 … … 163 163 164 164 def test_main(self): 165 filesystem = test.unit_test_filesystem() 165 host = MockHost() 166 host.filesystem = test.unit_test_filesystem() 166 167 stdin = newstringio.StringIO() 167 168 stdout = newstringio.StringIO() 168 169 stderr = newstringio.StringIO() 169 170 res = mock_drt.main(['--platform', 'test'] + self.extra_args(False), 170 filesystem, stdin, stdout, stderr)171 host, stdin, stdout, stderr) 171 172 self.assertEqual(res, 0) 172 173 self.assertEqual(stdout.getvalue(), '') 173 174 self.assertEqual(stderr.getvalue(), '') 174 self.assertEqual( filesystem.written_files, {})175 self.assertEqual(host.filesystem.written_files, {}) 175 176 176 177 def test_pixeltest_passes(self): … … 205 206 return [] 206 207 207 def make_drt(self, options, args, filesystem, stdin, stdout, stderr):208 def make_drt(self, options, args, host, stdin, stdout, stderr): 208 209 options.chromium = True 209 210 … … 213 214 options.pixel_tests = True 214 215 215 return mock_drt.MockChromiumDRT(options, args, filesystem, stdin, stdout, stderr)216 return mock_drt.MockChromiumDRT(options, args, host, stdin, stdout, stderr) 216 217 217 218 def input_line(self, port, test_name, checksum=None): -
trunk/Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py
r99140 r99773 47 47 from webkitpy.tool.mocktool import MockOptions 48 48 from webkitpy.common.system.executive_mock import MockExecutive 49 from webkitpy.common. system.user_mock import MockUser49 from webkitpy.common.host_mock import MockHost 50 50 mock_options = MockOptions(configuration='Release') 51 51 … … 69 69 return None 70 70 71 return maker(options=options, filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())71 return maker(options=options, host=MockHost()) 72 72 73 73 def test_default_worker_model(self): -
trunk/Tools/Scripts/webkitpy/layout_tests/port/qt.py
r98833 r99773 60 60 61 61 # sys_platform exists only for unit testing. 62 def __init__(self, sys_platform=None, **kwargs):63 WebKitPort.__init__(self, **kwargs)62 def __init__(self, host, sys_platform=None, **kwargs): 63 WebKitPort.__init__(self, host, **kwargs) 64 64 self._operating_system = self._operating_system_for_platform(sys_platform or sys.platform) 65 65 self._version = self._operating_system -
trunk/Tools/Scripts/webkitpy/layout_tests/port/qt_unittest.py
r99140 r99773 36 36 from webkitpy.tool.mocktool import MockOptions 37 37 from webkitpy.common.system.executive_mock import MockExecutive 38 from webkitpy.common. system.user_mock import MockUser38 from webkitpy.common.host_mock import MockHost 39 39 40 40 … … 49 49 port = QtPort(sys_platform=sys_platform, 50 50 options=MockOptions(webkit_test_runner=use_webkit2, platform='qt'), 51 filesystem=MockFileSystem(), 52 user=MockUser(), 51 host=MockHost(), 53 52 executive=MockExecutive2(self._qt_version(qt_version))) 54 53 absolute_search_paths = map(port._webkit_baseline_path, search_paths) -
trunk/Tools/Scripts/webkitpy/layout_tests/port/test.py
r99233 r99773 36 36 from webkitpy.layout_tests.port import Port, Driver, DriverOutput 37 37 from webkitpy.layout_tests.models.test_configuration import TestConfiguration 38 from webkitpy.common.system.user_mock import MockUser 39 from webkitpy.common.system.executive_mock import MockExecutive 38 from webkitpy.common.host_mock import MockHost 40 39 from webkitpy.common.system.filesystem_mock import MockFileSystem 41 40 … … 278 277 return dictionary[key] 279 278 280 def __init__(self, port_name=None, **kwargs):279 def __init__(self, host=None, port_name=None, **kwargs): 281 280 if not port_name or port_name == 'test': 282 281 port_name = 'test-mac-leopard' 283 282 284 self._set_default_overriding_none(kwargs, 'user', MockUser()) 285 self._set_default_overriding_none(kwargs, 'executive', MockExecutive()) 283 host = host or MockHost() 286 284 filesystem = self._set_default_overriding_none(kwargs, 'filesystem', unit_test_filesystem()) 287 285 288 Port.__init__(self, port_name=port_name, **kwargs)286 Port.__init__(self, host, port_name=port_name, **kwargs) 289 287 self._results_directory = None 290 288 -
trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py
r99469 r99773 50 50 51 51 class WebKitPort(Port): 52 def __init__(self, **kwargs):53 Port.__init__(self, **kwargs)52 def __init__(self, host, **kwargs): 53 Port.__init__(self, host, **kwargs) 54 54 55 55 # FIXME: Disable pixel tests until they are run by default on build.webkit.org. -
trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit_unittest.py
r99469 r99773 28 28 import unittest 29 29 30 from webkitpy.common.host_mock import MockHost 31 from webkitpy.common.system.executive_mock import MockExecutive 30 32 from webkitpy.common.system.filesystem_mock import MockFileSystem 31 33 from webkitpy.common.system.outputcapture import OutputCapture 32 33 34 from webkitpy.layout_tests.models.test_configuration import TestConfiguration 35 from webkitpy.layout_tests.port import port_testcase 34 36 from webkitpy.layout_tests.port.webkit import WebKitPort, WebKitDriver 35 from webkitpy.layout_tests.port import port_testcase36 37 37 from webkitpy.tool.mocktool import MockOptions 38 from webkitpy.common.system.executive_mock import MockExecutive39 from webkitpy.common.system.user_mock import MockUser40 41 38 42 39 … … 45 42 46 43 def __init__(self, symbols_string=None, feature_list=None, 47 expectations_file=None, skips_file=None, 48 executive=None, filesystem=None, user=None, 44 expectations_file=None, skips_file=None, host=None, 49 45 **kwargs): 50 46 self.symbols_string = symbols_string # Passing "" disables all staticly-detectable features. 51 47 self.feature_list = feature_list # Passing [] disables all runtime-detectable features. 52 executive = executive or MockExecutive(should_log=False) 53 filesystem = filesystem or MockFileSystem() 54 user = user or MockUser() 55 WebKitPort.__init__(self, executive=executive, filesystem=filesystem, user=MockUser(), **kwargs) 48 host = host or MockHost() 49 WebKitPort.__init__(self, host=host, **kwargs) 56 50 57 51 def all_test_configurations(self): … … 75 69 # The WebKit ports override new-run-webkit-test default options. 76 70 options = MockOptions(pixel_tests=None, time_out_ms=None) 77 port = WebKitPort( options=options)71 port = WebKitPort(MockHost(), options=options) 78 72 self.assertEquals(port._options.pixel_tests, False) 79 73 self.assertEquals(port._options.time_out_ms, 35000) … … 81 75 # Note that we don't override options if specified by the user. 82 76 options = MockOptions(pixel_tests=True, time_out_ms=6000) 83 port = WebKitPort( options=options)77 port = WebKitPort(MockHost(), options=options) 84 78 self.assertEquals(port._options.pixel_tests, True) 85 79 self.assertEquals(port._options.time_out_ms, 6000) … … 125 119 126 120 def test_runtime_feature_list(self): 127 port = WebKitPort( executive=MockExecutive())121 port = WebKitPort(MockHost()) 128 122 port._executive.run_command = lambda command, cwd=None, error_handler=None: "Nonsense" 129 123 # runtime_features_list returns None when its results are meaningless (it couldn't run DRT or parse the output, etc.) -
trunk/Tools/Scripts/webkitpy/layout_tests/port/win.py
r99233 r99773 75 75 return self._version_string_from_windows_version_tuple(version_tuple) 76 76 77 def __init__(self, **kwargs):78 ApplePort.__init__(self, **kwargs)77 def __init__(self, host, **kwargs): 78 ApplePort.__init__(self, host, **kwargs) 79 79 self._operating_system = 'win' 80 80 -
trunk/Tools/Scripts/webkitpy/layout_tests/port/win_unittest.py
r99233 r99773 34 34 from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2 35 35 from webkitpy.common.system.filesystem_mock import MockFileSystem 36 from webkitpy.common. system.user_mock import MockUser36 from webkitpy.common.host_mock import MockHost 37 37 from webkitpy.common.system.outputcapture import OutputCapture 38 38 from webkitpy.layout_tests.port import port_testcase … … 71 71 port = WinPort(os_version_string=version, 72 72 options=MockOptions(webkit_test_runner=use_webkit2), 73 filesystem=MockFileSystem(), 74 user=MockUser(), 75 executive=MockExecutive()) 73 host=MockHost()) 76 74 absolute_search_paths = map(port._webkit_baseline_path, expected_search_paths) 77 75 self.assertEquals(port.baseline_search_path(), absolute_search_paths) … … 89 87 90 88 def _assert_version(self, port_name, expected_version): 91 port = WinPort(port_name=port_name, filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())89 port = WinPort(port_name=port_name, host=MockHost()) 92 90 self.assertEquals(port.version(), expected_version) 93 91 -
trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py
r99461 r99773 62 62 from webkitpy.common import array_stream 63 63 from webkitpy.common.system import outputcapture 64 from webkitpy.common.system.user_mock import MockUser65 64 from webkitpy.common.host_mock import MockHost 66 65 … … 147 146 options, parsed_args = parse_args(extra_args, tests_included=True) 148 147 149 user = MockUser()148 host = MockHost() 150 149 151 150 test_batches = [] … … 180 179 return RecordingTestDriver(self, worker_number) 181 180 182 recording_port = RecordingTestPort(options=options, user=user, filesystem=filesystem)181 recording_port = RecordingTestPort(options=options, host=host, filesystem=filesystem) 183 182 run_and_capture(recording_port, options, parsed_args) 184 183 … … 468 467 469 468 options, parsed_args = run_webkit_tests.parse_args(['--pixel-tests', '--no-new-test-results']) 470 test_port = CustomExitCodePort(options=options , user=MockUser())469 test_port = CustomExitCodePort(options=options) 471 470 res, out, err, _ = logging_run(['--no-show-results', 472 471 'failures/expected/missing_image.html', … … 640 639 def get_port_for_run(args): 641 640 options, parsed_args = run_webkit_tests.parse_args(args) 642 test_port = ImageDiffTestPort(options=options , user=MockUser())641 test_port = ImageDiffTestPort(options=options) 643 642 res = passing_run(args, port_obj=test_port, tests_included=True) 644 643 self.assertTrue(res) -
trunk/Tools/Scripts/webkitpy/to_be_moved/rebaseline_chromium_webkit_tests_unittest.py
r99271 r99773 41 41 42 42 from webkitpy.common.checkout.scm.scm_mock import MockSCM 43 from webkitpy.common.system.user_mock import MockUser44 43 45 44 from webkitpy.layout_tests import port -
trunk/Tools/Scripts/webkitpy/tool/servers/rebaselineserver.py
r96252 r99773 32 32 import BaseHTTPServer 33 33 34 from webkitpy.common.host import Host # FIXME: This should not be needed! 34 35 from webkitpy.layout_tests.port.webkit import WebKitPort 35 36 from webkitpy.tool.servers.reflectionhandler import ReflectionHandler … … 165 166 class AllPlatformsPort(WebKitPort): 166 167 def __init__(self): 167 WebKitPort.__init__(self, filesystem=test_config.filesystem) 168 # FIXME: This should get the Host from the test_config to be mockable! 169 WebKitPort.__init__(self, Host(), filesystem=test_config.filesystem) 168 170 self._platforms_by_directory = dict([(self._webkit_baseline_path(p), p) for p in test_config.platforms]) 169 171 -
trunk/Tools/Scripts/webkitpy/tool/servers/rebaselineserver_unittest.py
r99140 r99773 35 35 import webkitpy.thirdparty.simplejson as json 36 36 37 38 from webkitpy.common.checkout.scm.scm_mock import MockSCM 37 39 from webkitpy.common.net import resultsjsonparser_unittest 38 from webkitpy.common.system import filesystem_mock 40 from webkitpy.common.system.filesystem_mock import MockFileSystem 41 from webkitpy.common.host_mock import MockHost 39 42 from webkitpy.layout_tests.layout_package.json_results_generator import strip_json_wrapper 40 43 from webkitpy.layout_tests.port.webkit import WebKitPort 41 44 from webkitpy.tool.commands.rebaselineserver import TestConfig, RebaselineServer 42 from webkitpy.common.checkout.scm.scm_mock import MockSCM43 45 from webkitpy.tool.servers import rebaselineserver 44 46 … … 300 302 layout_tests_directory = "/mock-checkout/LayoutTests" 301 303 results_directory = '/WebKitBuild/Debug/layout-test-results' 302 mock_filesystem = filesystem_mock.MockFileSystem()304 mock_filesystem = MockFileSystem() 303 305 for file in test_files: 304 306 file_path = mock_filesystem.join(layout_tests_directory, file) … … 311 313 port_name = "mac" 312 314 def __init__(self): 313 # FIXME: This should use MockExecutive and MockUser as well. 314 WebKitPort.__init__(self, filesystem=mock_filesystem) 315 WebKitPort.__init__(self, filesystem=mock_filesystem, host=MockHost()) 315 316 316 317 return TestConfig(
Note: See TracChangeset
for help on using the changeset viewer.