[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

eric at webkit.org eric at webkit.org
Thu Apr 8 00:36:37 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 9800e5c6d8ea2fdf2199e4115cd38890d789f27d
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Dec 15 10:07:17 2009 +0000

    2009-12-15  Eric Seidel  <eric at webkit.org>
    
            Reviewed by Adam Barth.
    
            queue sub-commands need --status-host so they can report status
            https://bugs.webkit.org/show_bug.cgi?id=32313
    
            Make --status-bot a global option and make
            run_bugzilla_tool pass --status-bot to sub-commands.
    
            * Scripts/bugzilla-tool:
             - Rename _status to status_bot and make it non-lazy.
            * Scripts/modules/commands/queues.py:
             - Move status updates out of WorkQueue and into individual queues.
            * Scripts/modules/commands/queues_unittest.py:
             - Test that --status-host is passed to bugzilla-tool when run as subcommand.
            * Scripts/modules/mock_bugzillatool.py:
             - Add a MockStatusBot
            * Scripts/modules/workqueue.py:
             - Remove status_host and work_work_logs_directory callbacks.
             - Add new work_item_log_path callback so that WorkQueue doesn't need to know about patches!
            * Scripts/modules/workqueue_unittest.py:
             - Update unit tests to reflect new callbacks.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52145 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 833d9cb..9282cc0 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,27 @@
+2009-12-15  Eric Seidel  <eric at webkit.org>
+
+        Reviewed by Adam Barth.
+
+        queue sub-commands need --status-host so they can report status
+        https://bugs.webkit.org/show_bug.cgi?id=32313
+
+        Make --status-bot a global option and make
+        run_bugzilla_tool pass --status-bot to sub-commands.
+
+        * Scripts/bugzilla-tool:
+         - Rename _status to status_bot and make it non-lazy.
+        * Scripts/modules/commands/queues.py:
+         - Move status updates out of WorkQueue and into individual queues.
+        * Scripts/modules/commands/queues_unittest.py:
+         - Test that --status-host is passed to bugzilla-tool when run as subcommand.
+        * Scripts/modules/mock_bugzillatool.py:
+         - Add a MockStatusBot
+        * Scripts/modules/workqueue.py:
+         - Remove status_host and work_work_logs_directory callbacks.
+         - Add new work_item_log_path callback so that WorkQueue doesn't need to know about patches!
+        * Scripts/modules/workqueue_unittest.py:
+         - Update unit tests to reflect new callbacks.
+
 2009-12-15  Adam Barth  <abarth at webkit.org>
 
         Reviewed by Eric Seidel.
diff --git a/WebKitTools/Scripts/bugzilla-tool b/WebKitTools/Scripts/bugzilla-tool
index 23245f6..2a6ae90 100755
--- a/WebKitTools/Scripts/bugzilla-tool
+++ b/WebKitTools/Scripts/bugzilla-tool
@@ -48,17 +48,21 @@ class BugzillaTool(MultiCommandTool):
     def __init__(self):
         MultiCommandTool.__init__(self)
         self.global_option_parser.add_option("--dry-run", action="callback", help="do not touch remote servers", callback=self.dry_run_callback)
+        self.global_option_parser.add_option("--status-host", action="callback", type="string", nargs=1, help="Hostname (e.g. localhost or commit.webkit.org) where status updates should be posted.", callback=self.status_host_callback)
 
         self.bugs = Bugzilla()
         self.buildbot = BuildBot()
         self.executive = Executive()
         self._scm = None
-        self._status = None
+        self.status_bot = StatusBot()
 
     def dry_run_callback(self, option, opt, value, parser):
         self.scm().dryrun = True
         self.bugs.dryrun = True
 
+    def status_host_callback(self, option, opt, value, parser):
+        self.status_bot.set_host(value)
+
     def scm(self):
         # Lazily initialize SCM to not error-out before command line parsing (or when running non-scm commands).
         original_cwd = os.path.abspath(".")
@@ -76,11 +80,6 @@ class BugzillaTool(MultiCommandTool):
 
         return self._scm
 
-    def status(self):
-        if not self._status:
-            self._status = StatusBot()
-        return self._status
-
     def path(self):
         return __file__
 
diff --git a/WebKitTools/Scripts/modules/commands/queues.py b/WebKitTools/Scripts/modules/commands/queues.py
index ef83a67..1e4b331 100644
--- a/WebKitTools/Scripts/modules/commands/queues.py
+++ b/WebKitTools/Scripts/modules/commands/queues.py
@@ -28,10 +28,12 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+import os
 import re
 
 from datetime import datetime
 from optparse import make_option
+from StringIO import StringIO
 
 from modules.executive import ScriptError
 from modules.grammar import pluralize
@@ -48,7 +50,6 @@ class AbstractQueue(Command, WorkQueueDelegate):
     def __init__(self, options=None): # Default values should never be collections (like []) as default values are shared between invocations
         options_list = (options or []) + [
             make_option("--no-confirm", action="store_false", dest="confirm", default=True, help="Do not ask the user for confirmation before running the queue.  Dangerous!"),
-            make_option("--status-host", action="store", type="string", dest="status_host", default=StatusBot.default_host, help="Hostname (e.g. localhost or commit.webkit.org) where status updates should be posted."),
         ]
         Command.__init__(self, "Run the %s" % self.name, options=options_list)
 
@@ -58,14 +59,14 @@ class AbstractQueue(Command, WorkQueueDelegate):
         except Exception, e:
             log("Failed to CC watchers: %s." % e)
 
+    def _updates_status(self, message, patch, results_file=None):
+        self.tool.status_bot.update_status(self.name, message, patch, results_file)
+
     def queue_log_path(self):
         return "%s.log" % self.name
 
-    def work_logs_directory(self):
-        return "%s-logs" % self.name
-
-    def status_host(self):
-        return self.options.status_host
+    def work_item_log_path(self, patch):
+        return os.path.join("%s-logs" % self.name, "%s.log" % patch["bug_id"])
 
     def begin_work_queue(self):
         log("CAUTION: %s will discard all local changes in %s" % (self.name, self.tool.scm().checkout_root))
@@ -91,7 +92,10 @@ class AbstractQueue(Command, WorkQueueDelegate):
         raise NotImplementedError, "subclasses must implement"
 
     def run_bugzilla_tool(self, args):
-        bugzilla_tool_args = [self.tool.path()] + map(str, args)
+        bugzilla_tool_args = [self.tool.path()]
+        # FIXME: This is a hack, we should have a more general way to pass global options.
+        bugzilla_tool_args += ["--status-host=%s" % self.tool.status_bot.statusbot_host]
+        bugzilla_tool_args += map(str, args)
         self.tool.executive.run_and_throw_if_fail(bugzilla_tool_args)
 
     def log_progress(self, patch_ids):
@@ -117,6 +121,7 @@ class CommitQueue(AbstractQueue, StepSequenceErrorHandler):
     def next_work_item(self):
         patches = self.tool.bugs.fetch_patches_from_commit_queue(reject_invalid_patches=True)
         if not patches:
+            self._updates_status("Empty queue.", None)
             return None
         # Only bother logging if we have patches in the queue.
         self.log_progress([patch['id'] for patch in patches])
@@ -126,8 +131,10 @@ class CommitQueue(AbstractQueue, StepSequenceErrorHandler):
         red_builders_names = self.tool.buildbot.red_core_builders_names()
         if red_builders_names:
             red_builders_names = map(lambda name: "\"%s\"" % name, red_builders_names) # Add quotes around the names.
-            return (False, "Builders [%s] are red. See http://build.webkit.org." % ", ".join(red_builders_names), None)
-        return (True, "Landing patch %s from bug %s." % (patch["id"], patch["bug_id"]), patch)
+            self._updates_status("Builders [%s] are red. See http://build.webkit.org." % ", ".join(red_builders_names), None)
+            return False
+        self._updates_status("Landing patch %s from bug %s." % (patch["id"], patch["bug_id"]), patch)
+        return True
 
     def process_work_item(self, patch):
         self._cc_watchers(patch["bug_id"])
@@ -162,7 +169,6 @@ class AbstractReviewQueue(AbstractQueue, PersistentPatchCollectionDelegate, Step
 
     def begin_work_queue(self):
         AbstractQueue.begin_work_queue(self)
-        self.tool.status().set_host(self.options.status_host)
         self._patches = PersistentPatchCollection(self)
 
     def next_work_item(self):
@@ -192,7 +198,8 @@ class StyleQueue(AbstractReviewQueue):
         AbstractReviewQueue.__init__(self)
 
     def should_proceed_with_work_item(self, patch):
-        return (True, "Checking style for patch %s on bug %s." % (patch["id"], patch["bug_id"]), patch)
+        self._update_status("Checking style for patch %s on bug %s." % (patch["id"], patch["bug_id"]), patch)
+        return True
 
     def process_work_item(self, patch):
         try:
diff --git a/WebKitTools/Scripts/modules/commands/queues_unittest.py b/WebKitTools/Scripts/modules/commands/queues_unittest.py
index 75abbe5..d38159b 100644
--- a/WebKitTools/Scripts/modules/commands/queues_unittest.py
+++ b/WebKitTools/Scripts/modules/commands/queues_unittest.py
@@ -55,12 +55,15 @@ class AbstractQueueTest(CommandsTest):
         self._assert_log_progress_output(["1","2","3"], "3 patches in test-queue [1, 2, 3]\n")
         self._assert_log_progress_output([1], "1 patch in test-queue [1]\n")
 
-    def _assert_run_bugzilla_tool_output(self, run_args, tool_output):
+    def _assert_run_bugzilla_tool(self, run_args):
         queue = TestQueue()
-        queue.bind_to_tool(MockBugzillaTool())
-        # MockBugzillaTool.path() is "echo"
-        self._assert_output(queue.run_bugzilla_tool, [run_args], expected_stdout=tool_output)
+        tool = MockBugzillaTool()
+        queue.bind_to_tool(tool)
+
+        queue.run_bugzilla_tool(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_run_bugzilla_tool(self):
-        self._assert_run_bugzilla_tool_output([1], "")
-        self._assert_run_bugzilla_tool_output(["one", 2], "")
+        self._assert_run_bugzilla_tool([1])
+        self._assert_run_bugzilla_tool(["one", 2])
diff --git a/WebKitTools/Scripts/modules/mock_bugzillatool.py b/WebKitTools/Scripts/modules/mock_bugzillatool.py
index 6beae73..6c07f33 100644
--- a/WebKitTools/Scripts/modules/mock_bugzillatool.py
+++ b/WebKitTools/Scripts/modules/mock_bugzillatool.py
@@ -142,12 +142,18 @@ class MockSCM(Mock):
         return []
 
 
+class MockStatusBot(object):
+    def __init__(self):
+        self.statusbot_host = "example.com"
+
+
 class MockBugzillaTool():
     def __init__(self):
         self.bugs = MockBugzilla()
         self.buildbot = MockBuildBot()
         self.executive = Mock()
         self._scm = MockSCM()
+        self.status_bot = MockStatusBot()
 
     def scm(self):
         return self._scm
diff --git a/WebKitTools/Scripts/modules/statusbot.py b/WebKitTools/Scripts/modules/statusbot.py
index 350aebf..62d18ed 100644
--- a/WebKitTools/Scripts/modules/statusbot.py
+++ b/WebKitTools/Scripts/modules/statusbot.py
@@ -28,6 +28,8 @@
 #
 # WebKit's Python module for interacting with the Commit Queue status page.
 
+from modules.logging import log
+
 # WebKit includes a built copy of BeautifulSoup in Scripts/modules
 # so this import should always succeed.
 from .BeautifulSoup import BeautifulSoup
@@ -65,6 +67,7 @@ class StatusBot:
         if not self.statusbot_host:
             return
 
+        log(status)
         update_status_url = "%s/update-status" % self.statusbot_server_url
         self.browser.open(update_status_url)
         self.browser.select_form(name="update_status")
diff --git a/WebKitTools/Scripts/modules/workqueue.py b/WebKitTools/Scripts/modules/workqueue.py
index f8cbba8..b4fc9e1 100644
--- a/WebKitTools/Scripts/modules/workqueue.py
+++ b/WebKitTools/Scripts/modules/workqueue.py
@@ -45,10 +45,7 @@ class WorkQueueDelegate:
     def queue_log_path(self):
         raise NotImplementedError, "subclasses must implement"
 
-    def work_logs_directory(self):
-        raise NotImplementedError, "subclasses must implement"
-
-    def status_host(self):
+    def work_item_log_path(self, work_item):
         raise NotImplementedError, "subclasses must implement"
 
     def begin_work_queue(self):
@@ -90,7 +87,6 @@ class WorkQueue:
 
     def run(self):
         self._begin_logging()
-        self.status_bot = StatusBot(host=self._delegate.status_host())
 
         self._delegate.begin_work_queue()
         while (self._delegate.should_continue_work_queue()):
@@ -98,13 +94,11 @@ class WorkQueue:
             try:
                 work_item = self._delegate.next_work_item()
                 if not work_item:
-                    self._update_status_and_sleep("Empty queue.")
+                    self._sleep("No work item.")
                     continue
-                (safe_to_proceed, waiting_message, patch) = self._delegate.should_proceed_with_work_item(work_item)
-                if not safe_to_proceed:
-                    self._update_status_and_sleep(waiting_message)
+                if not self._delegate.should_proceed_with_work_item(work_item):
+                    self._sleep("Not proceeding with work item.")
                     continue
-                self.status_bot.update_status(self._name, waiting_message, patch)
             except KeyboardInterrupt, e:
                 log("\nUser terminated queue.")
                 return 1
@@ -115,7 +109,7 @@ class WorkQueue:
                 continue
 
             # FIXME: Work logs should not depend on bug_id specificaly.
-            self._open_work_log(patch["bug_id"])
+            self._open_work_log(work_item)
             try:
                 self._delegate.process_work_item(work_item)
             except ScriptError, e:
@@ -132,9 +126,9 @@ class WorkQueue:
         self._queue_log = self._output_tee.add_log(self._delegate.queue_log_path())
         self._work_log = None
 
-    def _open_work_log(self, bug_id):
-        work_log_path = os.path.join(self._delegate.work_logs_directory(), "%s.log" % bug_id)
-        self._work_log = self._output_tee.add_log(work_log_path)
+    def _open_work_log(self, work_item):
+        work_item_log_path = self._delegate.work_item_log_path(work_item)
+        self._work_log = self._output_tee.add_log(work_item_log_path)
 
     def _ensure_work_log_closed(self):
         # If we still have a bug log open, close it.
@@ -151,9 +145,3 @@ class WorkQueue:
     def _sleep(cls, message):
         log(cls._sleep_message(message))
         time.sleep(cls.seconds_to_sleep)
-
-    def _update_status_and_sleep(self, message):
-        status_message = self._sleep_message(message)
-        self.status_bot.update_status(self._name, status_message)
-        log(status_message)
-        time.sleep(self.seconds_to_sleep)
diff --git a/WebKitTools/Scripts/modules/workqueue_unittest.py b/WebKitTools/Scripts/modules/workqueue_unittest.py
index ed77b5f..edb6fd9 100644
--- a/WebKitTools/Scripts/modules/workqueue_unittest.py
+++ b/WebKitTools/Scripts/modules/workqueue_unittest.py
@@ -43,12 +43,11 @@ class LoggingDelegate(WorkQueueDelegate):
 
     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',
+        'work_item_log_path',
         'process_work_item',
         'should_continue_work_queue'
     ]
@@ -60,13 +59,9 @@ class LoggingDelegate(WorkQueueDelegate):
         self.record("queue_log_path")
         return os.path.join(self._test.temp_dir, "queue_log_path")
 
-    def work_logs_directory(self):
-        self.record("work_logs_directory")
-        return os.path.join(self._test.temp_dir, "work_log_path")
-
-    def status_host(self):
-        self.record("status_host")
-        return None
+    def work_item_log_path(self, work_item):
+        self.record("work_item_log_path")
+        return os.path.join(self._test.temp_dir, "work_log_path", "%s.log" % work_item)
 
     def begin_work_queue(self):
         self.record("begin_work_queue")
@@ -111,8 +106,7 @@ class NotSafeToProceedDelegate(LoggingDelegate):
     def should_proceed_with_work_item(self, work_item):
         self.record("should_proceed_with_work_item")
         self._test.assertEquals(work_item, "work_item")
-        fake_patch = { 'bug_id' : 42 }
-        return (False, "waiting_message", fake_patch)
+        return False
 
 
 class FastWorkQueue(WorkQueue):
@@ -122,7 +116,7 @@ class FastWorkQueue(WorkQueue):
     # No sleep for the wicked.
     seconds_to_sleep = 0
 
-    def _update_status_and_sleep(self, message):
+    def _sleep(self, message):
         pass
 
 
@@ -132,8 +126,8 @@ class WorkQueueTest(unittest.TestCase):
         work_queue = WorkQueue("trivial-queue", delegate)
         work_queue.run()
         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")))
+        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")))
 
     def test_unexpected_error(self):
         delegate = ThrowErrorDelegate(self, 3)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list