Exemplo n.º 1
0
    def test_exception_during_command(self):
        tool = MockTool()
        tool.ensure_irc_connected(None)
        bot = IRCBot("sheriffbot", tool, Sheriff(tool, MockSheriffBot()),
                     irc_command.commands)

        class CommandWithException(object):
            def execute(self, nick, args, tool, sheriff):
                raise Exception("mock_exception")

        bot._parse_command_and_args = lambda request: (CommandWithException, [
        ])
        expected_logs = 'MOCK: irc.post: Exception executing command: mock_exception\n'
        OutputCapture().assert_outputs(self,
                                       bot.process_message,
                                       args=["mock_nick", "ignored message"],
                                       expected_logs=expected_logs)

        class CommandWithException(object):
            def execute(self, nick, args, tool, sheriff):
                raise KeyboardInterrupt()

        bot._parse_command_and_args = lambda request: (CommandWithException, [
        ])
        # KeyboardInterrupt and SystemExit are not subclasses of Exception and thus correctly will not be caught.
        OutputCapture().assert_outputs(self,
                                       bot.process_message,
                                       args=["mock_nick", "ignored message"],
                                       expected_exception=KeyboardInterrupt)
Exemplo n.º 2
0
 def test_parse_command_and_args(self):
     tool = MockTool()
     bot = IRCBot("sheriffbot", tool, Sheriff(tool, MockSheriffBot()), irc_command.commands)
     self.assertEqual(bot._parse_command_and_args(""), (Eliza, [""]))
     self.assertEqual(bot._parse_command_and_args("   "), (Eliza, [""]))
     self.assertEqual(bot._parse_command_and_args(" hi "), (irc_command.Hi, []))
     self.assertEqual(bot._parse_command_and_args(" hi there "), (irc_command.Hi, ["there"]))
Exemplo n.º 3
0
def run(message):
    tool = MockTool()
    tool.ensure_irc_connected(None)
    bot = IRCBot("sheriffbot", tool, Sheriff(tool, MockSheriffBot()),
                 irc_command.commands)
    bot._message_queue.post(["mock_nick", message])
    bot.process_pending_messages()
Exemplo n.º 4
0
 def test_rollout_reason(self):
     sheriff = Sheriff(MockTool(), MockSheriffBot())
     builders = [
         Builder("Foo", None),
         Builder("Bar", None),
     ]
     reason = "Caused builders Foo and Bar to fail."
     self.assertEquals(sheriff._rollout_reason(builders), reason)
Exemplo n.º 5
0
 def test_post_blame_comment_on_bug(self):
     sheriff = Sheriff(MockTool(), MockSheriffBot())
     builders = [
         Builder("Foo", None),
         Builder("Bar", None),
     ]
     commit_info = Mock()
     commit_info.bug_id = lambda: None
     commit_info.revision = lambda: 4321
     commit_info.committer = lambda: None
     commit_info.committer_email = lambda: "*****@*****.**"
     commit_info.reviewer = lambda: None
     commit_info.author = lambda: None
     sheriff.post_automatic_rollout_patch(commit_info, builders)
Exemplo n.º 6
0
 def run():
     sheriff = Sheriff(MockTool(), MockSheriffBot())
     builders = [
         Builder("Foo", None),
         Builder("Bar", None),
     ]
     commit_info = Mock()
     commit_info.bug_id = lambda: None
     commit_info.revision = lambda: 4321
     # Should do nothing with no bug_id
     sheriff.post_blame_comment_on_bug(commit_info, builders, [])
     sheriff.post_blame_comment_on_bug(commit_info, builders, ["mock-test-1", "mock-test-2"])
     # Should try to post a comment to the bug, but MockTool.bugs does nothing.
     commit_info.bug_id = lambda: 1234
     sheriff.post_blame_comment_on_bug(commit_info, builders, [])
     sheriff.post_blame_comment_on_bug(commit_info, builders, ["mock-test-1"])
     sheriff.post_blame_comment_on_bug(commit_info, builders, ["mock-test-1", "mock-test-2"])
Exemplo n.º 7
0
 def begin_work_queue(self):
     self._sheriff = Sheriff(self._tool, self)
     self._irc_bot = IRCBot(self.name, self._tool, self._sheriff, irc_commands)
     self._tool.ensure_irc_connected(self._irc_bot.irc_delegate())
Exemplo n.º 8
0
 def begin_work_queue(self):
     AbstractQueue.begin_work_queue(self)
     self._sheriff = Sheriff(self._tool, self)
     self._irc_bot = SheriffIRCBot(self._tool, self._sheriff)
     self._tool.ensure_irc_connected(self._irc_bot.irc_delegate())
Exemplo n.º 9
0
 def begin_work_queue(self):
     AbstractQueue.begin_work_queue(self)
     self._sheriff = Sheriff(self._tool, self)
     self._irc_bot = IRCBot("perfalizer", self._tool, self._sheriff,
                            self._commands)
     self._tool.ensure_irc_connected(self._irc_bot.irc_delegate())
Exemplo n.º 10
0
 def run():
     tool = MockTool()
     tool.buildbot.light_tree_on_fire()
     sheriff = Sheriff(tool, MockSheriffBot())
     revisions_causing_failures = {}
     sheriff.provoke_flaky_builders(revisions_causing_failures)