Diff
Modified: trunk/Tools/ChangeLog (108375 => 108376)
--- trunk/Tools/ChangeLog 2012-02-21 19:25:22 UTC (rev 108375)
+++ trunk/Tools/ChangeLog 2012-02-21 19:28:03 UTC (rev 108376)
@@ -1,3 +1,34 @@
+2012-02-21 Dirk Pranke <[email protected]>
+
+ webkitpy: prepare to delete message_broker.py
+ https://bugs.webkit.org/show_bug.cgi?id=78997
+
+ Reviewed by Eric Seidel.
+
+ This is part 1 of 3 changes to fix bug 78187. This change
+ prepares the code for merging message_broker.py into
+ manager_worker_broker.py; the tests in message_broker_unittest
+ are merged into manager_worker_broker_unittest, the symbols
+ needed by the tests are exported from manager_worker_broker.py,
+ and manager_worker_broker itself is updated to refer to the
+ symbols directly (without the module prefix).
+
+ * Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py:
+ (get):
+ (AbstractWorker):
+ (AbstractWorker.__init__):
+ (_ManagerConnection):
+ (_ManagerConnection.__init__):
+ (_WorkerConnection):
+ (_WorkerConnection.__init__):
+ * Scripts/webkitpy/layout_tests/controllers/manager_worker_broker_unittest.py:
+ (InterfaceTest.test_brokerclient_is_abstract):
+ (InterfaceTest.test_brokerclient_is_abstract.methods):
+ (MessageTest):
+ (MessageTest.test__no_body):
+ (MessageTest.test__body):
+ * Scripts/webkitpy/layout_tests/controllers/message_broker_unittest.py: Removed.
+
2012-02-21 Sam Weinig <[email protected]>
Attempt to fix the Snow Leopard build.
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py (108375 => 108376)
--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py 2012-02-21 19:25:22 UTC (rev 108375)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py 2012-02-21 19:28:03 UTC (rev 108376)
@@ -38,7 +38,7 @@
Manager --> _InlineManager ---> _InlineWorker <-> Worker
^ \ / ^
| v v |
- \-------------------- MessageBroker -------------/
+ \----------------------- Broker ----------------/
"""
import logging
@@ -47,11 +47,12 @@
import Queue
import sys
-from webkitpy.layout_tests.controllers import message_broker
+from webkitpy.layout_tests.controllers.message_broker import Broker, BrokerClient, BrokerConnection, _Message
_log = logging.getLogger(__name__)
+
#
# Topic names for Manager <-> Worker messaging
#
@@ -64,7 +65,7 @@
Args:
worker_model - concurrency model to use (inline/processes)
- client - message_broker.BrokerClient implementation to dispatch
+ client - BrokerClient implementation to dispatch
replies to.
worker_class - type of workers to create. This class should override
the methods in AbstractWorker.
@@ -80,11 +81,11 @@
else:
raise ValueError("unsupported value for --worker-model: %s" % worker_model)
- broker = message_broker.Broker(queue_class)
+ broker = Broker(queue_class)
return manager_class(broker, client, worker_class)
-class AbstractWorker(message_broker.BrokerClient):
+class AbstractWorker(BrokerClient):
def __init__(self, worker_connection, worker_arguments=None):
"""The constructor should be used to do any simple initialization
necessary, but should not do anything that creates data structures
@@ -96,7 +97,7 @@
worker_connection - handle to the BrokerConnection object creating
the worker and that can be used for messaging.
worker_arguments - (optional, Picklable) object passed to the worker from the manager"""
- message_broker.BrokerClient.__init__(self)
+ BrokerClient.__init__(self)
self._worker_connection = worker_connection
self._name = 'worker'
self._done = False
@@ -138,7 +139,7 @@
self._canceled = True
-class _ManagerConnection(message_broker.BrokerConnection):
+class _ManagerConnection(BrokerConnection):
def __init__(self, broker, client, worker_class):
"""Base initialization for all Manager objects.
@@ -147,8 +148,7 @@
client: callback object (the caller)
worker_class: class object to use to create workers.
"""
- message_broker.BrokerConnection.__init__(self, broker, client,
- MANAGER_TOPIC, ANY_WORKER_TOPIC)
+ BrokerConnection.__init__(self, broker, client, MANAGER_TOPIC, ANY_WORKER_TOPIC)
self._worker_class = worker_class
def start_worker(self, worker_arguments=None):
@@ -191,11 +191,10 @@
return worker_connection
-class _WorkerConnection(message_broker.BrokerConnection):
+class _WorkerConnection(BrokerConnection):
def __init__(self, broker, worker_class, worker_arguments=None):
self._client = worker_class(self, worker_arguments)
- message_broker.BrokerConnection.__init__(self, broker, self._client,
- ANY_WORKER_TOPIC, MANAGER_TOPIC)
+ BrokerConnection.__init__(self, broker, self._client, ANY_WORKER_TOPIC, MANAGER_TOPIC)
def name(self):
return self._client.name()
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker_unittest.py (108375 => 108376)
--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker_unittest.py 2012-02-21 19:25:22 UTC (rev 108375)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker_unittest.py 2012-02-21 19:28:03 UTC (rev 108376)
@@ -33,7 +33,6 @@
from webkitpy.common.system import outputcapture
from webkitpy.layout_tests.controllers import manager_worker_broker
-from webkitpy.layout_tests.controllers import message_broker
# In order to reliably control when child workers are starting and stopping,
@@ -204,6 +203,13 @@
# FIXME: There must be a better way to do this and also verify
# that classes do implement every abstract method in an interface.
+ def test_brokerclient_is_abstract(self):
+ # Test that all the base class methods are abstract and have the
+ # signature we expect.
+ obj = manager_worker_broker.BrokerClient()
+ self.assertRaises(NotImplementedError, obj.is_done)
+ self.assertRaises(NotImplementedError, obj.name)
+
def test_managerconnection_is_abstract(self):
# Test that all the base class methods are abstract and have the
# signature we expect.
@@ -221,5 +227,28 @@
self.assertRaises(NotImplementedError, obj.join, None)
+class MessageTest(unittest.TestCase):
+ def test__no_body(self):
+ msg = manager_worker_broker._Message('src', 'topic_name', 'message_name', None)
+ self.assertTrue(repr(msg))
+ s = msg.dumps()
+ new_msg = manager_worker_broker._Message.loads(s)
+ self.assertEqual(new_msg.name, 'message_name')
+ self.assertEqual(new_msg.args, None)
+ self.assertEqual(new_msg.topic_name, 'topic_name')
+ self.assertEqual(new_msg.src, 'src')
+
+ def test__body(self):
+ msg = manager_worker_broker._Message('src', 'topic_name', 'message_name', ('body', 0))
+ self.assertTrue(repr(msg))
+ s = msg.dumps()
+ new_msg = manager_worker_broker._Message.loads(s)
+ self.assertEqual(new_msg.name, 'message_name')
+ self.assertEqual(new_msg.args, ('body', 0))
+ self.assertEqual(new_msg.topic_name, 'topic_name')
+ self.assertEqual(new_msg.src, 'src')
+
+
+
if __name__ == '__main__':
unittest.main()
Deleted: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/message_broker_unittest.py (108375 => 108376)
--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/message_broker_unittest.py 2012-02-21 19:25:22 UTC (rev 108375)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/message_broker_unittest.py 2012-02-21 19:28:03 UTC (rev 108376)
@@ -1,76 +0,0 @@
-# Copyright (C) 2011 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 unittest
-
-from webkitpy.layout_tests.controllers import message_broker
-
-# This file exists to test routines that aren't necessarily covered elsewhere;
-# most of the testing of message_broker will be covered under the tests in
-# the manager_worker_broker module.
-
-
-class MessageTest(unittest.TestCase):
- def test__no_body(self):
- msg = message_broker._Message('src', 'topic_name', 'message_name', None)
- self.assertTrue(repr(msg))
- s = msg.dumps()
- new_msg = message_broker._Message.loads(s)
- self.assertEqual(new_msg.name, 'message_name')
- self.assertEqual(new_msg.args, None)
- self.assertEqual(new_msg.topic_name, 'topic_name')
- self.assertEqual(new_msg.src, 'src')
-
- def test__body(self):
- msg = message_broker._Message('src', 'topic_name', 'message_name',
- ('body', 0))
- self.assertTrue(repr(msg))
- s = msg.dumps()
- new_msg = message_broker._Message.loads(s)
- self.assertEqual(new_msg.name, 'message_name')
- self.assertEqual(new_msg.args, ('body', 0))
- self.assertEqual(new_msg.topic_name, 'topic_name')
- self.assertEqual(new_msg.src, 'src')
-
-
-class InterfaceTest(unittest.TestCase):
- # These tests mostly exist to pacify coverage.
-
- # FIXME: There must be a better way to do this and also verify
- # that classes do implement every abstract method in an interface.
-
- def test_brokerclient_is_abstract(self):
- # Test that all the base class methods are abstract and have the
- # signature we expect.
- obj = message_broker.BrokerClient()
- self.assertRaises(NotImplementedError, obj.is_done)
- self.assertRaises(NotImplementedError, obj.name)
-
-
-if __name__ == '__main__':
- unittest.main()