| OLD | NEW |
| 1 # Copyright (C) 2011 Google Inc. All rights reserved. | 1 # Copyright (C) 2011 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | 28 |
| 29 from webkitpy.common.checkout.scm.scm_mock import MockSCM | 29 from webkitpy.common.checkout.scm.scm_mock import MockSCM |
| 30 from webkitpy.common.net.buildbot.buildbot_mock import MockBuildBot | 30 from webkitpy.common.net.buildbot.buildbot_mock import MockBuildBot |
| 31 from webkitpy.common.net.web_mock import MockWeb | 31 from webkitpy.common.net.web_mock import MockWeb |
| 32 from webkitpy.common.system.systemhost_mock import MockSystemHost | 32 from webkitpy.common.system.systemhost_mock import MockSystemHost |
| 33 | 33 |
| 34 # New-style ports need to move down into webkitpy.common. | 34 # New-style ports need to move down into webkitpy.common. |
| 35 from webkitpy.layout_tests.builders import Builders |
| 35 from webkitpy.layout_tests.port.factory import PortFactory | 36 from webkitpy.layout_tests.port.factory import PortFactory |
| 36 from webkitpy.layout_tests.port.test import add_unit_tests_to_mock_filesystem | 37 from webkitpy.layout_tests.port.test import add_unit_tests_to_mock_filesystem |
| 37 | 38 |
| 38 | 39 |
| 39 class MockHost(MockSystemHost): | 40 class MockHost(MockSystemHost): |
| 40 | 41 |
| 41 def __init__(self, log_executive=False, executive_throws_when_run=None, init
ialize_scm_by_default=True, web=None, scm=None): | 42 def __init__(self, log_executive=False, executive_throws_when_run=None, init
ialize_scm_by_default=True, web=None, scm=None, os_name=None, os_version=None): |
| 42 MockSystemHost.__init__(self, log_executive, executive_throws_when_run) | 43 MockSystemHost.__init__(self, log_executive, executive_throws_when_run,
os_name=os_name, os_version=os_version) |
| 43 add_unit_tests_to_mock_filesystem(self.filesystem) | 44 add_unit_tests_to_mock_filesystem(self.filesystem) |
| 44 self.web = web or MockWeb() | 45 self.web = web or MockWeb() |
| 45 | 46 |
| 46 self._scm = scm | 47 self._scm = scm |
| 47 # FIXME: we should never initialize the SCM by default, since the real | 48 # FIXME: we should never initialize the SCM by default, since the real |
| 48 # object doesn't either. This has caused at least one bug (see bug 89498
). | 49 # object doesn't either. This has caused at least one bug (see bug 89498
). |
| 49 if initialize_scm_by_default: | 50 if initialize_scm_by_default: |
| 50 self.initialize_scm() | 51 self.initialize_scm() |
| 51 self.buildbot = MockBuildBot() | 52 self.buildbot = MockBuildBot() |
| 52 | 53 |
| 53 # Note: We're using a real PortFactory here. Tests which don't wish to
depend | 54 # Note: We're using a real PortFactory here. Tests which don't wish to
depend |
| 54 # on the list of known ports should override this with a MockPortFactory
. | 55 # on the list of known ports should override this with a MockPortFactory
. |
| 55 self.port_factory = PortFactory(self) | 56 self.port_factory = PortFactory(self) |
| 56 | 57 |
| 58 self.builders = Builders() |
| 59 |
| 57 def initialize_scm(self, patch_directories=None): | 60 def initialize_scm(self, patch_directories=None): |
| 58 if not self._scm: | 61 if not self._scm: |
| 59 self._scm = MockSCM(filesystem=self.filesystem, executive=self.execu
tive) | 62 self._scm = MockSCM(filesystem=self.filesystem, executive=self.execu
tive) |
| 60 # Various pieces of code (wrongly) call filesystem.chdir(checkout_root). | 63 # Various pieces of code (wrongly) call filesystem.chdir(checkout_root). |
| 61 # Making the checkout_root exist in the mock filesystem makes that chdir
not raise. | 64 # Making the checkout_root exist in the mock filesystem makes that chdir
not raise. |
| 62 self.filesystem.maybe_make_directory(self._scm.checkout_root) | 65 self.filesystem.maybe_make_directory(self._scm.checkout_root) |
| 63 | 66 |
| 64 def scm(self): | 67 def scm(self): |
| 65 return self._scm | 68 return self._scm |
| 66 | 69 |
| 67 def scm_for_path(self, path): | 70 def scm_for_path(self, path): |
| 68 # FIXME: consider supporting more than one SCM so that we can do more co
mprehensive testing. | 71 # FIXME: consider supporting more than one SCM so that we can do more co
mprehensive testing. |
| 69 self.initialize_scm() | 72 self.initialize_scm() |
| 70 return self._scm | 73 return self._scm |
| 71 | 74 |
| 72 def checkout(self): | 75 def checkout(self): |
| 73 return self._checkout | 76 return self._checkout |
| OLD | NEW |