def initialize_scm(self, patch_directories=None): if not self._scm: 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)
def mock_checkout_for_test(self): executive = Executive() def mock_run(*args, **kwargs): # Note that we use a real Executive here, not a MockExecutive, so we can test that we're # invoking commit-log-editor correctly. env = os.environ.copy() env['CHANGE_LOG_EMAIL_ADDRESS'] = '*****@*****.**' kwargs['env'] = env return executive.run_command(*args, **kwargs) detector = SCMDetector(self.filesystem, executive) real_scm = detector.detect_scm_system(self.webkit_base) mock_scm = MockSCM() mock_scm.run = mock_run real_checkout = Checkout(real_scm) checkout = Checkout(mock_scm) checkout.script_path = real_checkout.script_path checkout.modified_changelogs = lambda git_commit, changed_files=None: self.changelog_paths return checkout
def __init__(self, log_executive=False, executive_throws_when_run=None): MockSystemHost.__init__(self, log_executive, executive_throws_when_run) add_unit_tests_to_mock_filesystem(self.filesystem) self.web = MockWeb() self._checkout = MockCheckout() 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) self.bugs = MockBugzilla() self.buildbot = MockBuildBot() self._chromium_buildbot = MockBuildBot() # Note: We're using a real PortFactory here. Tests which don't wish to depend # on the list of known ports should override this with a MockPortFactory. self.port_factory = PortFactory(self) self._watch_list = MockWatchList()
def move(self, origin, destination): if origin in self._exclusion_list: raise Exception("File is not SCM managed: " + origin) return MockSCM.move(self, origin, destination)
def delete_list(self, paths): for path in paths: if path in self._exclusion_list: raise Exception("File is not SCM managed: " + path) return MockSCM.delete_list(self, paths)
def exists(self, path): if path in self._exclusion_list: return False return MockSCM.exists(self, path)
def __init__(self, exclusion_list, filesystem=None, executive=None): MockSCM.__init__(self, filesystem, executive) self._exclusion_list = exclusion_list
def _make_checkout(self): return Checkout(scm=MockSCM(), filesystem=MockFileSystem(), executive=MockExecutive())