Title: [102393] trunk/Tools
Revision
102393
Author
[email protected]
Date
2011-12-08 16:20:39 -0800 (Thu, 08 Dec 2011)

Log Message

create a "SystemHost" object for webkitpy to slim down the Host object
https://bugs.webkit.org/show_bug.cgi?id=72680

Reviewed by Eric Siedel.

This creates a SystemHost object that other objects that should
only have dependencies on functionality in webkitpy.common.system
can use; this will allow them to not require a full Host.

* Scripts/webkitpy/common/host.py:
* Scripts/webkitpy/common/host_mock.py:
* Scripts/webkitpy/common/system/systemhost.py: Added.
* Scripts/webkitpy/common/system/systemhost_mock.py: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (102392 => 102393)


--- trunk/Tools/ChangeLog	2011-12-09 00:15:26 UTC (rev 102392)
+++ trunk/Tools/ChangeLog	2011-12-09 00:20:39 UTC (rev 102393)
@@ -1,3 +1,19 @@
+2011-12-08  Dirk Pranke  <[email protected]>
+
+        create a "SystemHost" object for webkitpy to slim down the Host object
+        https://bugs.webkit.org/show_bug.cgi?id=72680
+
+        Reviewed by Eric Siedel.
+
+        This creates a SystemHost object that other objects that should
+        only have dependencies on functionality in webkitpy.common.system
+        can use; this will allow them to not require a full Host.
+
+        * Scripts/webkitpy/common/host.py:
+        * Scripts/webkitpy/common/host_mock.py:
+        * Scripts/webkitpy/common/system/systemhost.py: Added.
+        * Scripts/webkitpy/common/system/systemhost_mock.py: Added.
+
 2011-12-08  Chris Fleizach  <[email protected]>
 
         AX: platform/mac/accessibility/search-with-frames.html crashes

Modified: trunk/Tools/Scripts/webkitpy/common/host.py (102392 => 102393)


--- trunk/Tools/Scripts/webkitpy/common/host.py	2011-12-09 00:15:26 UTC (rev 102392)
+++ trunk/Tools/Scripts/webkitpy/common/host.py	2011-12-09 00:20:39 UTC (rev 102393)
@@ -36,8 +36,7 @@
 from webkitpy.common.memoized import memoized
 from webkitpy.common.net import bugzilla, buildbot, web
 from webkitpy.common.net.buildbot.chromiumbuildbot import ChromiumBuildBot
-from webkitpy.common.system import executive, filesystem, platforminfo, user, workspace
-from webkitpy.common.system.environment import Environment
+from webkitpy.common.system.systemhost import SystemHost
 from webkitpy.common.watchlist.watchlistloader import WatchListLoader
 from webkitpy.layout_tests.port.factory import PortFactory
 
@@ -45,15 +44,9 @@
 _log = logging.getLogger(__name__)
 
 
-class Host(object):
+class Host(SystemHost):
     def __init__(self):
-        # These basic environment abstractions should be a separate lower-level object.
-        # Alternatively the rest of the objects in Host should just move up to a higher abstraction.
-        self.executive = executive.Executive()
-        self.filesystem = filesystem.FileSystem()
-        self.user = user.User()
-        self.platform = platforminfo.PlatformInfo(self.executive)
-        self.workspace = workspace.Workspace(self.filesystem, self.executive)
+        SystemHost.__init__(self)
         self.web = web.Web()
 
         # FIXME: Checkout should own the scm object.
@@ -112,9 +105,6 @@
             except OSError, e:
                 _log.debug('Failed to engage svn.bat Windows hack.')
 
-    def copy_current_environment(self):
-        return Environment(os.environ.copy())
-
     def _initialize_scm(self, patch_directories=None):
         if sys.platform == "win32":
             self._engage_awesome_windows_hacks()

Modified: trunk/Tools/Scripts/webkitpy/common/host_mock.py (102392 => 102393)


--- trunk/Tools/Scripts/webkitpy/common/host_mock.py	2011-12-09 00:15:26 UTC (rev 102392)
+++ trunk/Tools/Scripts/webkitpy/common/host_mock.py	2011-12-09 00:20:39 UTC (rev 102393)
@@ -31,31 +31,23 @@
 from webkitpy.common.net.bugzilla.bugzilla_mock import MockBugzilla
 from webkitpy.common.net.buildbot.buildbot_mock import MockBuildBot
 from webkitpy.common.net.web_mock import MockWeb
-from webkitpy.common.system.environment import Environment
-from webkitpy.common.system.executive_mock import MockExecutive
-from webkitpy.common.system.filesystem_mock import MockFileSystem
-from webkitpy.common.system.platforminfo_mock import MockPlatformInfo
-from webkitpy.common.system.user_mock import MockUser
-from webkitpy.common.system.workspace_mock import MockWorkspace
+from webkitpy.common.system.systemhost_mock import MockSystemHost
 from webkitpy.common.watchlist.watchlist_mock import MockWatchList
 
 # New-style ports need to move down into webkitpy.common.
 from webkitpy.layout_tests.port.factory import PortFactory
 
 
-class MockHost(object):
+class MockHost(MockSystemHost):
     def __init__(self, log_executive=False, executive_throws_when_run=None):
-        self.executive = MockExecutive(should_log=log_executive, should_throw_when_run=executive_throws_when_run)
-        self.user = MockUser()
-        self.platform = MockPlatformInfo()
-        self.workspace = MockWorkspace()
+        MockSystemHost.__init__(self, log_executive, executive_throws_when_run)
         self.web = MockWeb()
 
         self._checkout = MockCheckout()
         self._scm = MockSCM()
         # 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 = MockFileSystem(dirs=set([self._scm.checkout_root]))
+        self.filesystem.maybe_make_directory(self._scm.checkout_root)
 
         self.bugs = MockBugzilla()
         self.buildbot = MockBuildBot()
@@ -67,9 +59,6 @@
 
         self._watch_list = MockWatchList()
 
-    def copy_current_environment(self):
-        return Environment({"MOCK_ENVIRON_COPY": '1'})
-
     def _initialize_scm(self, patch_directories=None):
         pass
 

Added: trunk/Tools/Scripts/webkitpy/common/system/systemhost.py (0 => 102393)


--- trunk/Tools/Scripts/webkitpy/common/system/systemhost.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/common/system/systemhost.py	2011-12-09 00:20:39 UTC (rev 102393)
@@ -0,0 +1,43 @@
+# Copyright (c) 2011 Google Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#     * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import os
+
+from webkitpy.common.system import environment, executive, filesystem, platforminfo, user, workspace
+
+
+class SystemHost(object):
+    def __init__(self):
+        self.executive = executive.Executive()
+        self.filesystem = filesystem.FileSystem()
+        self.user = user.User()
+        self.platform = platforminfo.PlatformInfo(self.executive)
+        self.workspace = workspace.Workspace(self.filesystem, self.executive)
+
+    def copy_current_environment(self):
+        return environment.Environment(os.environ.copy())
Property changes on: trunk/Tools/Scripts/webkitpy/common/system/systemhost.py
___________________________________________________________________

Added: svn:eol-style

Added: trunk/Tools/Scripts/webkitpy/common/system/systemhost_mock.py (0 => 102393)


--- trunk/Tools/Scripts/webkitpy/common/system/systemhost_mock.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/common/system/systemhost_mock.py	2011-12-09 00:20:39 UTC (rev 102393)
@@ -0,0 +1,48 @@
+    # Copyright (c) 2011 Google Inc. All rights reserved.
+    #
+    # Redistribution and use in source and binary forms, with or without
+    # modification, are permitted provided that the following conditions are
+    # met:
+    #
+    #     * Redistributions of source code must retain the above copyright
+    # notice, this list of conditions and the following disclaimer.
+    #     * Redistributions in binary form must reproduce the above
+    # copyright notice, this list of conditions and the following disclaimer
+    # in the documentation and/or other materials provided with the
+    # distribution.
+    #     * Neither the name of Google Inc. nor the names of its
+    # contributors may be used to endorse or promote products derived from
+    # this software without specific prior written permission.
+    #
+    # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+    # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+    # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+    # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+    # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+    # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+    # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+    # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+from webkitpy.common.system.environment import Environment
+from webkitpy.common.system.executive_mock import MockExecutive
+from webkitpy.common.system.filesystem_mock import MockFileSystem
+from webkitpy.common.system.platforminfo_mock import MockPlatformInfo
+from webkitpy.common.system.user_mock import MockUser
+from webkitpy.common.system.workspace_mock import MockWorkspace
+
+
+class MockSystemHost(object):
+    def __init__(self, log_executive=False, executive_throws_when_run=None):
+        self.executive = MockExecutive(should_log=log_executive, should_throw_when_run=executive_throws_when_run)
+        self.filesystem = MockFileSystem()
+        self.user = MockUser()
+        self.platform = MockPlatformInfo()
+
+        # FIXME: Should this take pointers to the filesystem and the executive?
+        self.workspace = MockWorkspace()
+
+    def copy_current_environment(self):
+        return Environment({"MOCK_ENVIRON_COPY": '1'})
Property changes on: trunk/Tools/Scripts/webkitpy/common/system/systemhost_mock.py
___________________________________________________________________

Added: svn:eol-style

_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to