Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1368)

Unified Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/host_mock.py

Issue 2671583002: Revert of Simplify the initialization of Git objects in Host. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Tools/Scripts/webkitpy/common/host_mock.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/common/host_mock.py b/third_party/WebKit/Tools/Scripts/webkitpy/common/host_mock.py
index b204e2d234391c2a664965c841216d4994515e6b..7bfd8901bb0116ca88cc188949bfed8539b901a2 100644
--- a/third_party/WebKit/Tools/Scripts/webkitpy/common/host_mock.py
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/common/host_mock.py
@@ -42,6 +42,7 @@
def __init__(self,
log_executive=False,
+ initialize_scm_by_default=True,
web=None,
scm=None,
os_name=None,
@@ -55,8 +56,13 @@
add_unit_tests_to_mock_filesystem(self.filesystem)
self.web = web or MockWeb()
+
self._scm = scm
-
+ # TODO(qyearsley): we should never initialize the SCM by default, since
+ # the real object doesn't either. This has caused at least one bug
+ # (see bug 89498).
+ if initialize_scm_by_default:
+ self.initialize_scm()
self.buildbot = MockBuildBot()
# Note: We're using a real PortFactory here. Tests which don't wish to depend
@@ -65,12 +71,17 @@
self.builders = BuilderList(BUILDERS)
- def scm(self, path=None):
- if path:
- return MockGit(cwd=path, filesystem=self.filesystem, executive=self.executive)
+ def initialize_scm(self, patch_directories=None):
if not self._scm:
self._scm = MockGit(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)
+
+ def scm(self):
return self._scm
+
+ def scm_for_path(self, path):
+ # FIXME: consider supporting more than one SCM so that we can do more comprehensive testing.
+ self.initialize_scm()
+ return self._scm

Powered by Google App Engine
This is Rietveld 408576698