[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.16-1409-g5afdf4d

eric at webkit.org eric at webkit.org
Thu Dec 3 13:37:25 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit 15cbcf8ae98e86ca937aec6e5c4bed71ebe2b41f
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Nov 16 11:04:09 2009 +0000

    2009-11-16  Eric Seidel  <eric at webkit.org>
    
            Reviewed by Adam Barth.
    
            WorkQueue is the only place that should know about special exit codes
            https://bugs.webkit.org/show_bug.cgi?id=31534
    
            Move LandPatchesFromBugs.handled_error to WorkQueue.exit_after_handled_error
            and add tests for handling exit codes.
            I also cleaned up workqueue_unittest.py more.
    
            * Scripts/bugzilla-tool:
            * Scripts/modules/workqueue.py:
            * Scripts/modules/workqueue_unittest.py:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51024 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 4ccefce..8e9ff04 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -2,6 +2,21 @@
 
         Reviewed by Adam Barth.
 
+        WorkQueue is the only place that should know about special exit codes
+        https://bugs.webkit.org/show_bug.cgi?id=31534
+
+        Move LandPatchesFromBugs.handled_error to WorkQueue.exit_after_handled_error
+        and add tests for handling exit codes.
+        I also cleaned up workqueue_unittest.py more.
+
+        * Scripts/bugzilla-tool:
+        * Scripts/modules/workqueue.py:
+        * Scripts/modules/workqueue_unittest.py:
+
+2009-11-16  Eric Seidel  <eric at webkit.org>
+
+        Reviewed by Adam Barth.
+
         Re-factor workqueue_unittest to allow for more than one test.
         https://bugs.webkit.org/show_bug.cgi?id=31535
 
diff --git a/WebKitTools/Scripts/bugzilla-tool b/WebKitTools/Scripts/bugzilla-tool
index f1efeb0..60cb34c 100755
--- a/WebKitTools/Scripts/bugzilla-tool
+++ b/WebKitTools/Scripts/bugzilla-tool
@@ -376,11 +376,6 @@ class LandPatchesFromBugs(Command):
         options += WebKitLandingScripts.land_options()
         Command.__init__(self, 'Lands all patches on a bug optionally testing them first', 'BUGID', options=options)
 
-    @staticmethod
-    def handled_error(error):
-        log(error)
-        exit(2) # Exit 2 insted of 1 to indicate to the commit-queue to indicate we handled the error, and that the queue should keep looping.
-
     @classmethod
     def _close_bug_if_no_active_patches(cls, bugs, bug_id):
         # This should check to make sure there are no r? or r+ patches on the bug before closing.
@@ -409,11 +404,11 @@ class LandPatchesFromBugs(Command):
         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.")
-            cls.handled_error(e)
+            WorkQueue.exit_after_handled_error(e)
         except ScriptError, e:
             # Mark the patch as commit-queue- and comment in the bug.
             tool.bugs.reject_patch_from_commit_queue(patch['id'], e.message_with_output())
-            cls.handled_error(e)
+            WorkQueue.exit_after_handled_error(e)
 
     @staticmethod
     def _fetch_list_of_patches_to_land(options, args, tool):
diff --git a/WebKitTools/Scripts/modules/workqueue.py b/WebKitTools/Scripts/modules/workqueue.py
index 1b154cb..5698f05 100644
--- a/WebKitTools/Scripts/modules/workqueue.py
+++ b/WebKitTools/Scripts/modules/workqueue.py
@@ -75,6 +75,13 @@ class WorkQueue:
     log_date_format = "%Y-%m-%d %H:%M:%S"
     sleep_duration_text = "5 mins"
     seconds_to_sleep = 300
+    handled_error_code = 2
+
+    # Child processes exit with a special code to the parent queue process can detect the error was handled.
+    @classmethod
+    def exit_after_handled_error(cls, error):
+        log(error)
+        exit(cls.handled_error_code)
 
     def run(self):
         self._begin_logging()
@@ -102,9 +109,9 @@ class WorkQueue:
             try:
                 self._delegate.process_work_item(work_item)
             except ScriptError, e:
-                # exit(2) is a special exit code we use to indicate that the error was already
-                # handled by and we should keep looping anyway.
-                if e.exit_code == 2:
+                # Use a special exit code to indicate that the error was already
+                # handled in the child process and we should just keep looping.
+                if e.exit_code == self.handled_error_code:
                     continue
                 message = "Unexpected failure when landing patch!  Please file a bug against bugzilla-tool.\n%s" % e.message_with_output()
                 self._delegate.handle_unexpected_error(work_item, message)
diff --git a/WebKitTools/Scripts/modules/workqueue_unittest.py b/WebKitTools/Scripts/modules/workqueue_unittest.py
index ed7d0b2..efaddbf 100644
--- a/WebKitTools/Scripts/modules/workqueue_unittest.py
+++ b/WebKitTools/Scripts/modules/workqueue_unittest.py
@@ -32,71 +32,104 @@ import shutil
 import tempfile
 import unittest
 
+from modules.scm import ScriptError
 from modules.workqueue import WorkQueue, WorkQueueDelegate
 
 class LoggingDelegate(WorkQueueDelegate):
     def __init__(self, test):
-        self.test = test
-        self.callbacks = []
-        self.run_before = False
+        self._test = test
+        self._callbacks = []
+        self._run_before = False
+
+    expected_callbacks = [
+        'queue_log_path',
+        'status_host',
+        'begin_work_queue',
+        'should_continue_work_queue',
+        'next_work_item',
+        'should_proceed_with_work_item',
+        'work_logs_directory',
+        'process_work_item',
+        'should_continue_work_queue'
+    ]
+
+    def record(self, method_name):
+        self._callbacks.append(method_name)
 
     def queue_log_path(self):
-        self.callbacks.append("queue_log_path")
-        return os.path.join(self.test.temp_dir, "queue_log_path")
+        self.record("queue_log_path")
+        return os.path.join(self._test.temp_dir, "queue_log_path")
 
     def work_logs_directory(self):
-        self.callbacks.append("work_logs_directory")
-        return os.path.join(self.test.temp_dir, "work_log_path")
+        self.record("work_logs_directory")
+        return os.path.join(self._test.temp_dir, "work_log_path")
 
     def status_host(self):
-        self.callbacks.append("status_host")
+        self.record("status_host")
         return None
 
     def begin_work_queue(self):
-        self.callbacks.append("begin_work_queue")
+        self.record("begin_work_queue")
 
     def should_continue_work_queue(self):
-        self.callbacks.append("should_continue_work_queue")
-        if not self.run_before:
-            self.run_before = True
+        self.record("should_continue_work_queue")
+        if not self._run_before:
+            self._run_before = True
             return True
         return False
 
     def next_work_item(self):
-        self.callbacks.append("next_work_item")
+        self.record("next_work_item")
         return "work_item"
 
     def should_proceed_with_work_item(self, work_item):
-        self.callbacks.append("should_proceed_with_work_item")
-        self.test.assertEquals(work_item, "work_item")
+        self.record("should_proceed_with_work_item")
+        self._test.assertEquals(work_item, "work_item")
         return (True, "waiting_message", 42)
 
     def process_work_item(self, work_item):
-        self.callbacks.append("process_work_item")
-        self.test.assertEquals(work_item, "work_item")
+        self.record("process_work_item")
+        self._test.assertEquals(work_item, "work_item")
 
     def handle_unexpected_error(self, work_item, message):
-        self.callbacks.append("handle_unexpected_error")
-        self.test.assertEquals(work_item, "work_item")
+        self.record("handle_unexpected_error")
+        self._test.assertEquals(work_item, "work_item")
+
+class ThrowErrorDelegate(LoggingDelegate):
+    def __init__(self, test, error_code):
+        LoggingDelegate.__init__(self, test)
+        self.error_code = error_code
+
+    def process_work_item(self, work_item):
+        self.record("process_work_item")
+        raise ScriptError(exit_code=self.error_code)
 
 class WorkQueueTest(unittest.TestCase):
     def test_trivial(self):
         delegate = LoggingDelegate(self)
         work_queue = WorkQueue(delegate)
         work_queue.run()
-        self.assertEquals(delegate.callbacks, [
-            'queue_log_path',
-            'status_host',
-            'begin_work_queue',
-            'should_continue_work_queue',
-            'next_work_item',
-            'should_proceed_with_work_item',
-            'work_logs_directory',
-            'process_work_item',
-            'should_continue_work_queue'])
+        self.assertEquals(delegate._callbacks, LoggingDelegate.expected_callbacks)
         self.assertTrue(os.path.exists(delegate.queue_log_path()))
         self.assertTrue(os.path.exists(os.path.join(delegate.work_logs_directory(), "42.log")))
 
+    def test_unexpected_error(self):
+        delegate = ThrowErrorDelegate(self, 3)
+        work_queue = WorkQueue(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)
+
+    def test_handled_error(self):
+        delegate = ThrowErrorDelegate(self, WorkQueue.handled_error_code)
+        work_queue = WorkQueue(delegate)
+        work_queue.run()
+        self.assertEquals(delegate._callbacks, LoggingDelegate.expected_callbacks)
+
     def setUp(self):
         self.temp_dir = tempfile.mkdtemp(suffix="work_queue_test_logs")
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list