Пример #1
0
 def _test_ews(self, ews, results_are_conclusive=True):
     ews.bind_to_tool(MockTool())
     ews.host = MockHost()
     options = Mock()
     options.port = None
     options.run_tests = ews.run_tests
     self.assert_queue_outputs(ews, expected_logs=self._default_expected_logs(ews, results_are_conclusive), options=options)
Пример #2
0
    def assert_queue_outputs(self, queue, args=None, work_item=None, expected_stdout=None, expected_stderr=None, expected_exceptions=None, expected_logs=None, options=None, tool=None):
        if not tool:
            tool = MockTool()
            # This is a hack to make it easy for callers to not have to setup a custom MockFileSystem just to test the commit-queue
            # the cq tries to read the layout test results, and will hit a KeyError in MockFileSystem if we don't do this.
            tool.filesystem.write_text_file('/mock-results/full_results.json', "")
        if not expected_stdout:
            expected_stdout = {}
        if not expected_stderr:
            expected_stderr = {}
        if not args:
            args = []
        if not options:
            options = Mock()
            options.port = None
        if not work_item:
            work_item = self.mock_work_item
        tool.user.prompt = lambda message: "yes"

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

        self.assert_outputs(queue.queue_log_path, "queue_log_path", [], expected_stdout, expected_stderr, expected_exceptions, expected_logs)
        self.assert_outputs(queue.work_item_log_path, "work_item_log_path", [work_item], expected_stdout, expected_stderr, expected_exceptions, expected_logs)
        self.assert_outputs(queue.begin_work_queue, "begin_work_queue", [], expected_stdout, expected_stderr, expected_exceptions, expected_logs)
        self.assert_outputs(queue.should_continue_work_queue, "should_continue_work_queue", [], expected_stdout, expected_stderr, expected_exceptions, expected_logs)
        self.assert_outputs(queue.next_work_item, "next_work_item", [], expected_stdout, expected_stderr, expected_exceptions, expected_logs)
        self.assert_outputs(queue.process_work_item, "process_work_item", [work_item], expected_stdout, expected_stderr, expected_exceptions, expected_logs)
        self.assert_outputs(queue.handle_unexpected_error, "handle_unexpected_error", [work_item, "Mock error message"], expected_stdout, expected_stderr, expected_exceptions, expected_logs)
        # Should we have a different function for testing StepSequenceErrorHandlers?
        if isinstance(queue, StepSequenceErrorHandler):
            self.assert_outputs(queue.handle_script_error, "handle_script_error", [tool, {"patch": self.mock_work_item}, ScriptError(message="ScriptError error message", script_args="MockErrorCommand", output="MOCK output")], expected_stdout, expected_stderr, expected_exceptions, expected_logs)
Пример #3
0
    def assert_queue_outputs(self, queue, args=None, work_item=None, expected_stdout=None, expected_stderr=None, expected_exceptions=None, options=None, tool=None):
        if not tool:
            tool = MockTool()
            # This is a hack to make it easy for callers to not have to setup a custom MockFileSystem just to test the commit-queue
            # the cq tries to read the layout test results, and will hit a KeyError in MockFileSystem if we don't do this.
            tool.filesystem.write_text_file('/mock/results.html', "")
        if not expected_stdout:
            expected_stdout = {}
        if not expected_stderr:
            expected_stderr = {}
        if not args:
            args = []
        if not options:
            options = Mock()
            options.port = None
        if not work_item:
            work_item = self.mock_work_item
        tool.user.prompt = lambda message: "yes"

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

        self.assert_outputs(queue.queue_log_path, "queue_log_path", [], expected_stdout, expected_stderr, expected_exceptions)
        self.assert_outputs(queue.work_item_log_path, "work_item_log_path", [work_item], expected_stdout, expected_stderr, expected_exceptions)
        self.assert_outputs(queue.begin_work_queue, "begin_work_queue", [], expected_stdout, expected_stderr, expected_exceptions)
        self.assert_outputs(queue.should_continue_work_queue, "should_continue_work_queue", [], expected_stdout, expected_stderr, expected_exceptions)
        self.assert_outputs(queue.next_work_item, "next_work_item", [], expected_stdout, expected_stderr, expected_exceptions)
        self.assert_outputs(queue.should_proceed_with_work_item, "should_proceed_with_work_item", [work_item], expected_stdout, expected_stderr, expected_exceptions)
        self.assert_outputs(queue.process_work_item, "process_work_item", [work_item], expected_stdout, expected_stderr, expected_exceptions)
        self.assert_outputs(queue.handle_unexpected_error, "handle_unexpected_error", [work_item, "Mock error message"], expected_stdout, expected_stderr, expected_exceptions)
        # Should we have a different function for testing StepSequenceErrorHandlers?
        if isinstance(queue, StepSequenceErrorHandler):
            self.assert_outputs(queue.handle_script_error, "handle_script_error", [tool, {"patch": self.mock_work_item}, ScriptError(message="ScriptError error message", script_args="MockErrorCommand")], expected_stdout, expected_stderr, expected_exceptions)
Пример #4
0
 def _test_ews(self, ews):
     ews.bind_to_tool(MockTool())
     ews.host = MockHost()
     options = Mock()
     options.port = None
     options.run_tests = ews.run_tests
     self.assert_queue_outputs(ews, expected_logs=self._default_expected_logs(ews), options=options)
Пример #5
0
    def assert_queue_outputs(self, queue, args=None, work_item=None, expected_stdout=None, expected_stderr=None, expected_exceptions=None, options=None, tool=None):
        if not tool:
            tool = MockTool()
        if not expected_stdout:
            expected_stdout = {}
        if not expected_stderr:
            expected_stderr = {}
        if not args:
            args = []
        if not options:
            options = Mock()
            options.port = None
        if not work_item:
            work_item = self.mock_work_item
        tool.user.prompt = lambda message: "yes"

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

        self.assert_outputs(queue.queue_log_path, "queue_log_path", [], expected_stdout, expected_stderr, expected_exceptions)
        self.assert_outputs(queue.work_item_log_path, "work_item_log_path", [work_item], expected_stdout, expected_stderr, expected_exceptions)
        self.assert_outputs(queue.begin_work_queue, "begin_work_queue", [], expected_stdout, expected_stderr, expected_exceptions)
        self.assert_outputs(queue.should_continue_work_queue, "should_continue_work_queue", [], expected_stdout, expected_stderr, expected_exceptions)
        self.assert_outputs(queue.next_work_item, "next_work_item", [], expected_stdout, expected_stderr, expected_exceptions)
        self.assert_outputs(queue.should_proceed_with_work_item, "should_proceed_with_work_item", [work_item], expected_stdout, expected_stderr, expected_exceptions)
        self.assert_outputs(queue.process_work_item, "process_work_item", [work_item], expected_stdout, expected_stderr, expected_exceptions)
        self.assert_outputs(queue.handle_unexpected_error, "handle_unexpected_error", [work_item, "Mock error message"], expected_stdout, expected_stderr, expected_exceptions)
        # Should we have a different function for testing StepSequenceErrorHandlers?
        if isinstance(queue, StepSequenceErrorHandler):
            self.assert_outputs(queue.handle_script_error, "handle_script_error", [tool, {"patch": self.mock_work_item}, ScriptError(message="ScriptError error message", script_args="MockErrorCommand")], expected_stdout, expected_stderr, expected_exceptions)
Пример #6
0
 def _test_ews(self, ews, results_are_conclusive=True, use_security_sensitive_patch=False):
     ews.bind_to_tool(MockTool())
     ews.host = MockHost()
     options = Mock()
     options.port = None
     options.run_tests = ews.run_tests
     work_item = MockTool().bugs.fetch_attachment(10008) if use_security_sensitive_patch else None
     self.assert_queue_outputs(ews, work_item=work_item, expected_logs=self._default_expected_logs(ews, results_are_conclusive, work_item, will_fetch_from_status_server=bool(use_security_sensitive_patch)), options=options)
 def _test_builder_ews(self, ews):
     ews.bind_to_tool(MockTool())
     options = Mock()
     options.port = None
     options.run_tests = ews._default_run_tests
     self.assert_queue_outputs(
         ews,
         expected_logs=self._default_expected_logs(ews),
         options=options)
Пример #8
0
    def assert_queue_outputs(self,
                             queue,
                             args=None,
                             work_item=None,
                             expected_stdout=None,
                             expected_stderr=None,
                             expected_exceptions=None,
                             options=None,
                             tool=None):
        if not tool:
            tool = MockTool()
        if not expected_stdout:
            expected_stdout = {}
        if not expected_stderr:
            expected_stderr = {}
        if not args:
            args = []
        if not options:
            options = Mock()
            options.port = None
        if not work_item:
            work_item = self.mock_work_item
        tool.user.prompt = lambda message: "yes"

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

        self.assert_outputs(queue.queue_log_path, "queue_log_path", [],
                            expected_stdout, expected_stderr,
                            expected_exceptions)
        self.assert_outputs(queue.work_item_log_path, "work_item_log_path",
                            [work_item], expected_stdout, expected_stderr,
                            expected_exceptions)
        self.assert_outputs(queue.begin_work_queue, "begin_work_queue", [],
                            expected_stdout, expected_stderr,
                            expected_exceptions)
        self.assert_outputs(queue.should_continue_work_queue,
                            "should_continue_work_queue", [], expected_stdout,
                            expected_stderr, expected_exceptions)
        self.assert_outputs(queue.next_work_item, "next_work_item", [],
                            expected_stdout, expected_stderr,
                            expected_exceptions)
        self.assert_outputs(queue.should_proceed_with_work_item,
                            "should_proceed_with_work_item", [work_item],
                            expected_stdout, expected_stderr,
                            expected_exceptions)
        self.assert_outputs(queue.process_work_item, "process_work_item",
                            [work_item], expected_stdout, expected_stderr,
                            expected_exceptions)
        self.assert_outputs(queue.handle_unexpected_error,
                            "handle_unexpected_error",
                            [work_item, "Mock error message"], expected_stdout,
                            expected_stderr, expected_exceptions)
        # Should we have a different function for testing StepSequenceErrorHandlers?
        if isinstance(queue, StepSequenceErrorHandler):
            self.assert_outputs(
                queue.handle_script_error, "handle_script_error", [
                    tool, {
                        "patch": self.mock_work_item
                    },
                    ScriptError(message="ScriptError error message",
                                script_args="MockErrorCommand")
                ], expected_stdout, expected_stderr, expected_exceptions)
Пример #9
0
 def _test_builder_ews(self, ews):
     ews.bind_to_tool(MockTool())
     options = Mock()
     options.port = None
     options.run_tests = ews._default_run_tests
     self.assert_queue_outputs(ews, expected_stderr=self._default_expected_stderr(ews), options=options)