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 10 matching lines...) Expand all Loading... |
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
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.checkout_mock import MockCheckout | 29 from webkitpy.common.checkout.checkout_mock import MockCheckout |
30 from webkitpy.common.checkout.scm.scm_mock import MockSCM | 30 from webkitpy.common.checkout.scm.scm_mock import MockSCM |
31 from webkitpy.common.net.bugzilla.bugzilla_mock import MockBugzilla | |
32 from webkitpy.common.net.buildbot.buildbot_mock import MockBuildBot | 31 from webkitpy.common.net.buildbot.buildbot_mock import MockBuildBot |
33 from webkitpy.common.net.web_mock import MockWeb | 32 from webkitpy.common.net.web_mock import MockWeb |
34 from webkitpy.common.system.systemhost_mock import MockSystemHost | 33 from webkitpy.common.system.systemhost_mock import MockSystemHost |
35 from webkitpy.common.watchlist.watchlist_mock import MockWatchList | |
36 | 34 |
37 # New-style ports need to move down into webkitpy.common. | 35 # New-style ports need to move down into webkitpy.common. |
38 from webkitpy.layout_tests.port.factory import PortFactory | 36 from webkitpy.layout_tests.port.factory import PortFactory |
39 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 |
40 | 38 |
41 | 39 |
42 class MockHost(MockSystemHost): | 40 class MockHost(MockSystemHost): |
43 def __init__(self, log_executive=False, executive_throws_when_run=None, init
ialize_scm_by_default=True, web=None): | 41 def __init__(self, log_executive=False, executive_throws_when_run=None, init
ialize_scm_by_default=True, web=None): |
44 MockSystemHost.__init__(self, log_executive, executive_throws_when_run) | 42 MockSystemHost.__init__(self, log_executive, executive_throws_when_run) |
45 add_unit_tests_to_mock_filesystem(self.filesystem) | 43 add_unit_tests_to_mock_filesystem(self.filesystem) |
46 self.web = web or MockWeb() | 44 self.web = web or MockWeb() |
47 | 45 |
48 self._checkout = MockCheckout() | 46 self._checkout = MockCheckout() |
49 self._scm = None | 47 self._scm = None |
50 # 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 |
51 # 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
). |
52 if initialize_scm_by_default: | 50 if initialize_scm_by_default: |
53 self.initialize_scm() | 51 self.initialize_scm() |
54 self.bugs = MockBugzilla() | |
55 self.buildbot = MockBuildBot() | 52 self.buildbot = MockBuildBot() |
56 self._chromium_buildbot = MockBuildBot() | 53 self._chromium_buildbot = MockBuildBot() |
57 | 54 |
58 # Note: We're using a real PortFactory here. Tests which don't wish to
depend | 55 # Note: We're using a real PortFactory here. Tests which don't wish to
depend |
59 # on the list of known ports should override this with a MockPortFactory
. | 56 # on the list of known ports should override this with a MockPortFactory
. |
60 self.port_factory = PortFactory(self) | 57 self.port_factory = PortFactory(self) |
61 | 58 |
62 self._watch_list = MockWatchList() | |
63 | |
64 def initialize_scm(self, patch_directories=None): | 59 def initialize_scm(self, patch_directories=None): |
65 self._scm = MockSCM(filesystem=self.filesystem, executive=self.executive
) | 60 self._scm = MockSCM(filesystem=self.filesystem, executive=self.executive
) |
66 # Various pieces of code (wrongly) call filesystem.chdir(checkout_root). | 61 # Various pieces of code (wrongly) call filesystem.chdir(checkout_root). |
67 # Making the checkout_root exist in the mock filesystem makes that chdir
not raise. | 62 # Making the checkout_root exist in the mock filesystem makes that chdir
not raise. |
68 self.filesystem.maybe_make_directory(self._scm.checkout_root) | 63 self.filesystem.maybe_make_directory(self._scm.checkout_root) |
69 | 64 |
70 def scm(self): | 65 def scm(self): |
71 return self._scm | 66 return self._scm |
72 | 67 |
73 def checkout(self): | 68 def checkout(self): |
74 return self._checkout | 69 return self._checkout |
75 | 70 |
76 def chromium_buildbot(self): | 71 def chromium_buildbot(self): |
77 return self._chromium_buildbot | 72 return self._chromium_buildbot |
78 | |
79 def watch_list(self): | |
80 return self._watch_list | |
81 | |
OLD | NEW |