Commit bdf38888 authored by eric@webkit.org's avatar eric@webkit.org
Browse files

2009-12-02 Eric Seidel <eric@webkit.org>

        Reviewed by Adam Barth.

        REGRESSION(51595): commit-queue is throwing exceptions
        https://bugs.webkit.org/show_bug.cgi?id=32083

        * Scripts/modules/commands/queues.py:
         - Don't use default value of [] as it ends up getting shared.
         - Make log_progress accept arrays of ints as well as strings.
         - Return an exit code from execute()
        * Scripts/modules/commands/queues_unittest.py: Added.
         - Test to make sure log_progress will accept ints.
         - Test to make sure run_bugzilla_tool will accept ints.
        * Scripts/modules/workqueue.py:
         - Print the stack trace on unexpected exceptions for easier debugging.
        * Scripts/run-webkit-unittests:
         - Add queues_unittest.

        * Scripts/modules/commands/queues.py:
        * Scripts/modules/commands/queues_unittest.py: Copied from WebKitTools/Scripts/modules/commands/commandtest.py.
        * Scripts/modules/mock_bugzillatool.py:
        * Scripts/modules/workqueue.py:
        * Scripts/run-webkit-unittests:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51622 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3ac3ec8d
2009-12-02 Eric Seidel <eric@webkit.org>
Reviewed by Adam Barth.
REGRESSION(51595): commit-queue is throwing exceptions
https://bugs.webkit.org/show_bug.cgi?id=32083
* Scripts/modules/commands/queues.py:
- Don't use default value of [] as it ends up getting shared.
- Make log_progress accept arrays of ints as well as strings.
- Return an exit code from execute()
* Scripts/modules/commands/queues_unittest.py: Added.
- Test to make sure log_progress will accept ints.
- Test to make sure run_bugzilla_tool will accept ints.
* Scripts/modules/workqueue.py:
- Print the stack trace on unexpected exceptions for easier debugging.
* Scripts/run-webkit-unittests:
- Add queues_unittest.
* Scripts/modules/commands/queues.py:
* Scripts/modules/commands/queues_unittest.py: Copied from WebKitTools/Scripts/modules/commands/commandtest.py.
* Scripts/modules/mock_bugzillatool.py:
* Scripts/modules/workqueue.py:
* Scripts/run-webkit-unittests:
2009-12-02 David Levin <levin@chromium.org>
Reviewed by Adam Barth.
......
......@@ -46,12 +46,12 @@ from modules.workqueue import WorkQueue, WorkQueueDelegate
class AbstractQueue(Command, WorkQueueDelegate):
watchers = "webkit-bot-watchers@googlegroups.com"
def __init__(self, options=[]):
options += [
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)
Command.__init__(self, "Run the %s" % self.name, options=options_list)
def _cc_watchers(self, bug_id):
try:
......@@ -92,17 +92,17 @@ class AbstractQueue(Command, WorkQueueDelegate):
raise NotImplementedError, "subclasses must implement"
def run_bugzilla_tool(self, args):
bugzilla_tool_args = [self.tool.path()] + args
bugzilla_tool_args = [self.tool.path()] + map(str, args)
run_and_throw_if_fail(bugzilla_tool_args)
def log_progress(self, patch_ids):
log("%s in %s [%s]" % (pluralize("patch", len(patch_ids)), self.name, ", ".join(patch_ids)))
log("%s in %s [%s]" % (pluralize("patch", len(patch_ids)), self.name, ", ".join(map(str, patch_ids))))
def execute(self, options, args, tool):
self.options = options
self.tool = tool
work_queue = WorkQueue(self.name, self)
work_queue.run()
return work_queue.run()
class CommitQueue(AbstractQueue, LandingSequenceErrorHandler):
......@@ -146,7 +146,7 @@ class CommitQueue(AbstractQueue, LandingSequenceErrorHandler):
class AbstractTryQueue(AbstractQueue, PersistentPatchCollectionDelegate, LandingSequenceErrorHandler):
def __init__(self, options=[]):
def __init__(self, options=None):
AbstractQueue.__init__(self, options)
# PersistentPatchCollectionDelegate methods
......
# 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 unittest
from modules.commands.commandtest import CommandsTest
from modules.commands.queues import *
from modules.mock_bugzillatool import MockBugzillaTool
from modules.outputcapture import OutputCapture
class TestQueue(AbstractQueue):
name = "test-queue"
class AbstractQueueTest(CommandsTest):
def _assert_output(self, function, args, expected_stdout="", expected_stderr=""):
capture = OutputCapture()
capture.capture_output()
function(*args)
(stdout_string, stderr_string) = capture.restore_output()
self.assertEqual(stdout_string, expected_stdout)
self.assertEqual(stderr_string, expected_stderr)
def _assert_log_progress_output(self, patch_ids, progress_output):
self._assert_output(TestQueue().log_progress, [patch_ids], expected_stderr=progress_output)
def test_log_progress(self):
self._assert_log_progress_output([1,2,3], "3 patches in test-queue [1, 2, 3]\n")
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):
queue = TestQueue()
queue.bind_to_tool(MockBugzillaTool())
# MockBugzillaTool.path() is "echo"
self._assert_output(queue.run_bugzilla_tool, [run_args], expected_stdout=tool_output)
def test_run_bugzilla_tool(self):
self._assert_run_bugzilla_tool_output([1], "1\n")
self._assert_run_bugzilla_tool_output(["one", 2], "one 2\n")
......@@ -130,3 +130,6 @@ class MockBugzillaTool():
def scm(self):
return self._scm
def path(self):
return "echo"
......@@ -30,6 +30,7 @@
import os
import time
import traceback
from datetime import datetime, timedelta
......@@ -104,7 +105,11 @@ class WorkQueue:
self._update_status_and_sleep(waiting_message)
continue
self.status_bot.update_status(self._name, waiting_message, patch)
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)
continue
......
......@@ -35,6 +35,7 @@ from modules.changelogs_unittest import *
from modules.commands.download_unittest import *
from modules.commands.upload_unittest import *
from modules.commands.queries_unittest import *
from modules.commands.queues_unittest import *
from modules.committers_unittest import *
from modules.cpp_style_unittest import *
from modules.diff_parser_unittest import *
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment