[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.17-1283-gcf603cf
abarth at webkit.org
abarth at webkit.org
Tue Jan 5 23:54:59 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit e1959ab8b28e63a4f04bbf869777e3fd54d9bb87
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Dec 19 06:33:49 2009 +0000
2009-12-18 Adam Barth <abarth at webkit.org>
Rubber stamped by Eric Seidel.
Renamed WorkQueue to QueueEngine. WorkQueue is not a queue.
* Scripts/modules/commands/queues.py:
* Scripts/modules/queueengine.py: Added.
* Scripts/modules/queueengine_unittest.py: Added.
* Scripts/modules/stepsequence.py:
* Scripts/modules/workqueue.py: Removed.
* Scripts/modules/workqueue_unittest.py: Removed.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52378 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 24fc2c1..3d34f84 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,5 +1,18 @@
2009-12-18 Adam Barth <abarth at webkit.org>
+ Rubber stamped by Eric Seidel.
+
+ Renamed WorkQueue to QueueEngine. WorkQueue is not a queue.
+
+ * Scripts/modules/commands/queues.py:
+ * Scripts/modules/queueengine.py: Added.
+ * Scripts/modules/queueengine_unittest.py: Added.
+ * Scripts/modules/stepsequence.py:
+ * Scripts/modules/workqueue.py: Removed.
+ * Scripts/modules/workqueue_unittest.py: Removed.
+
+2009-12-18 Adam Barth <abarth at webkit.org>
+
Reviewed by Eric Seidel.
Add watches for EWS
diff --git a/WebKitTools/Scripts/modules/commands/queues.py b/WebKitTools/Scripts/modules/commands/queues.py
index ebf06e6..e6e1503 100644
--- a/WebKitTools/Scripts/modules/commands/queues.py
+++ b/WebKitTools/Scripts/modules/commands/queues.py
@@ -41,9 +41,9 @@ from modules.multicommandtool import Command
from modules.patchcollection import PersistentPatchCollection, PersistentPatchCollectionDelegate
from modules.statusbot import StatusBot
from modules.stepsequence import StepSequenceErrorHandler
-from modules.workqueue import WorkQueue, WorkQueueDelegate
+from modules.queueengine import QueueEngine, QueueEngineDelegate
-class AbstractQueue(Command, WorkQueueDelegate):
+class AbstractQueue(Command, QueueEngineDelegate):
watchers = [
"webkit-bot-watchers at googlegroups.com",
]
@@ -74,7 +74,7 @@ class AbstractQueue(Command, WorkQueueDelegate):
response = raw_input("Are you sure? Type \"yes\" to continue: ")
if (response != "yes"):
error("User declined.")
- log("Running WebKit %s. %s" % (self.name, datetime.now().strftime(WorkQueue.log_date_format)))
+ log("Running WebKit %s. %s" % (self.name, datetime.now().strftime(QueueEngine.log_date_format)))
def should_continue_work_queue(self):
return True
@@ -104,7 +104,7 @@ class AbstractQueue(Command, WorkQueueDelegate):
def execute(self, options, args, tool):
self.options = options
self.tool = tool
- work_queue = WorkQueue(self.name, self)
+ work_queue = QueueEngine(self.name, self)
return work_queue.run()
diff --git a/WebKitTools/Scripts/modules/queueengine.py b/WebKitTools/Scripts/modules/queueengine.py
new file mode 100644
index 0000000..6cb1e13
--- /dev/null
+++ b/WebKitTools/Scripts/modules/queueengine.py
@@ -0,0 +1,147 @@
+#!/usr/bin/env python
+# Copyright (c) 2009, Google Inc. All rights reserved.
+# Copyright (c) 2009 Apple 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 time
+import traceback
+
+from datetime import datetime, timedelta
+
+from modules.executive import ScriptError
+from modules.logging import log, OutputTee
+from modules.statusbot import StatusBot
+
+class QueueEngineDelegate:
+ def queue_name(self):
+ raise NotImplementedError, "subclasses must implement"
+
+ def queue_log_path(self):
+ raise NotImplementedError, "subclasses must implement"
+
+ def work_item_log_path(self, work_item):
+ raise NotImplementedError, "subclasses must implement"
+
+ 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"
+
+ def should_proceed_with_work_item(self, work_item):
+ # returns (safe_to_proceed, waiting_message, patch)
+ raise NotImplementedError, "subclasses must implement"
+
+ def process_work_item(self, work_item):
+ raise NotImplementedError, "subclasses must implement"
+
+ def handle_unexpected_error(self, work_item, message):
+ raise NotImplementedError, "subclasses must implement"
+
+
+class QueueEngine:
+ def __init__(self, name, delegate):
+ self._name = name
+ self._delegate = delegate
+ self._output_tee = OutputTee()
+
+ 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()
+
+ self._delegate.begin_work_queue()
+ while (self._delegate.should_continue_work_queue()):
+ try:
+ self._ensure_work_log_closed()
+ work_item = self._delegate.next_work_item()
+ if not work_item:
+ self._sleep("No work item.")
+ continue
+ if not self._delegate.should_proceed_with_work_item(work_item):
+ self._sleep("Not proceeding with work item.")
+ continue
+
+ # FIXME: Work logs should not depend on bug_id specificaly.
+ # This looks fixed, no?
+ self._open_work_log(work_item)
+ try:
+ self._delegate.process_work_item(work_item)
+ except ScriptError, e:
+ # 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)
+ except KeyboardInterrupt, e:
+ log("\nUser terminated queue.")
+ return 1
+ except Exception, e:
+ traceback.print_exc()
+ # Don't try tell the status bot, in case telling it causes an exception.
+ self._sleep("Exception while preparing queue: %s." % e)
+ # Never reached.
+ self._ensure_work_log_closed()
+
+ def _begin_logging(self):
+ self._queue_log = self._output_tee.add_log(self._delegate.queue_log_path())
+ self._work_log = None
+
+ 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.
+ if self._work_log:
+ self._output_tee.remove_log(self._work_log)
+ self._work_log = None
+
+ @classmethod
+ def _sleep_message(cls, message):
+ wake_time = datetime.now() + timedelta(seconds=cls.seconds_to_sleep)
+ return "%s Sleeping until %s (%s)." % (message, wake_time.strftime(cls.log_date_format), cls.sleep_duration_text)
+
+ @classmethod
+ def _sleep(cls, message):
+ log(cls._sleep_message(message))
+ time.sleep(cls.seconds_to_sleep)
diff --git a/WebKitTools/Scripts/modules/queueengine_unittest.py b/WebKitTools/Scripts/modules/queueengine_unittest.py
new file mode 100644
index 0000000..8f1093d
--- /dev/null
+++ b/WebKitTools/Scripts/modules/queueengine_unittest.py
@@ -0,0 +1,170 @@
+#!/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.executive import ScriptError
+from modules.queueengine import QueueEngine, QueueEngineDelegate
+
+class LoggingDelegate(QueueEngineDelegate):
+ def __init__(self, test):
+ self._test = test
+ self._callbacks = []
+ self._run_before = False
+
+ expected_callbacks = [
+ 'queue_log_path',
+ 'begin_work_queue',
+ 'should_continue_work_queue',
+ 'next_work_item',
+ 'should_proceed_with_work_item',
+ 'work_item_log_path',
+ 'process_work_item',
+ 'should_continue_work_queue'
+ ]
+
+ def record(self, method_name):
+ self._callbacks.append(method_name)
+
+ def queue_log_path(self):
+ self.record("queue_log_path")
+ return os.path.join(self._test.temp_dir, "queue_log_path")
+
+ 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")
+
+ def should_continue_work_queue(self):
+ 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.record("next_work_item")
+ return "work_item"
+
+ 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 (True, "waiting_message", fake_patch)
+
+ def process_work_item(self, work_item):
+ self.record("process_work_item")
+ self._test.assertEquals(work_item, "work_item")
+
+ def handle_unexpected_error(self, work_item, message):
+ 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 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")
+ return False
+
+
+class FastQueueEngine(QueueEngine):
+ def __init__(self, delegate):
+ QueueEngine.__init__(self, "fast-queue", delegate)
+
+ # No sleep for the wicked.
+ seconds_to_sleep = 0
+
+ def _sleep(self, message):
+ pass
+
+
+class QueueEngineTest(unittest.TestCase):
+ 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")))
+
+ 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)
+
+ 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)
+
+ def test_not_safe_to_proceed(self):
+ delegate = NotSafeToProceedDelegate(self)
+ work_queue = FastQueueEngine(delegate)
+ work_queue.run()
+ expected_callbacks = LoggingDelegate.expected_callbacks[:]
+ next_work_item_index = expected_callbacks.index('next_work_item')
+ # We slice out the common part of the expected callbacks.
+ # We add 2 here to include should_proceed_with_work_item, which is
+ # a pain to search for directly because it occurs twice.
+ expected_callbacks = expected_callbacks[:next_work_item_index + 2]
+ expected_callbacks.append('should_continue_work_queue')
+ self.assertEquals(delegate._callbacks, expected_callbacks)
+
+ def setUp(self):
+ self.temp_dir = tempfile.mkdtemp(suffix="work_queue_test_logs")
+
+ def tearDown(self):
+ shutil.rmtree(self.temp_dir)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/WebKitTools/Scripts/modules/stepsequence.py b/WebKitTools/Scripts/modules/stepsequence.py
index 0858f91..f7ebce9 100644
--- a/WebKitTools/Scripts/modules/stepsequence.py
+++ b/WebKitTools/Scripts/modules/stepsequence.py
@@ -30,7 +30,7 @@ from modules.buildsteps import CommandOptions
from modules.executive import ScriptError
from modules.logging import log
from modules.scm import CheckoutNeedsUpdate
-from modules.workqueue import WorkQueue
+from modules.queueengine import QueueEngine
class StepSequenceErrorHandler():
@@ -66,11 +66,11 @@ class StepSequence(object):
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.")
- WorkQueue.exit_after_handled_error(e)
+ 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)
- WorkQueue.exit_after_handled_error(e)
+ QueueEngine.exit_after_handled_error(e)
diff --git a/WebKitTools/Scripts/modules/workqueue.py b/WebKitTools/Scripts/modules/workqueue.py
deleted file mode 100644
index 314644d..0000000
--- a/WebKitTools/Scripts/modules/workqueue.py
+++ /dev/null
@@ -1,147 +0,0 @@
-#!/usr/bin/env python
-# Copyright (c) 2009, Google Inc. All rights reserved.
-# Copyright (c) 2009 Apple 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 time
-import traceback
-
-from datetime import datetime, timedelta
-
-from modules.executive import ScriptError
-from modules.logging import log, OutputTee
-from modules.statusbot import StatusBot
-
-class WorkQueueDelegate:
- def queue_name(self):
- raise NotImplementedError, "subclasses must implement"
-
- def queue_log_path(self):
- raise NotImplementedError, "subclasses must implement"
-
- def work_item_log_path(self, work_item):
- raise NotImplementedError, "subclasses must implement"
-
- 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"
-
- def should_proceed_with_work_item(self, work_item):
- # returns (safe_to_proceed, waiting_message, patch)
- raise NotImplementedError, "subclasses must implement"
-
- def process_work_item(self, work_item):
- raise NotImplementedError, "subclasses must implement"
-
- def handle_unexpected_error(self, work_item, message):
- raise NotImplementedError, "subclasses must implement"
-
-
-class WorkQueue:
- def __init__(self, name, delegate):
- self._name = name
- self._delegate = delegate
- self._output_tee = OutputTee()
-
- 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()
-
- self._delegate.begin_work_queue()
- while (self._delegate.should_continue_work_queue()):
- try:
- self._ensure_work_log_closed()
- work_item = self._delegate.next_work_item()
- if not work_item:
- self._sleep("No work item.")
- continue
- if not self._delegate.should_proceed_with_work_item(work_item):
- self._sleep("Not proceeding with work item.")
- continue
-
- # FIXME: Work logs should not depend on bug_id specificaly.
- # This looks fixed, no?
- self._open_work_log(work_item)
- try:
- self._delegate.process_work_item(work_item)
- except ScriptError, e:
- # 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)
- except KeyboardInterrupt, e:
- log("\nUser terminated queue.")
- return 1
- except Exception, e:
- traceback.print_exc()
- # Don't try tell the status bot, in case telling it causes an exception.
- self._sleep("Exception while preparing queue: %s." % e)
- # Never reached.
- self._ensure_work_log_closed()
-
- def _begin_logging(self):
- self._queue_log = self._output_tee.add_log(self._delegate.queue_log_path())
- self._work_log = None
-
- 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.
- if self._work_log:
- self._output_tee.remove_log(self._work_log)
- self._work_log = None
-
- @classmethod
- def _sleep_message(cls, message):
- wake_time = datetime.now() + timedelta(seconds=cls.seconds_to_sleep)
- return "%s Sleeping until %s (%s)." % (message, wake_time.strftime(cls.log_date_format), cls.sleep_duration_text)
-
- @classmethod
- def _sleep(cls, message):
- log(cls._sleep_message(message))
- time.sleep(cls.seconds_to_sleep)
diff --git a/WebKitTools/Scripts/modules/workqueue_unittest.py b/WebKitTools/Scripts/modules/workqueue_unittest.py
deleted file mode 100644
index edb6fd9..0000000
--- a/WebKitTools/Scripts/modules/workqueue_unittest.py
+++ /dev/null
@@ -1,170 +0,0 @@
-#!/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.executive import ScriptError
-from modules.workqueue import WorkQueue, WorkQueueDelegate
-
-class LoggingDelegate(WorkQueueDelegate):
- def __init__(self, test):
- self._test = test
- self._callbacks = []
- self._run_before = False
-
- expected_callbacks = [
- 'queue_log_path',
- 'begin_work_queue',
- 'should_continue_work_queue',
- 'next_work_item',
- 'should_proceed_with_work_item',
- 'work_item_log_path',
- 'process_work_item',
- 'should_continue_work_queue'
- ]
-
- def record(self, method_name):
- self._callbacks.append(method_name)
-
- def queue_log_path(self):
- self.record("queue_log_path")
- return os.path.join(self._test.temp_dir, "queue_log_path")
-
- 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")
-
- def should_continue_work_queue(self):
- 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.record("next_work_item")
- return "work_item"
-
- 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 (True, "waiting_message", fake_patch)
-
- def process_work_item(self, work_item):
- self.record("process_work_item")
- self._test.assertEquals(work_item, "work_item")
-
- def handle_unexpected_error(self, work_item, message):
- 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 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")
- return False
-
-
-class FastWorkQueue(WorkQueue):
- def __init__(self, delegate):
- WorkQueue.__init__(self, "fast-queue", delegate)
-
- # No sleep for the wicked.
- seconds_to_sleep = 0
-
- def _sleep(self, message):
- pass
-
-
-class WorkQueueTest(unittest.TestCase):
- def test_trivial(self):
- delegate = LoggingDelegate(self)
- work_queue = WorkQueue("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")))
-
- def test_unexpected_error(self):
- delegate = ThrowErrorDelegate(self, 3)
- work_queue = WorkQueue("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)
-
- def test_handled_error(self):
- delegate = ThrowErrorDelegate(self, WorkQueue.handled_error_code)
- work_queue = WorkQueue("handled-error-queue", delegate)
- work_queue.run()
- self.assertEquals(delegate._callbacks, LoggingDelegate.expected_callbacks)
-
- def test_not_safe_to_proceed(self):
- delegate = NotSafeToProceedDelegate(self)
- work_queue = FastWorkQueue(delegate)
- work_queue.run()
- expected_callbacks = LoggingDelegate.expected_callbacks[:]
- next_work_item_index = expected_callbacks.index('next_work_item')
- # We slice out the common part of the expected callbacks.
- # We add 2 here to include should_proceed_with_work_item, which is
- # a pain to search for directly because it occurs twice.
- expected_callbacks = expected_callbacks[:next_work_item_index + 2]
- expected_callbacks.append('should_continue_work_queue')
- self.assertEquals(delegate._callbacks, expected_callbacks)
-
- def setUp(self):
- self.temp_dir = tempfile.mkdtemp(suffix="work_queue_test_logs")
-
- def tearDown(self):
- shutil.rmtree(self.temp_dir)
-
-
-if __name__ == '__main__':
- unittest.main()
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list