Changeset 70006 in webkit
- Timestamp:
- Oct 18, 2010 4:08:33 PM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r69986 r70006 1 2010-10-18 Eric Seidel <eric@webkit.org> 2 3 Reviewed by Adam Barth. 4 5 Add Queue class and add minimal unittesting of QueueStatusServer code 6 https://bugs.webkit.org/show_bug.cgi?id=47847 7 8 * QueueStatusServer/handlers/dashboard.py: 9 * QueueStatusServer/handlers/queuestatus.py: 10 * QueueStatusServer/handlers/recentstatus.py: 11 * QueueStatusServer/handlers/statusbubble.py: 12 * QueueStatusServer/handlers/updateworkitems.py: 13 * QueueStatusServer/model/attachment.py: 14 * QueueStatusServer/model/queues.py: 15 * QueueStatusServer/model/queues_unittest.py: Added. 16 * QueueStatusServer/model/svnrevision.py: 17 * Scripts/test-webkitpy: 18 * Scripts/webkitpy/test/main.py: 19 1 20 2010-10-18 Anders Carlsson <andersca@apple.com> 2 21 -
trunk/WebKitTools/QueueStatusServer/handlers/dashboard.py
r66518 r70006 33 33 34 34 from model.attachment import Attachment 35 from model.queues import queues35 from model.queues import Queue 36 36 37 37 38 38 class Dashboard(webapp.RequestHandler): 39 # We may want to sort these? 40 _ordered_queues = Queue.all() 41 _header_names = [queue.short_name() for queue in _ordered_queues] 39 42 40 # FIXME: This list probably belongs as part of a Queue object in queues.py 41 # Arrays are bubble_name, queue_name 42 # FIXME: Can this be unified with StatusBubble._queues_to_display? 43 _queues_to_display = [ 44 ["Style", "style-queue"], 45 ["Cr-Linux", "chromium-ews"], 46 ["Qt", "qt-ews"], 47 ["Gtk", "gtk-ews"], 48 ["Mac", "mac-ews"], 49 ["Win", "win-ews"], 50 ["Commit", "commit-queue"], 51 ] 52 # Split the zipped list into component parts 53 _header_names, _ordered_queue_names = zip(*_queues_to_display) 54 55 # This asserts that all of the queues listed above are valid queue names. 56 assert(reduce(operator.and_, map(lambda name: name in queues, _ordered_queue_names))) 57 58 def _build_bubble(self, attachment, queue_name): 59 queue_status = attachment.status_for_queue(queue_name) 43 def _build_bubble(self, attachment, queue): 44 queue_status = attachment.status_for_queue(queue.name()) 60 45 bubble = { 61 46 "status_class": attachment.state_from_queue_status(queue_status) if queue_status else "none", … … 68 53 "bug_id": attachment.bug_id(), 69 54 "attachment_id": attachment.id, 70 "bubbles": [self._build_bubble(attachment, queue _name) for queue_name in self._ordered_queue_names],55 "bubbles": [self._build_bubble(attachment, queue) for queue in self._ordered_queues], 71 56 } 72 57 return row -
trunk/WebKitTools/QueueStatusServer/handlers/queuestatus.py
r68453 r70006 30 30 from google.appengine.ext.webapp import template 31 31 32 from model.queues import queues, display_name_for_queue32 from model.queues import Queue 33 33 from model.workitems import WorkItems 34 34 from model.activeworkitems import ActiveWorkItems … … 51 51 52 52 def get(self, queue_name): 53 queued_items = WorkItems.all().filter("queue_name =", queue_name).get() 54 active_items = ActiveWorkItems.all().filter("queue_name =", queue_name).get() 55 statuses = queuestatus.QueueStatus.all().filter("queue_name =", queue_name).order("-date").fetch(15) 53 queue_name = queue_name.lowercase() 54 queue = Queue.queue_with_name(queue_name) 55 if not queue: 56 self.error(404) 57 58 queued_items = WorkItems.all().filter("queue_name =", queue.name()).get() 59 active_items = ActiveWorkItems.all().filter("queue_name =", queue.name()).get() 60 statuses = queuestatus.QueueStatus.all().filter("queue_name =", queue.name()).order("-date").fetch(15) 56 61 57 62 status_groups = [] … … 70 75 71 76 template_values = { 72 "display_queue_name": display_name_for_queue(queue_name),77 "display_queue_name": queue.display_name(), 73 78 "work_item_rows": self._rows_for_work_items(queued_items, active_items), 74 79 "status_groups": status_groups, -
trunk/WebKitTools/QueueStatusServer/handlers/recentstatus.py
r64787 r70006 32 32 from google.appengine.ext.webapp import template 33 33 34 from model.queues import queues, display_name_for_queue34 from model.queues import Queue 35 35 from model.queuestatus import QueueStatus 36 36 from model.workitems import WorkItems … … 39 39 class QueueBubble(object): 40 40 """View support class for recentstatus.html""" 41 def __init__(self, queue _name):42 self._queue _name = queue_name43 self._work_items = WorkItems.all().filter("queue_name =", queue _name).get()44 self._last_status = QueueStatus.all().filter("queue_name =", queue _name).order("-date").get()41 def __init__(self, queue): 42 self._queue = queue 43 self._work_items = WorkItems.all().filter("queue_name =", queue.name()).get() 44 self._last_status = QueueStatus.all().filter("queue_name =", queue.name()).order("-date").get() 45 45 46 # FIXME: name and display_name should be replaced by a .queue() accessor. 46 47 def name(self): 47 return self._queue _name48 return self._queue.name() 48 49 49 50 def display_name(self): 50 return display_name_for_queue(self._queue_name)51 return self._queue.display_name() 51 52 52 53 def _last_status_date(self): … … 89 90 def get(self): 90 91 template_values = { 91 "queues": [QueueBubble(queue _name) for queue_name in queues],92 "queues": [QueueBubble(queue) for queue in Queue.all()], 92 93 } 93 94 self.response.out.write(template.render("templates/recentstatus.html", template_values)) -
trunk/WebKitTools/QueueStatusServer/handlers/statusbubble.py
r69471 r70006 34 34 from model.attachment import Attachment 35 35 from model.workitems import WorkItems 36 from model.queues import queues, name_with_underscores36 from model.queues import Queue 37 37 38 38 39 39 class StatusBubble(webapp.RequestHandler): 40 # FIXME: This list probably belongs as part of a Queue object in queues.py 41 # Arrays are bubble_name, queue_name 42 _queues_to_display = [ 43 ["style", "style-queue"], 44 ["cr-linux", "chromium-ews"], 45 ["gtk", "gtk-ews"], 46 ["qt", "qt-ews"], 47 ["mac", "mac-ews"], 48 ["win", "win-ews"], 49 ["efl", "efl-ews"], 50 ] 40 _queues_to_display = [queue for queue in Queue.all() if queue.is_ews()] 51 41 52 # This asserts that all of the queues listed above are valid queue names. 53 assert(reduce(operator.and_, map(lambda name_pair: name_pair[1] in queues, _queues_to_display))) 54 55 def _build_bubble(self, queue_name_pair, attachment): 56 bubble_name = queue_name_pair[0] 57 queue_name = queue_name_pair[1] 58 59 queue_status = attachment.status_for_queue(queue_name) 42 def _build_bubble(self, queue, attachment): 43 queue_status = attachment.status_for_queue(queue.name()) 60 44 bubble = { 61 "name": bubble_name,45 "name": queue.short_name().lowercase(), 62 46 "attachment_id": attachment.id, 63 "queue_position": attachment.position_in_queue(queue _name),47 "queue_position": attachment.position_in_queue(queue.name()), 64 48 "state": attachment.state_from_queue_status(queue_status) if queue_status else "none", 65 49 "status": queue_status, … … 69 53 def get(self, attachment_id): 70 54 attachment = Attachment(int(attachment_id)) 71 bubbles = [self._build_bubble( name_pair, attachment) for name_pairin self._queues_to_display]55 bubbles = [self._build_bubble(queue, attachment) for queue in self._queues_to_display] 72 56 template_values = { 73 57 "bubbles": bubbles, -
trunk/WebKitTools/QueueStatusServer/handlers/updateworkitems.py
r59986 r70006 31 31 32 32 from handlers.updatebase import UpdateBase 33 from model.queues import queues33 from model.queues import Queue 34 34 from model.workitems import WorkItems 35 35 … … 42 42 43 43 def _work_items_for_queue(self, queue_name): 44 if queue_name not in queues: 45 self.response.out.write("\"%s\" is not in queues %s" % (queue_name, queues)) 44 queue = Queue.queue_for_name(queue_name) 45 if queue: 46 self.response.out.write("\"%s\" is not in queues %s" % (queue_name, Queue.all())) 46 47 return None 47 48 work_items = WorkItems.all().filter("queue_name =", queue_name).get() -
trunk/WebKitTools/QueueStatusServer/model/attachment.py
r59534 r70006 31 31 from google.appengine.api import memcache 32 32 33 from model.queues import queues, name_with_underscores33 from model.queues import Queue 34 34 from model.queuestatus import QueueStatus 35 35 from model.workitems import WorkItems … … 92 92 93 93 def status_for_queue(self, queue_name): 94 underscore_queue_name = name_with_underscores(queue_name)94 underscore_queue_name = Queue(queue_name).name_with_underscores() 95 95 # summary() is a horrible API and should be killed. 96 96 queue_summary = self.summary().get(underscore_queue_name) … … 135 135 status = QueueStatus.all().filter('queue_name =', queue).filter('active_patch_id =', self.id).order('-date').get() 136 136 if status: 137 summary[name_with_underscores(queue)] = { 137 queue_name = Queue(queue_name).name_with_underscores() 138 # summary() is a horrible API and should be killed. 139 summary[queue_name] = { 138 140 "state": self.state_from_queue_status(status), 139 141 "status": status, -
trunk/WebKitTools/QueueStatusServer/model/queues.py
r66564 r70006 27 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 29 29 30 import re 30 31 31 32 32 queues = [ 33 "commit-queue", 34 "style-queue", 35 "chromium-ews", 36 "qt-ews", 37 "gtk-ews", 38 "mac-ews", 39 "win-ews", 40 "efl-ews", 41 ] 33 class Queue(object): 42 34 35 # Eventually the list of queues may be stored in the data store. 36 _all_queue_names = [ 37 "commit-queue", 38 "style-queue", 39 "chromium-ews", 40 "qt-ews", 41 "gtk-ews", 42 "mac-ews", 43 "win-ews", 44 "efl-ews", 45 ] 43 46 44 # FIXME: We need some sort of Queue object. 45 def _title_case(string): 46 words = string.split(" ") 47 words = map(lambda word: word.capitalize(), words) 48 return " ".join(words) 47 def __init__(self, name): 48 assert(name in self._all_queue_names) 49 self._name = name 49 50 51 @classmethod 52 def queue_with_name(cls, queue_name): 53 if queue_name not in cls._all_queue_names: 54 return None 55 return Queue(queue_name) 50 56 51 def display_name_for_queue(queue_name): 52 # HACK: chromium-ews is incorrectly named.53 display_name = queue_name.replace("chromium-ews", "cr-linux-ews")57 @classmethod 58 def all(cls): 59 return [Queue(name) for name in cls._all_queue_names] 54 60 55 display_name = display_name.replace("-", " ") 56 display_name = display_name.replace("cr", "chromium") 57 display_name = _title_case(display_name) 58 display_name = display_name.replace("Ews", "EWS") 59 return display_name 61 def name(self): 62 return self._name 60 63 64 def _caplitalize_after_dash(self, string): 65 return "-".join([word[0].upper() + word[1:] for word in string.split("-")]) 61 66 62 def name_with_underscores(dashed_name): 63 regexp = re.compile("-") 64 return regexp.sub("_", dashed_name) 67 # For use in status bubbles or table headers 68 def short_name(self): 69 # HACK: chromium-ews is incorrectly named. 70 short_name = self._name.replace("chromium-ews", "Cr-Linux-ews") 71 short_name = short_name.replace("-ews", "") 72 short_name = short_name.replace("-queue", "") 73 return self._caplitalize_after_dash(short_name.capitalize()) 74 75 def display_name(self): 76 # HACK: chromium-ews is incorrectly named. 77 display_name = self._name.replace("chromium-ews", "cr-linux-ews") 78 79 display_name = display_name.replace("-", " ") 80 display_name = display_name.replace("cr", "chromium") 81 display_name = display_name.title() 82 display_name = display_name.replace("Ews", "EWS") 83 return display_name 84 85 _dash_regexp = re.compile("-") 86 87 def name_with_underscores(self): 88 return self._dash_regexp.sub("_", self._name) 89 90 def is_ews(self): 91 return self._name.endswith("-ews") -
trunk/WebKitTools/QueueStatusServer/model/svnrevision.py
r56210 r70006 29 29 from google.appengine.ext import db 30 30 31 31 32 class SVNRevision(db.Model): 32 33 number = db.IntegerProperty() -
trunk/WebKitTools/Scripts/test-webkitpy
r68080 r70006 228 228 229 229 230 def _path_from_webkit_root(*components): 231 webkit_root = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) 232 return os.path.join(webkit_root, *components) 233 234 235 def _test_import(module_path): 236 try: 237 sys.path.append(os.path.dirname(module_path)) 238 module_name = os.path.basename(module_path) 239 __import__(module_name) 240 return True 241 except Exception, e: 242 message = "Skipping tests in %s due to failure (%s)." % (module_path, e) 243 if module_name.endswith("QueueStatusServer"): 244 message += " This module is optional. The failure is likely due to a missing Google AppEngine install. (http://code.google.com/appengine/downloads.html)" 245 _log.warn(message) 246 return False 247 230 248 if __name__ == "__main__": 231 232 external_package_paths = [os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'WebKit2', 'Scripts', 'webkit2')] 249 # FIXME: We should probably test each package separately to avoid naming conflicts. 250 external_package_paths = [ 251 _path_from_webkit_root('WebKit2', 'Scripts', 'webkit2'), 252 _path_from_webkit_root('WebKitTools', 'QueueStatusServer'), 253 ] 233 254 init(sys.argv[1:], external_package_paths) 234 255 … … 241 262 from webkitpy.test.main import Tester 242 263 264 external_package_paths = filter(_test_import, external_package_paths) 265 243 266 Tester().run_tests(sys.argv, external_package_paths) -
trunk/WebKitTools/Scripts/webkitpy/test/main.py
r68084 r70006 51 51 return unittest_paths 52 52 53 def _modules_from_paths(self, webkitpy_dir, paths):53 def _modules_from_paths(self, package_root, paths): 54 54 """Return a list of fully-qualified module names given paths.""" 55 webkitpy_dir = os.path.abspath(webkitpy_dir)56 webkitpy_name = os.path.split(webkitpy_dir)[1] # Equals "webkitpy".55 package_path = os.path.abspath(package_root) 56 root_package_name = os.path.split(package_path)[1] # Equals "webkitpy". 57 57 58 prefix_length = len( webkitpy_dir)58 prefix_length = len(package_path) 59 59 60 60 modules = [] … … 73 73 parts.insert(0, tail) 74 74 # We now have, for example: common.config.ports_unittest 75 parts.insert(0, webkitpy_name) # Put "webkitpy" at the beginning. 75 # FIXME: This is all a hack around the fact that we always prefix webkitpy includes with "webkitpy." 76 parts.insert(0, root_package_name) # Put "webkitpy" at the beginning. 76 77 module = ".".join(parts) 77 78 modules.append(module) … … 92 93 external_package_paths = [] 93 94 else: 95 # FIXME: We should consider moving webkitpy off of using "webkitpy." to prefix 96 # all includes. If we did that, then this would use path instead of dirname(path). 97 # QueueStatusServer.__init__ has a sys.path import hack due to this code. 94 98 sys.path.extend(set(os.path.dirname(path) for path in external_package_paths)) 95 99 … … 102 106 # Otherwise, auto-detect all unit tests. 103 107 108 # FIXME: This should be combined with the external_package_paths code above. 104 109 webkitpy_dir = os.path.dirname(webkitpy.__file__) 105 110
Note: See TracChangeset
for help on using the changeset viewer.