- Revision
- 103012
- Author
- [email protected]
- Date
- 2011-12-15 19:02:33 -0800 (Thu, 15 Dec 2011)
Log Message
webkitpy: cleanup prior to systemhostifying the layout_test/port* classes
https://bugs.webkit.org/show_bug.cgi?id=74551
This is some minor cleanup prior to making all of the host/port
changes described in bug 74138.
* Scripts/webkitpy/common/host_mock.py:
(MockHost.__init__):
- make sure the scm object is initialized with the same mock
executive and filesystem objects.
* Scripts/webkitpy/common/system/filesystem_mock.py:
(MockFileSystem.clear_written_files):
- add a routine that will be useful in testing.
(MockFileSystem.maybe_make_directory):
(MockFileSystem.write_binary_file):
- fix bugs to make sure directories are created properly.
* Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py:
(_Process.run):
- add clarifying comments.
* Scripts/webkitpy/layout_tests/port/mock_drt.py:
(MockDRTPort.__init__):
(MockDRT.__init__):
- add clarifying comments.
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (103011 => 103012)
--- trunk/Tools/ChangeLog 2011-12-16 02:32:29 UTC (rev 103011)
+++ trunk/Tools/ChangeLog 2011-12-16 03:02:33 UTC (rev 103012)
@@ -1,3 +1,30 @@
+2011-12-15 Dirk Pranke <[email protected]>
+
+ webkitpy: cleanup prior to systemhostifying the layout_test/port* classes
+ https://bugs.webkit.org/show_bug.cgi?id=74551
+
+ This is some minor cleanup prior to making all of the host/port
+ changes described in bug 74138.
+
+ * Scripts/webkitpy/common/host_mock.py:
+ (MockHost.__init__):
+ - make sure the scm object is initialized with the same mock
+ executive and filesystem objects.
+
+ * Scripts/webkitpy/common/system/filesystem_mock.py:
+ (MockFileSystem.clear_written_files):
+ - add a routine that will be useful in testing.
+ (MockFileSystem.maybe_make_directory):
+ (MockFileSystem.write_binary_file):
+ - fix bugs to make sure directories are created properly.
+ * Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py:
+ (_Process.run):
+ - add clarifying comments.
+ * Scripts/webkitpy/layout_tests/port/mock_drt.py:
+ (MockDRTPort.__init__):
+ (MockDRT.__init__):
+ - add clarifying comments.
+
2011-12-15 Anders Carlsson <[email protected]>
Regression (r102866): Navigating away from or closing a page with a plugin crashes
Modified: trunk/Tools/Scripts/webkitpy/common/host_mock.py (103011 => 103012)
--- trunk/Tools/Scripts/webkitpy/common/host_mock.py 2011-12-16 02:32:29 UTC (rev 103011)
+++ trunk/Tools/Scripts/webkitpy/common/host_mock.py 2011-12-16 03:02:33 UTC (rev 103012)
@@ -44,7 +44,7 @@
self.web = MockWeb()
self._checkout = MockCheckout()
- self._scm = MockSCM()
+ self._scm = MockSCM(filesystem=self.filesystem, executive=self.executive)
# Various pieces of code (wrongly) call filesystem.chdir(checkout_root).
# Making the checkout_root exist in the mock filesystem makes that chdir not raise.
self.filesystem.maybe_make_directory(self._scm.checkout_root)
Modified: trunk/Tools/Scripts/webkitpy/common/system/filesystem_mock.py (103011 => 103012)
--- trunk/Tools/Scripts/webkitpy/common/system/filesystem_mock.py 2011-12-16 02:32:29 UTC (rev 103011)
+++ trunk/Tools/Scripts/webkitpy/common/system/filesystem_mock.py 2011-12-16 03:02:33 UTC (rev 103012)
@@ -64,6 +64,10 @@
sep = property(_get_sep, doc="pathname separator")
+ def clear_written_files(self):
+ # This function can be used to track what is written between steps in a test.
+ self.written_files = {}
+
def _raise_not_found(self, path):
raise IOError(errno.ENOENT, path, os.strerror(errno.ENOENT))
@@ -243,8 +247,9 @@
def maybe_make_directory(self, *path):
norm_path = self.normpath(self.join(*path))
- if not self.isdir(norm_path):
+ while norm_path and not self.isdir(norm_path):
self.dirs.add(norm_path)
+ norm_path = self.dirname(norm_path)
def move(self, source, destination):
if self.files[source] is None:
@@ -275,6 +280,7 @@
return self.files[path]
def write_binary_file(self, path, contents):
+ # FIXME: should this assert if dirname(path) doesn't exist?
self.files[path] = contents
self.written_files[path] = contents
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py (103011 => 103012)
--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py 2011-12-16 02:32:29 UTC (rev 103011)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py 2011-12-16 03:02:33 UTC (rev 103012)
@@ -52,7 +52,9 @@
except ImportError:
multiprocessing = None
-from webkitpy.common.host import Host # FIXME: This should not be needed!
+# These are needed when workers are launched in new child processes.
+from webkitpy.common.host import Host
+
from webkitpy.layout_tests.controllers import message_broker
from webkitpy.layout_tests.views import printing
@@ -252,11 +254,13 @@
self._client = client
def run(self):
- options = self._options
- # FIXME: This should get the Host from the owner of this object
- # so this function can be properly mocked!
+ # We need to create a new Host object here because this is
+ # running in a new process and we can't require the parent's
+ # Host to be pickleable and passed to the child.
host = Host()
host._initialize_scm()
+
+ options = self._options
port_obj = host.port_factory.get(self._platform_name, options)
# The unix multiprocessing implementation clones the
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt.py (103011 => 103012)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt.py 2011-12-16 02:32:29 UTC (rev 103011)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt.py 2011-12-16 03:02:33 UTC (rev 103012)
@@ -30,16 +30,21 @@
"""
This is an implementation of the Port interface that overrides other
ports and changes the Driver binary to "MockDRT".
+
+The MockDRT objects emulate what a real DRT would do. In particular, they
+return the output a real DRT would return for a given test, assuming that
+test actually passes (except for reftests, which currently cause the
+MockDRT to crash).
"""
import base64
import logging
import sys
-from webkitpy.common.host import Host
+from webkitpy.common.system.systemhost import SystemHost
+from webkitpy.layout_tests.port.factory import PortFactory
from webkitpy.tool.mocktool import MockOptions
-
_log = logging.getLogger(__name__)
@@ -51,7 +56,7 @@
if 'port_name' in kwargs:
kwargs['port_name'] = kwargs['port_name'][len(prefix):]
self._host = host
- self.__delegate = host.port_factory.get(**kwargs)
+ self.__delegate = PortFactory(host).get(**kwargs)
self.__real_name = prefix + self.__delegate.name()
def real_name(self):
@@ -180,7 +185,7 @@
port_name = None
if options.platform:
port_name = options.platform
- self._port = self._host.port_factory.get(port_name, options=options)
+ self._port = PortFactory(host).get(port_name=port_name, options=options)
def run(self):
while True:
@@ -277,7 +282,6 @@
if __name__ == '__main__':
- # FIXME: Why is this using a real Host object instead of MockHost?
- host = Host()
- host._initialize_scm()
- sys.exit(main(sys.argv[1:], host, sys.stdin, sys.stdout, sys.stderr))
+ # Note that the Mock in MockDRT refers to the fact that it is emulating a
+ # real DRT, and as such, it needs access to a real SystemHost, not a MockSystemHost.
+ sys.exit(main(sys.argv[1:], SystemHost(), sys.stdin, sys.stdout, sys.stderr))