示例#1
0
    def __init__(self,
                 log_executive=False,
                 executive_throws_when_run=None,
                 initialize_scm_by_default=True,
                 web=None,
                 create_stub_repository_files=False):
        MockSystemHost.__init__(self, log_executive, executive_throws_when_run)
        add_unit_tests_to_mock_filesystem(self.filesystem)
        if create_stub_repository_files:
            add_checkout_information_json_to_mock_filesystem(self.filesystem)
        self.web = web or MockWeb()

        self._checkout = MockCheckout()
        self._scm = None
        # FIXME: 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.bugs = MockBugzilla()
        self.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()
示例#2
0
    def test_prepare_state(self):
        command = AbstractRevertPrepCommand()
        mock_commit_info = MockCheckout().commit_info_for_revision(123)
        command._commit_info = lambda revision: mock_commit_info

        state = command._prepare_state(None, ["124 123 125", "Reason"], None)
        self.assertEqual(123, state["revision"])
        self.assertEqual([123, 124, 125], state["revision_list"])

        self.assertRaises(ScriptError, command._prepare_state, options=None, args=["125 r122  123", "Reason"], tool=None)
        self.assertRaises(ScriptError, command._prepare_state, options=None, args=["125 foo 123", "Reason"], tool=None)

        command._commit_info = lambda revision: None
        state = command._prepare_state(None, ["124 123 125", "Reason"], None)
        self.assertEqual(123, state["revision"])
        self.assertEqual([123, 124, 125], state["revision_list"])
示例#3
0
    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()