def test_guess_reviewer_from_bug(self):
     capture = OutputCapture()
     step = UpdateChangeLogsWithReviewer(MockBugzillaTool(), Mock())
     expected_stderr = "0 reviewed patches on bug 75, cannot infer reviewer.\n"
     capture.assert_outputs(self,
                            step._guess_reviewer_from_bug, [75],
                            expected_stderr=expected_stderr)
Esempio n. 2
0
 def _run_step(self, step, tool=None, options=None, state=None):
     if not tool:
         tool = MockBugzillaTool()
     if not options:
         options = Mock()
     if not state:
         state = {}
     step(tool, options).run(state)
 def test_commit_message_for_current_diff(self):
     tool = MockBugzillaTool()
     mock_commit_message_for_this_commit = Mock()
     mock_commit_message_for_this_commit.message = lambda: "Mock message"
     tool._scm.commit_message_for_this_commit = lambda: mock_commit_message_for_this_commit
     expected_stdout = "Mock message\n"
     self.assert_execute_outputs(CommitMessageForCurrentDiff(), [],
                                 expected_stdout=expected_stdout,
                                 tool=tool)
Esempio n. 4
0
 def test_empty_state(self):
     capture = OutputCapture()
     step = CloseBugForLandDiff(MockBugzillaTool(), Mock())
     expected_stderr = "Committed r49824: <http://trac.webkit.org/changeset/49824>\nNo bug id provided.\n"
     capture.assert_outputs(self,
                            step.run, [{
                                "commit_text": "Mock commit text"
                            }],
                            expected_stderr=expected_stderr)
    def _assert_run_webkit_patch(self, run_args):
        queue = TestQueue()
        tool = MockBugzillaTool()
        queue.bind_to_tool(tool)

        queue.run_webkit_patch(run_args)
        expected_run_args = ["echo", "--status-host=example.com"] + map(
            str, run_args)
        tool.executive.run_and_throw_if_fail.assert_called_with(
            expected_run_args)
 def test_assign_to_committer(self):
     tool = MockBugzillaTool()
     expected_stderr = "Warning, attachment 128 on bug 42 has invalid committer ([email protected])\nBug 77 is already assigned to [email protected] (None).\nBug 76 has no non-obsolete patches, ignoring.\n"
     self.assert_execute_outputs(AssignToCommitter(), [],
                                 expected_stderr=expected_stderr,
                                 tool=tool)
     tool.bugs.reassign_bug.assert_called_with(
         42, "*****@*****.**",
         "Attachment 128 was posted by a committer and has review+, assigning to Eric Seidel for commit."
     )
 def test_patch_collection_delegate_methods(self):
     queue = TestReviewQueue()
     tool = MockBugzillaTool()
     queue.bind_to_tool(tool)
     self.assertEquals(queue.collection_name(), "test-review-queue")
     self.assertEquals(queue.fetch_potential_patch_ids(), [103])
     queue.status_server()
     self.assertTrue(queue.is_terminal_status("Pass"))
     self.assertTrue(queue.is_terminal_status("Fail"))
     self.assertTrue(queue.is_terminal_status("Error: Your patch exploded"))
     self.assertFalse(queue.is_terminal_status("Foo"))
Esempio n. 8
0
 def assert_execute_outputs(self,
                            command,
                            args,
                            expected_stdout="",
                            expected_stderr="",
                            options=Mock(),
                            tool=MockBugzillaTool()):
     command.bind_to_tool(tool)
     OutputCapture().assert_outputs(self,
                                    command.execute, [options, args, tool],
                                    expected_stdout=expected_stdout,
                                    expected_stderr=expected_stderr)
    def test_mark_bug_fixed(self):
        tool = MockBugzillaTool()
        tool._scm.last_svn_commit_log = lambda: "r9876 |"
        options = Mock()
        options.bug_id = 42
        expected_stderr = """Bug: <http://example.com/42> Bug with two r+'d and cq+'d patches, one of which has an invalid commit-queue setter.
Revision: 9876
MOCK: user.open_url: http://example.com/42
Adding comment to Bug 42.
"""
        self.assert_execute_outputs(MarkBugFixed(), [],
                                    expected_stderr=expected_stderr,
                                    tool=tool,
                                    options=options)
Esempio n. 10
0
    def test_rollout(self):
        tool = MockBugzillaTool()
        tool.buildbot.light_tree_on_fire()
        expected_stderr = {
            "begin_work_queue":
            "CAUTION: commit-queue will discard all local changes in \"%s\"\nRunning WebKit commit-queue.\n"
            % MockSCM.fake_checkout_root,
            # FIXME: The commit-queue warns about bad committers twice.  This is due to the fact that we access Attachment.reviewer() twice and it logs each time.
            "next_work_item":
            """Warning, attachment 128 on bug 42 has invalid committer ([email protected])
Warning, attachment 128 on bug 42 has invalid committer ([email protected])
1 patch in commit-queue [106]
""",
        }
        self.assert_queue_outputs(CommitQueue(),
                                  tool=tool,
                                  expected_stderr=expected_stderr)
Esempio n. 11
0
    def assert_queue_outputs(self,
                             queue,
                             args=None,
                             work_item=None,
                             expected_stdout=None,
                             expected_stderr=None,
                             options=Mock(),
                             tool=MockBugzillaTool()):
        if not expected_stdout:
            expected_stdout = {}
        if not expected_stderr:
            expected_stderr = {}
        if not args:
            args = []
        if not work_item:
            work_item = self.mock_work_item
        tool.user.prompt = lambda message: "yes"

        queue.execute(options, args, tool, engine=MockQueueEngine)

        OutputCapture().assert_outputs(
            self,
            queue.queue_log_path,
            expected_stdout=expected_stdout.get("queue_log_path", ""),
            expected_stderr=expected_stderr.get("queue_log_path", ""))
        OutputCapture().assert_outputs(
            self,
            queue.work_item_log_path,
            args=[work_item],
            expected_stdout=expected_stdout.get("work_item_log_path", ""),
            expected_stderr=expected_stderr.get("work_item_log_path", ""))
        OutputCapture().assert_outputs(
            self,
            queue.begin_work_queue,
            expected_stdout=expected_stdout.get("begin_work_queue", ""),
            expected_stderr=expected_stderr.get("begin_work_queue", ""))
        OutputCapture().assert_outputs(
            self,
            queue.should_continue_work_queue,
            expected_stdout=expected_stdout.get("should_continue_work_queue",
                                                ""),
            expected_stderr=expected_stderr.get("should_continue_work_queue",
                                                ""))
        OutputCapture().assert_outputs(
            self,
            queue.next_work_item,
            expected_stdout=expected_stdout.get("next_work_item", ""),
            expected_stderr=expected_stderr.get("next_work_item", ""))
        OutputCapture().assert_outputs(self,
                                       queue.should_proceed_with_work_item,
                                       args=[work_item],
                                       expected_stdout=expected_stdout.get(
                                           "should_proceed_with_work_item",
                                           ""),
                                       expected_stderr=expected_stderr.get(
                                           "should_proceed_with_work_item",
                                           ""))
        OutputCapture().assert_outputs(
            self,
            queue.process_work_item,
            args=[work_item],
            expected_stdout=expected_stdout.get("process_work_item", ""),
            expected_stderr=expected_stderr.get("process_work_item", ""))
        OutputCapture().assert_outputs(
            self,
            queue.handle_unexpected_error,
            args=[work_item, "Mock error message"],
            expected_stdout=expected_stdout.get("handle_unexpected_error", ""),
            expected_stderr=expected_stderr.get("handle_unexpected_error", ""))
Esempio n. 12
0
 def test_prompt_for_bug_or_title_step(self):
     tool = MockBugzillaTool()
     tool.user.prompt = lambda message: 42
     self._run_step(PromptForBugOrTitle, tool=tool)
 def test_empty_state(self):
     capture = OutputCapture()
     step = UpdateChangeLogsWithReviewer(MockBugzillaTool(), Mock())
     capture.assert_outputs(self, step.run, [{}])