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

abarth at webkit.org abarth at webkit.org
Wed Apr 7 23:42:54 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 8e525c548d20f41d5d4e968a34c7fd9d318a964a
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Nov 16 09:25:03 2009 +0000

    2009-11-16  Adam Barth  <abarth at webkit.org>
    
            Reviewed by Eric Seidel.
    
            Unit test WorkQueue
            https://bugs.webkit.org/show_bug.cgi?id=31531
    
            Adds basic unit testing for WorkQueue.  Just runs through one cycle.
    
            * Scripts/bugzilla-tool:
            * Scripts/modules/statusbot.py:
            * Scripts/modules/workqueue.py:
            * Scripts/modules/workqueue_unittest.py: Added.
            * Scripts/run-webkit-unittests:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51018 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 4cc8291..d36cb31 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,18 @@
+2009-11-16  Adam Barth  <abarth at webkit.org>
+
+        Reviewed by Eric Seidel.
+
+        Unit test WorkQueue
+        https://bugs.webkit.org/show_bug.cgi?id=31531
+
+        Adds basic unit testing for WorkQueue.  Just runs through one cycle.
+
+        * Scripts/bugzilla-tool:
+        * Scripts/modules/statusbot.py:
+        * Scripts/modules/workqueue.py:
+        * Scripts/modules/workqueue_unittest.py: Added.
+        * Scripts/run-webkit-unittests:
+
 2009-11-16  Eric Seidel  <eric at webkit.org>
 
         Reviewed by Adam Barth.
diff --git a/WebKitTools/Scripts/bugzilla-tool b/WebKitTools/Scripts/bugzilla-tool
index 68b244c..f6a3317 100755
--- a/WebKitTools/Scripts/bugzilla-tool
+++ b/WebKitTools/Scripts/bugzilla-tool
@@ -722,6 +722,9 @@ class LandPatchesFromCommitQueue(Command, WorkQueueDelegate):
                 error("User declined.")
         log("Running WebKit Commit Queue. %s" % datetime.now().strftime(WorkQueue.log_date_format))
 
+    def should_continue_work_queue(self):
+        return True
+
     def next_work_item(self):
         # Fetch patches instead of just bug ids to that we validate reviewer/committer flags on every patch.
         patches = self.tool.bugs.fetch_patches_from_commit_queue(reject_invalid_patches=True)
diff --git a/WebKitTools/Scripts/modules/statusbot.py b/WebKitTools/Scripts/modules/statusbot.py
index 9c9ba04..d9b54b3 100644
--- a/WebKitTools/Scripts/modules/statusbot.py
+++ b/WebKitTools/Scripts/modules/statusbot.py
@@ -56,6 +56,9 @@ class StatusBot:
         self.browser = Browser()
 
     def update_status(self, status, bug_id=None, patch_id=None):
+        # During unit testing, statusbot_host is None
+        if not self.statusbot_host:
+            return
         self.browser.open(self.update_status_url)
         self.browser.select_form(name="update_status")
         if bug_id:
diff --git a/WebKitTools/Scripts/modules/workqueue.py b/WebKitTools/Scripts/modules/workqueue.py
index 379dfb6..1b154cb 100644
--- a/WebKitTools/Scripts/modules/workqueue.py
+++ b/WebKitTools/Scripts/modules/workqueue.py
@@ -33,9 +33,9 @@ import time
 
 from datetime import datetime, timedelta
 
-from logging import log, OutputTee
-from scm import ScriptError
-from statusbot import StatusBot
+from modules.logging import log, OutputTee
+from modules.scm import ScriptError
+from modules.statusbot import StatusBot
 
 class WorkQueueDelegate:
     def queue_log_path(self):
@@ -50,6 +50,9 @@ class WorkQueueDelegate:
     def begin_work_queue(self):
         raise NotImplementedError, "subclasses must implement"
 
+    def should_continue_work_queue(self):
+        raise NotImplementedError, "subclasses must implement"
+
     def next_work_item(self):
         raise NotImplementedError, "subclasses must implement"
 
@@ -78,7 +81,7 @@ class WorkQueue:
         self.status_bot = StatusBot(host=self._delegate.status_host())
 
         self._delegate.begin_work_queue()
-        while (True):
+        while (self._delegate.should_continue_work_queue()):
             self._ensure_work_log_closed()
             try:
                 work_item = self._delegate.next_work_item()
diff --git a/WebKitTools/Scripts/modules/workqueue_unittest.py b/WebKitTools/Scripts/modules/workqueue_unittest.py
new file mode 100644
index 0000000..f3fa310
--- /dev/null
+++ b/WebKitTools/Scripts/modules/workqueue_unittest.py
@@ -0,0 +1,105 @@
+#!/usr/bin/env python
+# Copyright (c) 2009, Google Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+# 
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#     * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (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 shutil
+import tempfile
+import unittest
+
+from modules.workqueue import WorkQueue, WorkQueueDelegate
+
+class WorkQueueTest(unittest.TestCase, WorkQueueDelegate):
+    def test_trivial(self):
+        self.set_up()
+        work_queue = WorkQueue(self)
+        work_queue.run()
+        self.assertEquals(self.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.clean_up()
+
+    def set_up(self):
+        self.callbacks = []
+        self.run_before = False
+        self.temp_dir = tempfile.mkdtemp(suffix="work_queue_test_logs")
+
+    def clean_up(self):
+        os.path.exists(self.queue_log_path())
+        os.path.exists(os.path.join(self.work_logs_directory(), "42.log"))
+        shutil.rmtree(self.temp_dir)
+
+    def queue_log_path(self):
+        self.callbacks.append("queue_log_path")
+        return os.path.join(self.temp_dir, "queue_log_path")
+
+    def work_logs_directory(self):
+        self.callbacks.append("work_logs_directory")
+        return os.path.join(self.temp_dir, "work_log_path")
+
+    def status_host(self):
+        self.callbacks.append("status_host")
+        return None
+
+    def begin_work_queue(self):
+        self.callbacks.append("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
+            return True
+        return False
+
+    def next_work_item(self):
+        self.callbacks.append("next_work_item")
+        return "work_item"
+
+    def should_proceed_with_work_item(self, work_item):
+        self.callbacks.append("should_proceed_with_work_item")
+        self.assertEquals(work_item, "work_item")
+        return (True, "waiting_message", 42)
+
+    def process_work_item(self, work_item):
+        self.callbacks.append("process_work_item")
+        self.assertEquals(work_item, "work_item")
+
+    def handle_unexpected_error(self, work_item, message):
+        self.callbacks.append("handle_unexpected_error")
+        self.assertEquals(work_item, "work_item")
+
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/WebKitTools/Scripts/run-webkit-unittests b/WebKitTools/Scripts/run-webkit-unittests
index 8d0ef1d..0ad6570 100755
--- a/WebKitTools/Scripts/run-webkit-unittests
+++ b/WebKitTools/Scripts/run-webkit-unittests
@@ -37,6 +37,7 @@ from modules.cpp_style_unittest import *
 from modules.diff_parser_unittest import *
 from modules.logging_unittest import *
 from modules.scm_unittest import *
+from modules.workqueue_unittest import *
 
 if __name__ == "__main__":
     unittest.main()

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list