Changeset 99773 in webkit


Ignore:
Timestamp:
Nov 9, 2011 3:40:48 PM (12 years ago)
Author:
eric@webkit.org
Message:

Make the Port object have a Host
https://bugs.webkit.org/show_bug.cgi?id=71961

Reviewed by Adam Barth.

This has been a long time coming.
Now that Port has a Host object, it's very easy
to write unittests which use a properly mocked Port.
Soon we will remove the executive, filesystem and user
members of Port and get everything through the Host.

Note how in many callsites we're actually removing
explicit mocks, since we're now always going to get the
correct Executive/User/FileSystem from the
Host and callsites don't need to be careful to pass each one.

This is prep-work for adding a new Environment member to
Host and needing to be able to access the Environment
member from Port functions w/o needing to pass an Environment
object (or appropriate Mock) every place we create a Port object.
Now that we have a single Host object to reach out through, its
simple to add additional functionality (like Environment) while
keeping our unittests properly mocked.

  • Scripts/webkitpy/common/host.py:
  • Scripts/webkitpy/common/net/credentials_unittest.py:
  • Scripts/webkitpy/layout_tests/controllers/manager_unittest.py:
  • Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py:
  • Scripts/webkitpy/layout_tests/port/apple.py:
  • Scripts/webkitpy/layout_tests/port/base.py:
  • Scripts/webkitpy/layout_tests/port/base_unittest.py:
  • Scripts/webkitpy/layout_tests/port/chromium.py:
  • Scripts/webkitpy/layout_tests/port/chromium_gpu.py:
  • Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py:
  • Scripts/webkitpy/layout_tests/port/chromium_linux.py:
  • Scripts/webkitpy/layout_tests/port/chromium_linux_unittest.py:
  • Scripts/webkitpy/layout_tests/port/chromium_mac.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/dryrun.py:
  • Scripts/webkitpy/layout_tests/port/efl.py:
  • Scripts/webkitpy/layout_tests/port/factory.py:
  • Scripts/webkitpy/layout_tests/port/google_chrome.py:
  • Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py:
  • Scripts/webkitpy/layout_tests/port/gtk.py:
  • Scripts/webkitpy/layout_tests/port/mac.py:
  • Scripts/webkitpy/layout_tests/port/mac_unittest.py:
  • Scripts/webkitpy/layout_tests/port/mock_drt.py:
  • Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py:
  • Scripts/webkitpy/layout_tests/port/port_testcase.py:
  • Scripts/webkitpy/layout_tests/port/qt.py:
  • Scripts/webkitpy/layout_tests/port/qt_unittest.py:
  • Scripts/webkitpy/layout_tests/port/test.py:
  • Scripts/webkitpy/layout_tests/port/webkit.py:
  • Scripts/webkitpy/layout_tests/port/webkit_unittest.py:
  • Scripts/webkitpy/layout_tests/port/win.py:
  • Scripts/webkitpy/layout_tests/port/win_unittest.py:
  • Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:
  • Scripts/webkitpy/to_be_moved/rebaseline_chromium_webkit_tests_unittest.py:
  • Scripts/webkitpy/tool/servers/rebaselineserver.py:
  • Scripts/webkitpy/tool/servers/rebaselineserver_unittest.py:
Location:
trunk/Tools
Files:
40 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r99770 r99773  
     12011-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
    1672011-11-09  Dominic Mazzoni  <dmazzoni@google.com>
    268
  • trunk/Tools/Scripts/webkitpy/common/host.py

    r99326 r99773  
    6161        # In order to instantiate a port correctly, we have to pass it at least an executive, user, scm, and filesystem
    6262        # 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).
    6364        self.port_factory = PortFactory(self)
    6465
  • trunk/Tools/Scripts/webkitpy/common/net/credentials_unittest.py

    r99140 r99773  
    3838from webkitpy.tool.mocktool import MockOptions
    3939from webkitpy.common.system.executive_mock import MockExecutive
    40 from webkitpy.common.system.user_mock import MockUser
    4140
    4241
  • trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py

    r99233 r99773  
    4848from webkitpy.tool.mocktool import MockOptions
    4949from webkitpy.common.system.executive_mock import MockExecutive
    50 from webkitpy.common.system.user_mock import MockUser
    5150from webkitpy.common.host_mock import MockHost
    5251
     
    189188        options, args = run_webkit_tests.parse_args(['--platform=test', '--print=nothing', 'http/tests/passes', 'passes'])
    190189        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)
    192191        run_webkit_tests._set_up_derived_options(port, options)
    193192        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  
    5353    multiprocessing = None
    5454
    55 from webkitpy.layout_tests.port.factory import PortFactory
     55from webkitpy.common.host import Host  # FIXME: This should not be needed!
    5656from webkitpy.layout_tests.controllers import message_broker
    5757from webkitpy.layout_tests.views import printing
     
    253253        def run(self):
    254254            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)
    257259
    258260            # The unix multiprocessing implementation clones the
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/apple.py

    r93176 r99773  
    5757        return port_name[len(self.port_name + '-'):]
    5858
    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):
    6060        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)
    6262
    6363        # FIXME: This sort of parsing belongs in factory.py!
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py

    r98877 r99773  
    4848    multiprocessing = None
    4949
    50 from webkitpy.common import system
    5150from webkitpy.common.system import logutils
    5251from webkitpy.common.system import path
    53 from webkitpy.common.system.executive import Executive, ScriptError
    54 from webkitpy.common.system.user import User
     52from webkitpy.common.system.executive import ScriptError
    5553from webkitpy.layout_tests import read_checksum_from_png
    5654from webkitpy.layout_tests.models.test_configuration import TestConfiguration
     
    6866    """Fake implementation of optparse.Values. Cloned from webkitpy.tool.mocktool.MockOptions."""
    6967
    70     def __init__(self, **kwargs):
     68    def __init__(self, *args, **kwargs):
    7169        # The caller can set option values using keyword arguments. We don't
    7270        # set any values by default because we don't know how this
     
    8987    ALL_BUILD_TYPES = ('debug', 'release')
    9088
    91     def __init__(self, port_name=None, options=None,
     89    def __init__(self, host,
     90                 port_name=None, options=None,
    9291                 executive=None,
    9392                 user=None,
     
    108107        self.options = options or DummyOptions()
    109108
    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
    113115        self.config = config or port_config.Config(self.executive, self.filesystem)
    114116
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py

    r99140 r99773  
    4040from webkitpy.tool.mocktool import MockOptions
    4141from webkitpy.common.system.executive_mock import MockExecutive
    42 from webkitpy.common.system.user_mock import MockUser
    43 
     42from webkitpy.common.host_mock import MockHost
    4443
    4544from webkitpy.layout_tests.port import Port, Driver, DriverOutput
     
    5150class PortTest(unittest.TestCase):
    5251    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())
    5653        return Port(*args, **kwargs)
    5754
     
    285282
    286283    def test_virtual_methods(self):
    287         port = Port()
     284        port = Port(MockHost())
    288285        self.assertVirtual(port.baseline_path)
    289286        self.assertVirtual(port.baseline_search_path)
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium.py

    r99006 r99773  
    8989    }
    9090
    91     def __init__(self, **kwargs):
    92         Port.__init__(self, **kwargs)
     91    def __init__(self, host, **kwargs):
     92        Port.__init__(self, host, **kwargs)
    9393        # All sub-classes override this, but we need an initial value for testing.
    9494        self._version = 'xp'
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_gpu.py

    r99068 r99773  
    3434
    3535
    36 def get(platform=None, port_name='chromium-gpu', **kwargs):
     36def get(host, platform=None, port_name='chromium-gpu', **kwargs):
    3737    """Some tests have slightly different results when run while using
    3838    hardware acceleration.  In those cases, we prepend an additional directory
     
    5050
    5151    if port_name.startswith('chromium-gpu-linux'):
    52         return ChromiumGpuLinuxPort(port_name=port_name, **kwargs)
     52        return ChromiumGpuLinuxPort(host, port_name=port_name, **kwargs)
    5353    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)
    5555    if port_name.startswith('chromium-gpu-mac'):
    56         return ChromiumGpuMacPort(port_name=port_name, **kwargs)
     56        return ChromiumGpuMacPort(host, port_name=port_name, **kwargs)
    5757    if port_name.startswith('chromium-gpu-win'):
    58         return ChromiumGpuWinPort(port_name=port_name, **kwargs)
     58        return ChromiumGpuWinPort(host, port_name=port_name, **kwargs)
    5959    raise NotImplementedError('unsupported port: %s' % port_name)
    6060
     
    9191
    9292class 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)
    9595        _set_gpu_options(self)
    9696
     
    105105
    106106class 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)
    109109        _set_gpu_options(self, graphics_type='gpu-cg')
    110110
     
    118118
    119119class 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)
    122122        _set_gpu_options(self)
    123123
     
    131131
    132132class 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)
    135135        _set_gpu_options(self)
    136136
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py

    r99233 r99773  
    5959
    6060    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
    6164        # test that we got the right port
    6265        mock_options = MockOptions(accelerated_compositing=None,
     
    6568                                            child_processes=None)
    6669        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)
    6971        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)
    7173        self.assertTrue(port._options.accelerated_compositing)
    7274        self.assertTrue(port._options.accelerated_2d_canvas)
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_linux.py

    r90697 r99773  
    2828# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2929
    30 """Chromium Linux implementation of the Port interface."""
    31 
    3230import logging
    33 
    3431import chromium
    3532
     
    5956    }
    6057
    61     def __init__(self, port_name=None, **kwargs):
     58    def __init__(self, host, port_name=None, **kwargs):
    6259        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)
    6461        # We re-set the port name once the base object is fully initialized
    6562        # in order to be able to find the DRT binary properly.
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_linux_unittest.py

    r89031 r99773  
    3030
    3131from webkitpy.common.system import executive_mock
    32 from webkitpy.common.system import filesystem_mock
     32from webkitpy.common.host_mock import MockHost
    3333
    3434from webkitpy.layout_tests.port import chromium_linux
     
    4444    def assert_architecture(self, port_name=None, file_output=None,
    4545                            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
    4948        if file_output:
    50             executive = executive_mock.MockExecutive2(file_output)
     49            host.executive = executive_mock.MockExecutive2(file_output)
    5150
    52         port = chromium_linux.ChromiumLinuxPort(port_name=port_name,
    53             executive=executive, filesystem=filesystem)
     51        port = chromium_linux.ChromiumLinuxPort(host, port_name=port_name)
    5452        self.assertEquals(port.architecture(), expected_architecture)
    5553        if expected_architecture == 'x86':
     
    7472        # FIXME: Check that, for now, these are illegal port names.
    7573        # 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')
    8076
    8177    def test_determine_architecture_fails(self):
    8278        # 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())
    8580        self.assertEquals(port.architecture(), 'x86_64')
    8681
    8782        # 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)
    9387        self.assertEquals(port.architecture(), 'x86_64')
    9488
    9589        # 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)
    10192
    10293
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_mac.py

    r99068 r99773  
    110110    }
    111111
    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):
    113113        # We're a little generic here because this code is reused by the
    114114        # 'google-chrome' port as well as the 'mock-' and 'dryrun-' ports.
    115115        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)
    117117        if port_name.endswith('-mac'):
    118118            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  
    3030
    3131from webkitpy.thirdparty.mock import Mock
     32from webkitpy.common.host_mock import MockHost
    3233
    3334from webkitpy.layout_tests.port import chromium_mac
     
    3738class ChromiumMacPortTest(port_testcase.PortTestCase):
    3839    def port_maker(self, platform):
     40        # FIXME: This platform check should be removed!
    3941        if platform != 'darwin':
    4042            return None
     
    4244
    4345    def test_check_wdiff(self):
    44         port = chromium_mac.ChromiumMacPort()
     46        port = chromium_mac.ChromiumMacPort(MockHost())
    4547        self.assertTrue(port.check_wdiff())
    4648
    4749    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)
    5051        self.assertEquals(expected, port.name())
    5152
    5253    def test_versions(self):
    53         port = chromium_mac.ChromiumMacPort()
     54        port = chromium_mac.ChromiumMacPort(MockHost())
    5455        self.assertTrue(port.name() in ('chromium-cg-mac-leopard', 'chromium-cg-mac-snowleopard', 'chromium-cg-mac-lion', 'chromium-cg-mac-future'))
    5556
     
    7677
    7778    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')
    7980        self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-mac-leopard'))
    8081
    81         port = chromium_mac.ChromiumMacPort(port_name='chromium-mac-snowleopard')
     82        port = chromium_mac.ChromiumMacPort(MockHost(), port_name='chromium-mac-snowleopard')
    8283        self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-mac-snowleopard'))
    8384
    84         port = chromium_mac.ChromiumMacPort(port_name='chromium-mac-lion')
     85        port = chromium_mac.ChromiumMacPort(MockHost(), port_name='chromium-mac-lion')
    8586        self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-mac'))
    8687
    8788    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')
    8990        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')
    9192        self.assertEquals('cpu', port.graphics_type())
    9293        # For now, Mac defaults to cpu-cg graphics type.
    93         port = chromium_mac.ChromiumMacPort()
     94        port = chromium_mac.ChromiumMacPort(MockHost())
    9495        self.assertEquals('cpu-cg', port.graphics_type())
    9596
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py

    r99233 r99773  
    3333from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2
    3434from webkitpy.common.system.filesystem_mock import MockFileSystem
    35 from webkitpy.common.system.user_mock import MockUser
     35from webkitpy.common.host_mock import MockHost
    3636from webkitpy.thirdparty.mock import Mock
    3737from webkitpy.tool.mocktool import MockOptions
     
    123123    def test_all_test_configurations(self):
    124124        """Validate the complete set of configurations this port knows about."""
    125         port = chromium.ChromiumPort()
     125        port = chromium.ChromiumPort(MockHost())
    126126        self.assertEquals(set(port.all_test_configurations()), set([
    127127            TestConfiguration('leopard', 'x86', 'debug', 'cpu'),
     
    185185    class TestMacPort(chromium_mac.ChromiumMacPort):
    186186        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)
    189188
    190189        def default_configuration(self):
     
    194193    class TestLinuxPort(chromium_linux.ChromiumLinuxPort):
    195194        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)
    198196
    199197        def default_configuration(self):
     
    203201    class TestWinPort(chromium_win.ChromiumWinPort):
    204202        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)
    207204
    208205        def default_configuration(self):
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win.py

    r99233 r99773  
    8686    }
    8787
    88     def __init__(self, port_name=None, windows_version=None, **kwargs):
     88    def __init__(self, host, port_name=None, windows_version=None, **kwargs):
    8989        # We're a little generic here because this code is reused by the
    9090        # 'google-chrome' port as well as the 'mock-' and 'dryrun-' ports.
    9191        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)
    9393        if port_name.endswith('-win'):
    9494            self._version = os_version(windows_version)
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py

    r98833 r99773  
    3232
    3333from webkitpy.common.system import outputcapture
     34from webkitpy.common.host_mock import MockHost
    3435from webkitpy.common.system.filesystem_mock import MockFileSystem
    35 from webkitpy.tool import mocktool
    3636
    3737from webkitpy.layout_tests.port import chromium_win
     
    7272            return
    7373
    74         port._executive = mocktool.MockExecutive(should_log=True)
     74        port._executive = MockExecutive(should_log=True)
    7575        self._port = port
    7676        port.path_from_chromium_base = self._mock_path_from_chromium_base
     
    8686            return
    8787
    88         port._executive = mocktool.MockExecutive(should_log=True)
     88        port._executive = MockExecutive(should_log=True)
    8989        port.path_from_chromium_base = self._mock_path_from_chromium_base
    9090        self._port = port
     
    9595
    9696    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)
    9998        self.assertEquals(expected, port.name())
    10099
    101100    def test_versions(self):
    102         port = chromium_win.ChromiumWinPort()
     101        port = chromium_win.ChromiumWinPort(MockHost())
    103102        self.assertTrue(port.name() in ('chromium-win-xp', 'chromium-win-vista', 'chromium-win-win7'))
    104103
     
    127126
    128127    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')
    130129        self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-win-xp'))
    131130
    132         port = chromium_win.ChromiumWinPort(port_name='chromium-win-vista')
     131        port = chromium_win.ChromiumWinPort(MockHost(), port_name='chromium-win-vista')
    133132        self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-win-vista'))
    134133
    135         port = chromium_win.ChromiumWinPort(port_name='chromium-win-win7')
     134        port = chromium_win.ChromiumWinPort(MockHost(), port_name='chromium-win-win7')
    136135        self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-win'))
    137136
    138137    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        })
    141142
    142         port = chromium_win.ChromiumWinPort(filesystem=mock)
     143        port = chromium_win.ChromiumWinPort(host)
    143144        self.assertEquals(
    144145            '/mock-checkout/Source/WebKit/chromium/build/Release/DumpRenderTree.exe',
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/dryrun.py

    r99233 r99773  
    5858    """DryRun implementation of the Port interface."""
    5959
    60     def __init__(self, **kwargs):
     60    def __init__(self, host, **kwargs):
    6161        pfx = 'dryrun-'
    6262        if 'port_name' in kwargs:
     
    6565            else:
    6666                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)
    6968
    7069    def __getattr__(self, name):
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/efl.py

    r98833 r99773  
    3232
    3333from webkitpy.layout_tests.models.test_configuration import TestConfiguration
    34 from webkitpy.layout_tests.port import base, builders, server_process, webkit
     34from webkitpy.layout_tests.port.webkit import WebKitPort
    3535
    3636
     
    3838
    3939
    40 class EflPort(webkit.WebKitPort):
     40class EflPort(WebKitPort):
    4141    port_name = "efl"
    4242
    43     def __init__(self, **kwargs):
    44         webkit.WebKitPort.__init__(self, **kwargs)
     43    def __init__(self, host, **kwargs):
     44        WebKitPort.__init__(self, host, **kwargs)
    4545        self._version = self.port_name
    4646
     
    4949
    5050    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)
    5252
    5353    def _generate_all_test_configurations(self):
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/factory.py

    r99233 r99773  
    3232import re
    3333import sys
    34 
    35 from .test import unit_test_filesystem
    3634
    3735from webkitpy.layout_tests.port import builders
     
    7674        return dictionary[key]
    7775
    78     def _get_kwargs(self, **kwargs):
     76    def _get_kwargs(self, host=None, **kwargs):
    7977        port_to_use = self._port_name_from_arguments_and_options(**kwargs)
    8078
     
    8583            # provided to the port.  The unit_test_filesystem has an extra
    8684            # _tests attribute which a bunch of unittests depend on.
     85            from .test import unit_test_filesystem
    8786            self._set_default_overriding_none(kwargs, 'filesystem', unit_test_filesystem())
    8887        elif port_to_use.startswith('dryrun'):
     
    125124            raise NotImplementedError('unsupported port: %s' % port_to_use)
    126125
    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)
    136128
    137129    def all_port_names(self):
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/google_chrome.py

    r85877 r99773  
    4242    return chromium_overrides + port._filesystem.read_text_file(overrides_path)
    4343
    44 def GetGoogleChromePort(**kwargs):
     44
     45def GetGoogleChromePort(host, **kwargs):
    4546    """Some tests have slightly different results when compiled as Google
    4647    Chrome vs Chromium.  In those cases, we prepend an additional directory to
     
    5556        class GoogleChromeLinux32Port(chromium_linux.ChromiumLinuxPort):
    5657            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'))
    6160                return paths
    6261
    6362            def test_expectations_overrides(self):
    64                 return _test_expectations_overrides(self,
    65                     chromium_linux.ChromiumLinuxPort)
     63                return _test_expectations_overrides(self, chromium_linux.ChromiumLinuxPort)
    6664
    6765            def architecture(self):
    6866                return 'x86'
    6967
    70         return GoogleChromeLinux32Port(port_name='chromium-linux-x86', **kwargs)
     68        return GoogleChromeLinux32Port(host, port_name='chromium-linux-x86', **kwargs)
    7169    elif port_name == 'google-chrome-linux64':
    7270        import chromium_linux
     
    7472        class GoogleChromeLinux64Port(chromium_linux.ChromiumLinuxPort):
    7573            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'))
    8076                return paths
    8177
    8278            def test_expectations_overrides(self):
    83                 return _test_expectations_overrides(self,
    84                     chromium_linux.ChromiumLinuxPort)
     79                return _test_expectations_overrides(self, chromium_linux.ChromiumLinuxPort)
    8580
    8681            def architecture(self):
    8782                return 'x86_64'
    8883
    89         return GoogleChromeLinux64Port(port_name='chromium-linux-x86_64', **kwargs)
     84        return GoogleChromeLinux64Port(host, port_name='chromium-linux-x86_64', **kwargs)
    9085    elif port_name.startswith('google-chrome-mac'):
    9186        import chromium_mac
     
    9388        class GoogleChromeMacPort(chromium_mac.ChromiumMacPort):
    9489            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'))
    9992                return paths
    10093
    10194            def test_expectations_overrides(self):
    102                 return _test_expectations_overrides(self,
    103                     chromium_mac.ChromiumMacPort)
     95                return _test_expectations_overrides(self, chromium_mac.ChromiumMacPort)
    10496
    105         return GoogleChromeMacPort(**kwargs)
     97        return GoogleChromeMacPort(host, **kwargs)
    10698    elif port_name.startswith('google-chrome-win'):
    10799        import chromium_win
     
    109101        class GoogleChromeWinPort(chromium_win.ChromiumWinPort):
    110102            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'))
    115105                return paths
    116106
    117107            def test_expectations_overrides(self):
    118                 return _test_expectations_overrides(self,
    119                     chromium_win.ChromiumWinPort)
     108                return _test_expectations_overrides(self, chromium_win.ChromiumWinPort)
    120109
    121         return GoogleChromeWinPort(**kwargs)
     110        return GoogleChromeWinPort(host, **kwargs)
    122111    raise NotImplementedError('unsupported port: %s' % port_name)
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py

    r99233 r99773  
    2929from webkitpy.common.host_mock import MockHost
    3030from webkitpy.common.system.filesystem_mock import MockFileSystem
    31 from webkitpy.common.system.user_mock import MockUser
    3231from webkitpy.common.system.executive_mock import MockExecutive
    3332
     
    4847
    4948    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())
    5150        path = port.baseline_search_path()[0]
    5251        self.assertEqual(expected_path, port._filesystem.basename(path))
     
    6059        chromium_port = host.port_factory.get("chromium-cg-mac")
    6160        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)
    6462
    6563        expected_chromium_overrides = '// chromium overrides\n'
    6664        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')
    6967
    70         fs.files[chromium_path] = expected_chromium_overrides
    71         fs.files[chrome_path] = None
     68        host.filesystem.files[chromium_path] = expected_chromium_overrides
     69        host.filesystem.files[chrome_path] = None
    7270        actual_chrome_overrides = port.test_expectations_overrides()
    7371        self.assertEqual(expected_chromium_overrides, actual_chrome_overrides)
    7472
    75         fs.files[chrome_path] = expected_chrome_overrides
     73        host.filesystem.files[chrome_path] = expected_chrome_overrides
    7674        actual_chrome_overrides = port.test_expectations_overrides()
    7775        self.assertEqual(actual_chrome_overrides, expected_chromium_overrides + expected_chrome_overrides)
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/gtk.py

    r99377 r99773  
    2727# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828
     29from __future__ import with_statement
     30
    2931"""WebKit Gtk implementation of the Port interface."""
    3032
     
    3537
    3638from webkitpy.layout_tests.models.test_configuration import TestConfiguration
    37 from webkitpy.layout_tests.port import base, builders, server_process, webkit
     39from webkitpy.layout_tests.port.server_process import ServerProcess
     40from webkitpy.layout_tests.port.webkit import WebKitDriver, WebKitPort
    3841
    3942
     
    4144
    4245
    43 class GtkDriver(webkit.WebKitDriver):
     46class GtkDriver(WebKitDriver):
    4447    def start(self):
    4548        display_id = self._worker_number + 1
    4649        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)
    5052        server_name = self._port.driver_name()
    5153        environment = self._port.setup_environ_for_server(server_name)
    5254        # We must do this here because the DISPLAY number depends on _worker_number
    5355        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)
    5557
    5658    def stop(self):
    57         webkit.WebKitDriver.stop(self)
     59        WebKitDriver.stop(self)
     60        # FIXME: This should use Executive.kill_process
    5861        os.kill(self._xvfb_process.pid, signal.SIGTERM)
    5962        self._xvfb_process.wait()
    6063
    6164
    62 class GtkPort(webkit.WebKitPort):
     65class GtkPort(WebKitPort):
    6366    port_name = "gtk"
    6467
    65     def __init__(self, **kwargs):
    66         webkit.WebKitPort.__init__(self, **kwargs)
     68    def __init__(self, host, **kwargs):
     69        WebKitPort.__init__(self, host, **kwargs)
    6770        self._version = self.port_name
    6871
     
    7477
    7578    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)
    7780        environment['GTK_MODULES'] = 'gail'
    7881        environment['LIBOVERLAY_SCROLLBAR'] = '0'
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/mac.py

    r98833 r99773  
    7575        return os_version(os_version_string)
    7676
    77     def __init__(self, **kwargs):
    78         ApplePort.__init__(self, **kwargs)
     77    def __init__(self, host, **kwargs):
     78        ApplePort.__init__(self, host, **kwargs)
    7979        self._operating_system = 'mac'
    8080        self._leak_detector = LeakDetector(self)
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/mac_unittest.py

    r99140 r99773  
    3333from webkitpy.tool.mocktool import MockOptions
    3434from webkitpy.common.system.executive_mock import MockExecutive
    35 from webkitpy.common.system.user_mock import MockUser
     35from webkitpy.common.host_mock import MockHost
    3636
    3737
     
    4444
    4545    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)
    4747        self.assertEqual(port._skipped_file_search_paths(), expected_paths)
    4848
     
    7575
    7676    def test_tests_from_skipped_file_contents(self):
    77         port = MacPort(filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())
     77        port = MacPort(MockHost())
    7878        self.assertEqual(port._tests_from_skipped_file_contents(self.example_skipped_file), self.example_skipped_tests)
    7979
    8080    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)
    8282        self.assertEquals(expected, port.name())
    8383
    8484    def test_tests_for_other_platforms(self):
    8585        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')
    8787        platform_dir_paths = map(port._webkit_baseline_path, platforms)
    8888        # Replace our empty mock file system with one which has our expected platform directories.
     
    9595
    9696    def test_version(self):
    97         port = MacPort(filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())
     97        port = MacPort(MockHost())
    9898        self.assertTrue(port.version())
    9999
     
    119119
    120120    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))
    122122        env = port.setup_environ_for_server(port.driver_name())
    123123        self.assertEquals(env['MallocStackLogging'], '1')
     
    128128        # rather be passed components (directly or via setters).  Once
    129129        # 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))
    131131        absolute_search_paths = map(port._webkit_baseline_path, search_paths)
    132132        self.assertEquals(port.baseline_search_path(), absolute_search_paths)
     
    143143
    144144    def test_show_results_html_file(self):
    145         port = MacPort(filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())
     145        port = MacPort(MockHost())
    146146        # Delay setting a should_log executive to avoid logging from MacPort.__init__.
    147147        port._executive = MockExecutive(should_log=True)
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt.py

    r99233 r99773  
    3535import base64
    3636import logging
    37 import optparse
    38 import os
    3937import sys
    4038
    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
     39from webkitpy.common.host import Host
    4540from webkitpy.tool.mocktool import MockOptions
    4641
     
    5247    """MockPort implementation of the Port interface."""
    5348
    54     def __init__(self, **kwargs):
     49    def __init__(self, host, **kwargs):
    5550        prefix = 'mock-'
    5651        if 'port_name' in kwargs:
    5752            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)
    6055        self.__real_name = prefix + self.__delegate.name()
    6156
     
    7772
    7873    def _path_to_driver(self):
    79         return os.path.abspath(__file__)
     74        return self._host.filesystem.abspath(__file__)
    8075
    8176    def create_driver(self, worker_number):
     
    8984            cmd = self.__original_driver_cmd_line()
    9085            index = cmd.index(self.__delegate._path_to_driver())
    91             cmd[index:index + 1] = [sys.executable, self._path_to_driver(),
    92                                     '--platform', self.name()]
     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()]
    9388            return cmd
    9489
     
    123118
    124119
    125 def main(argv, fs, stdin, stdout, stderr):
     120def main(argv, host, stdin, stdout, stderr):
    126121    """Run the tests."""
    127122
    128123    options, args = parse_options(argv)
    129124    if options.chromium:
    130         drt = MockChromiumDRT(options, args, fs, stdin, stdout, stderr)
     125        drt = MockChromiumDRT(options, args, host, stdin, stdout, stderr)
    131126    else:
    132         drt = MockDRT(options, args, fs, stdin, stdout, stderr)
     127        drt = MockDRT(options, args, host, stdin, stdout, stderr)
    133128    return drt.run()
    134129
     
    175170
    176171class MockDRT(object):
    177     def __init__(self, options, args, filesystem, stdin, stdout, stderr):
     172    def __init__(self, options, args, host, stdin, stdout, stderr):
    178173        self._options = options
    179174        self._args = args
    180         self._filesystem = filesystem
     175        self._host = host
    181176        self._stdout = stdout
    182177        self._stdin = stdin
     
    186181        if options.platform:
    187182            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)
    190184
    191185    def run(self):
     
    271265        if self._options.pixel_tests and test_input.checksum:
    272266            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,
    274268                                               actual_image)
    275269        self._stdout.write(actual_text)
     
    284278
    285279if __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  
    4949        if sys.platform == 'win32':
    5050            # 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)
    5353
    5454    def test_default_worker_model(self):
     
    5757
    5858    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'))
    6060
    6161    def test_check_sys_deps(self):
     
    106106        return ['-']
    107107
    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)
    110110
    111111    def make_input_output(self, port, test_name, pixel_tests,
     
    141141        port_name = 'test'
    142142        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)
    145145        drt_input, drt_output = self.make_input_output(port, test_name,
    146146            pixel_tests, expected_checksum, drt_output)
     
    152152        options, args = mock_drt.parse_options(args)
    153153
    154         drt = self.make_drt(options, args, filesystem, stdin, stdout, stderr)
     154        drt = self.make_drt(options, args, host, stdin, stdout, stderr)
    155155        res = drt.run()
    156156
     
    163163
    164164    def test_main(self):
    165         filesystem = test.unit_test_filesystem()
     165        host = MockHost()
     166        host.filesystem = test.unit_test_filesystem()
    166167        stdin = newstringio.StringIO()
    167168        stdout = newstringio.StringIO()
    168169        stderr = newstringio.StringIO()
    169170        res = mock_drt.main(['--platform', 'test'] + self.extra_args(False),
    170                             filesystem, stdin, stdout, stderr)
     171                            host, stdin, stdout, stderr)
    171172        self.assertEqual(res, 0)
    172173        self.assertEqual(stdout.getvalue(), '')
    173174        self.assertEqual(stderr.getvalue(), '')
    174         self.assertEqual(filesystem.written_files, {})
     175        self.assertEqual(host.filesystem.written_files, {})
    175176
    176177    def test_pixeltest_passes(self):
     
    205206        return []
    206207
    207     def make_drt(self, options, args, filesystem, stdin, stdout, stderr):
     208    def make_drt(self, options, args, host, stdin, stdout, stderr):
    208209        options.chromium = True
    209210
     
    213214        options.pixel_tests = True
    214215
    215         return mock_drt.MockChromiumDRT(options, args, filesystem, stdin, stdout, stderr)
     216        return mock_drt.MockChromiumDRT(options, args, host, stdin, stdout, stderr)
    216217
    217218    def input_line(self, port, test_name, checksum=None):
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py

    r99140 r99773  
    4747from webkitpy.tool.mocktool import MockOptions
    4848from webkitpy.common.system.executive_mock import MockExecutive
    49 from webkitpy.common.system.user_mock import MockUser
     49from webkitpy.common.host_mock import MockHost
    5050mock_options = MockOptions(configuration='Release')
    5151
     
    6969            return None
    7070
    71         return maker(options=options, filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())
     71        return maker(options=options, host=MockHost())
    7272
    7373    def test_default_worker_model(self):
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/qt.py

    r98833 r99773  
    6060
    6161    # 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)
    6464        self._operating_system = self._operating_system_for_platform(sys_platform or sys.platform)
    6565        self._version = self._operating_system
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/qt_unittest.py

    r99140 r99773  
    3636from webkitpy.tool.mocktool import MockOptions
    3737from webkitpy.common.system.executive_mock import MockExecutive
    38 from webkitpy.common.system.user_mock import MockUser
     38from webkitpy.common.host_mock import MockHost
    3939
    4040
     
    4949        port = QtPort(sys_platform=sys_platform,
    5050            options=MockOptions(webkit_test_runner=use_webkit2, platform='qt'),
    51             filesystem=MockFileSystem(),
    52             user=MockUser(),
     51            host=MockHost(),
    5352            executive=MockExecutive2(self._qt_version(qt_version)))
    5453        absolute_search_paths = map(port._webkit_baseline_path, search_paths)
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/test.py

    r99233 r99773  
    3636from webkitpy.layout_tests.port import Port, Driver, DriverOutput
    3737from 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
     38from webkitpy.common.host_mock import MockHost
    4039from webkitpy.common.system.filesystem_mock import MockFileSystem
    4140
     
    278277        return dictionary[key]
    279278
    280     def __init__(self, port_name=None, **kwargs):
     279    def __init__(self, host=None, port_name=None, **kwargs):
    281280        if not port_name or port_name == 'test':
    282281            port_name = 'test-mac-leopard'
    283282
    284         self._set_default_overriding_none(kwargs, 'user', MockUser())
    285         self._set_default_overriding_none(kwargs, 'executive', MockExecutive())
     283        host = host or MockHost()
    286284        filesystem = self._set_default_overriding_none(kwargs, 'filesystem', unit_test_filesystem())
    287285
    288         Port.__init__(self, port_name=port_name, **kwargs)
     286        Port.__init__(self, host, port_name=port_name, **kwargs)
    289287        self._results_directory = None
    290288
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py

    r99469 r99773  
    5050
    5151class WebKitPort(Port):
    52     def __init__(self, **kwargs):
    53         Port.__init__(self, **kwargs)
     52    def __init__(self, host, **kwargs):
     53        Port.__init__(self, host, **kwargs)
    5454
    5555        # 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  
    2828import unittest
    2929
     30from webkitpy.common.host_mock import MockHost
     31from webkitpy.common.system.executive_mock import MockExecutive
    3032from webkitpy.common.system.filesystem_mock import MockFileSystem
    3133from webkitpy.common.system.outputcapture import OutputCapture
    32 
    3334from webkitpy.layout_tests.models.test_configuration import TestConfiguration
     35from webkitpy.layout_tests.port import port_testcase
    3436from webkitpy.layout_tests.port.webkit import WebKitPort, WebKitDriver
    35 from webkitpy.layout_tests.port import port_testcase
    36 
    3737from webkitpy.tool.mocktool import MockOptions
    38 from webkitpy.common.system.executive_mock import MockExecutive
    39 from webkitpy.common.system.user_mock import MockUser
    40 
    4138
    4239
     
    4542
    4643    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,
    4945                 **kwargs):
    5046        self.symbols_string = symbols_string  # Passing "" disables all staticly-detectable features.
    5147        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)
    5650
    5751    def all_test_configurations(self):
     
    7569        # The WebKit ports override new-run-webkit-test default options.
    7670        options = MockOptions(pixel_tests=None, time_out_ms=None)
    77         port = WebKitPort(options=options)
     71        port = WebKitPort(MockHost(), options=options)
    7872        self.assertEquals(port._options.pixel_tests, False)
    7973        self.assertEquals(port._options.time_out_ms, 35000)
     
    8175        # Note that we don't override options if specified by the user.
    8276        options = MockOptions(pixel_tests=True, time_out_ms=6000)
    83         port = WebKitPort(options=options)
     77        port = WebKitPort(MockHost(), options=options)
    8478        self.assertEquals(port._options.pixel_tests, True)
    8579        self.assertEquals(port._options.time_out_ms, 6000)
     
    125119
    126120    def test_runtime_feature_list(self):
    127         port = WebKitPort(executive=MockExecutive())
     121        port = WebKitPort(MockHost())
    128122        port._executive.run_command = lambda command, cwd=None, error_handler=None: "Nonsense"
    129123        # 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  
    7575            return self._version_string_from_windows_version_tuple(version_tuple)
    7676
    77     def __init__(self, **kwargs):
    78         ApplePort.__init__(self, **kwargs)
     77    def __init__(self, host, **kwargs):
     78        ApplePort.__init__(self, host, **kwargs)
    7979        self._operating_system = 'win'
    8080
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/win_unittest.py

    r99233 r99773  
    3434from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2
    3535from webkitpy.common.system.filesystem_mock import MockFileSystem
    36 from webkitpy.common.system.user_mock import MockUser
     36from webkitpy.common.host_mock import MockHost
    3737from webkitpy.common.system.outputcapture import OutputCapture
    3838from webkitpy.layout_tests.port import port_testcase
     
    7171        port = WinPort(os_version_string=version,
    7272            options=MockOptions(webkit_test_runner=use_webkit2),
    73             filesystem=MockFileSystem(),
    74             user=MockUser(),
    75             executive=MockExecutive())
     73            host=MockHost())
    7674        absolute_search_paths = map(port._webkit_baseline_path, expected_search_paths)
    7775        self.assertEquals(port.baseline_search_path(), absolute_search_paths)
     
    8987
    9088    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())
    9290        self.assertEquals(port.version(), expected_version)
    9391
  • trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py

    r99461 r99773  
    6262from webkitpy.common import array_stream
    6363from webkitpy.common.system import outputcapture
    64 from webkitpy.common.system.user_mock import MockUser
    6564from webkitpy.common.host_mock import MockHost
    6665
     
    147146    options, parsed_args = parse_args(extra_args, tests_included=True)
    148147
    149     user = MockUser()
     148    host = MockHost()
    150149
    151150    test_batches = []
     
    180179            return RecordingTestDriver(self, worker_number)
    181180
    182     recording_port = RecordingTestPort(options=options, user=user, filesystem=filesystem)
     181    recording_port = RecordingTestPort(options=options, host=host, filesystem=filesystem)
    183182    run_and_capture(recording_port, options, parsed_args)
    184183
     
    468467
    469468        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)
    471470        res, out, err, _ = logging_run(['--no-show-results',
    472471            'failures/expected/missing_image.html',
     
    640639        def get_port_for_run(args):
    641640            options, parsed_args = run_webkit_tests.parse_args(args)
    642             test_port = ImageDiffTestPort(options=options, user=MockUser())
     641            test_port = ImageDiffTestPort(options=options)
    643642            res = passing_run(args, port_obj=test_port, tests_included=True)
    644643            self.assertTrue(res)
  • trunk/Tools/Scripts/webkitpy/to_be_moved/rebaseline_chromium_webkit_tests_unittest.py

    r99271 r99773  
    4141
    4242from webkitpy.common.checkout.scm.scm_mock import MockSCM
    43 from webkitpy.common.system.user_mock import MockUser
    4443
    4544from webkitpy.layout_tests import port
  • trunk/Tools/Scripts/webkitpy/tool/servers/rebaselineserver.py

    r96252 r99773  
    3232import BaseHTTPServer
    3333
     34from webkitpy.common.host import Host  # FIXME: This should not be needed!
    3435from webkitpy.layout_tests.port.webkit import WebKitPort
    3536from webkitpy.tool.servers.reflectionhandler import ReflectionHandler
     
    165166    class AllPlatformsPort(WebKitPort):
    166167        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)
    168170            self._platforms_by_directory = dict([(self._webkit_baseline_path(p), p) for p in test_config.platforms])
    169171
  • trunk/Tools/Scripts/webkitpy/tool/servers/rebaselineserver_unittest.py

    r99140 r99773  
    3535    import webkitpy.thirdparty.simplejson as json
    3636
     37
     38from webkitpy.common.checkout.scm.scm_mock import MockSCM
    3739from webkitpy.common.net import resultsjsonparser_unittest
    38 from webkitpy.common.system import filesystem_mock
     40from webkitpy.common.system.filesystem_mock import MockFileSystem
     41from webkitpy.common.host_mock import MockHost
    3942from webkitpy.layout_tests.layout_package.json_results_generator import strip_json_wrapper
    4043from webkitpy.layout_tests.port.webkit import WebKitPort
    4144from webkitpy.tool.commands.rebaselineserver import TestConfig, RebaselineServer
    42 from webkitpy.common.checkout.scm.scm_mock import MockSCM
    4345from webkitpy.tool.servers import rebaselineserver
    4446
     
    300302    layout_tests_directory = "/mock-checkout/LayoutTests"
    301303    results_directory = '/WebKitBuild/Debug/layout-test-results'
    302     mock_filesystem = filesystem_mock.MockFileSystem()
     304    mock_filesystem = MockFileSystem()
    303305    for file in test_files:
    304306        file_path = mock_filesystem.join(layout_tests_directory, file)
     
    311313        port_name = "mac"
    312314        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())
    315316
    316317    return TestConfig(
Note: See TracChangeset for help on using the changeset viewer.