예제 #1
0
 def test_trivial(self):
     delegate = LoggingDelegate(self)
     work_queue = QueueEngine("trivial-queue", delegate)
     work_queue.run()
     self.assertEquals(delegate._callbacks, LoggingDelegate.expected_callbacks)
     self.assertTrue(os.path.exists(os.path.join(self.temp_dir, "queue_log_path")))
     self.assertTrue(os.path.exists(os.path.join(self.temp_dir, "work_log_path", "work_item.log")))
예제 #2
0
 def test_unexpected_error(self):
     delegate = ThrowErrorDelegate(self, 3)
     work_queue = QueueEngine("error-queue", delegate)
     work_queue.run()
     expected_callbacks = LoggingDelegate.expected_callbacks[:]
     work_item_index = expected_callbacks.index('process_work_item')
     # The unexpected error should be handled right after process_work_item starts
     # but before any other callback.  Otherwise callbacks should be normal.
     expected_callbacks.insert(work_item_index + 1, 'handle_unexpected_error')
     self.assertEquals(delegate._callbacks, expected_callbacks)
예제 #3
0
 def test_unexpected_error(self):
     delegate = ThrowErrorDelegate(self, 3)
     work_queue = QueueEngine("error-queue", delegate)
     work_queue.run()
     expected_callbacks = LoggingDelegate.expected_callbacks[:]
     work_item_index = expected_callbacks.index('process_work_item')
     # The unexpected error should be handled right after process_work_item starts
     # but before any other callback.  Otherwise callbacks should be normal.
     expected_callbacks.insert(work_item_index + 1,
                               'handle_unexpected_error')
     self.assertEquals(delegate._callbacks, expected_callbacks)
예제 #4
0
 def test_trivial(self):
     delegate = LoggingDelegate(self)
     work_queue = QueueEngine("trivial-queue", delegate)
     work_queue.run()
     self.assertEquals(delegate._callbacks,
                       LoggingDelegate.expected_callbacks)
     self.assertTrue(
         os.path.exists(os.path.join(self.temp_dir, "queue_log_path")))
     self.assertTrue(
         os.path.exists(
             os.path.join(self.temp_dir, "work_log_path", "work_item.log")))
예제 #5
0
 def run_and_handle_errors(self, tool, options, state=None):
     if not state:
         state = {}
     try:
         self._run(tool, options, state)
     except CheckoutNeedsUpdate, e:
         log("Commit failed because the checkout is out of date.  Please update and try again.")
         log(
             "You can pass --no-build to skip building/testing after update if you believe the new commits did not affect the results."
         )
         QueueEngine.exit_after_handled_error(e)
예제 #6
0
 def run_and_handle_errors(self, tool, options, state=None):
     if not state:
         state = {}
     try:
         self._run(tool, options, state)
     except CheckoutNeedsUpdate, e:
         log("Commit failed because the checkout is out of date.  Please update and try again."
             )
         log("You can pass --no-build to skip building/testing after update if you believe the new commits did not affect the results."
             )
         QueueEngine.exit_after_handled_error(e)
예제 #7
0
class StepSequence(object):
    def __init__(self, steps):
        self._steps = steps or []

    def options(self):
        collected_options = [
            CommandOptions.parent_command,
            CommandOptions.quiet,
        ]
        for step in self._steps:
            collected_options = collected_options + step.options()
        # Remove duplicates.
        collected_options = sorted(set(collected_options))
        return collected_options

    def _run(self, tool, options, state):
        for step in self._steps:
            step(tool, options).run(state)

    def run_and_handle_errors(self, tool, options, state=None):
        if not state:
            state = {}
        try:
            self._run(tool, options, state)
        except CheckoutNeedsUpdate, e:
            log("Commit failed because the checkout is out of date.  Please update and try again."
                )
            log("You can pass --no-build to skip building/testing after update if you believe the new commits did not affect the results."
                )
            QueueEngine.exit_after_handled_error(e)
        except ScriptError, e:
            if not options.quiet:
                log(e.message_with_output())
            if options.parent_command:
                command = tool.command_by_name(options.parent_command)
                command.handle_script_error(tool, state, e)
            QueueEngine.exit_after_handled_error(e)
예제 #8
0
 def test_handled_error(self):
     delegate = ThrowErrorDelegate(self, QueueEngine.handled_error_code)
     work_queue = QueueEngine("handled-error-queue", delegate)
     work_queue.run()
     self.assertEquals(delegate._callbacks,
                       LoggingDelegate.expected_callbacks)
예제 #9
0
 def __init__(self, delegate):
     QueueEngine.__init__(self, "fast-queue", delegate)
예제 #10
0
 def test_handled_error(self):
     delegate = ThrowErrorDelegate(self, QueueEngine.handled_error_code)
     work_queue = QueueEngine("handled-error-queue", delegate)
     work_queue.run()
     self.assertEquals(delegate._callbacks, LoggingDelegate.expected_callbacks)
예제 #11
0
 def __init__(self, delegate):
     QueueEngine.__init__(self, "fast-queue", delegate)