Commit 7e9dacdd authored by eric@webkit.org's avatar eric@webkit.org

2010-01-27 Eric Seidel <eric@webkit.org>

        Reviewed by Darin Adler.

        webkit-patch needs an open-bugs command
        https://bugs.webkit.org/show_bug.cgi?id=30793

        * Scripts/test-webkitpy: import OpenBugsTest
        * Scripts/webkit-patch: import OpenBugs
        * Scripts/webkitpy/commands/download_unittest.py: don't import unittest
        * Scripts/webkitpy/commands/early_warning_system_unittest.py: ditto
        * Scripts/webkitpy/commands/queries_unittest.py: ditto
        * Scripts/webkitpy/commands/queues_unittest.py: ditto
        * Scripts/webkitpy/commands/upload_unittest.py: ditto
        * Scripts/webkitpy/mock_bugzillatool.py: log when user.open_url is called.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53925 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b79e21d1
2010-01-27 Eric Seidel <eric@webkit.org>
Reviewed by Darin Adler.
webkit-patch needs an open-bugs command
https://bugs.webkit.org/show_bug.cgi?id=30793
* Scripts/test-webkitpy: import OpenBugsTest
* Scripts/webkit-patch: import OpenBugs
* Scripts/webkitpy/commands/download_unittest.py: don't import unittest
* Scripts/webkitpy/commands/early_warning_system_unittest.py: ditto
* Scripts/webkitpy/commands/queries_unittest.py: ditto
* Scripts/webkitpy/commands/queues_unittest.py: ditto
* Scripts/webkitpy/commands/upload_unittest.py: ditto
* Scripts/webkitpy/mock_bugzillatool.py: log when user.open_url is called.
2010-01-27 Kenneth Rohde Christiansen <kenneth@webkit.org>
Rubberstamped by Simon Hausmann
......
......@@ -35,6 +35,7 @@ from webkitpy.buildbot_unittest import *
from webkitpy.changelogs_unittest import *
from webkitpy.commands.download_unittest import *
from webkitpy.commands.early_warning_system_unittest import *
from webkitpy.commands.openbugs_unittest import OpenBugsTest
from webkitpy.commands.upload_unittest import *
from webkitpy.commands.queries_unittest import *
from webkitpy.commands.queues_unittest import *
......
......@@ -36,6 +36,7 @@ from webkitpy.bugzilla import Bugzilla
from webkitpy.buildbot import BuildBot
from webkitpy.commands.download import *
from webkitpy.commands.early_warning_system import *
from webkitpy.commands.openbugs import OpenBugs
from webkitpy.commands.queries import *
from webkitpy.commands.queues import *
from webkitpy.commands.upload import *
......
......@@ -26,8 +26,6 @@
# (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.commands.commandtest import CommandsTest
from webkitpy.commands.download import *
from webkitpy.mock import Mock
......
......@@ -27,7 +27,6 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import os
import unittest
from webkitpy.commands.early_warning_system import *
from webkitpy.commands.queuestest import QueuesTest
......
# Copyright (c) 2010 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 re
import sys
from webkitpy.multicommandtool import AbstractDeclarativeCommand
from webkitpy.webkit_logging import log
class OpenBugs(AbstractDeclarativeCommand):
name = "open-bugs"
help_text = "Finds all bug numbers passed in arguments (or stdin if no args provided) and opens them in a web browser"
bug_number_regexp = re.compile(r"\b\d{4,6}\b")
def _open_bugs(self, bug_ids):
for bug_id in bug_ids:
bug_url = self.tool.bugs.bug_url_for_bug_id(bug_id)
self.tool.user.open_url(bug_url)
# _find_bugs_in_string mostly exists for easy unit testing.
def _find_bugs_in_string(self, string):
return self.bug_number_regexp.findall(string)
def _find_bugs_in_iterable(self, iterable):
return sum([self._find_bugs_in_string(string) for string in iterable], [])
def execute(self, options, args, tool):
if args:
bug_ids = self._find_bugs_in_iterable(args)
else:
# This won't open bugs until stdin is closed but could be made to easily. That would just make unit testing slightly harder.
bug_ids = self._find_bugs_in_iterable(sys.stdin)
log("%s bugs found in input." % len(bug_ids))
self._open_bugs(bug_ids)
# 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.
from webkitpy.commands.commandtest import CommandsTest
from webkitpy.commands.openbugs import OpenBugs
class OpenBugsTest(CommandsTest):
find_bugs_in_string_expectations = [
["123", []],
["1234", ["1234"]],
["12345", ["12345"]],
["123456", ["123456"]],
["1234567", []],
[" 123456 234567", ["123456", "234567"]],
]
def test_find_bugs_in_string(self):
openbugs = OpenBugs()
for expectation in self.find_bugs_in_string_expectations:
self.assertEquals(openbugs._find_bugs_in_string(expectation[0]), expectation[1])
def test_args_parsing(self):
expected_stderr = "2 bugs found in input.\nMOCK: user.open_url: http://example.com/12345\nMOCK: user.open_url: http://example.com/23456\n"
self.assert_execute_outputs(OpenBugs(), ["12345\n23456"], expected_stderr=expected_stderr)
......@@ -26,8 +26,6 @@
# (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.bugzilla import Bugzilla
from webkitpy.commands.commandtest import CommandsTest
from webkitpy.commands.queries import *
......
......@@ -27,7 +27,6 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import os
import unittest
from webkitpy.commands.commandtest import CommandsTest
from webkitpy.commands.queues import *
......
......@@ -26,8 +26,6 @@
# (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.commands.commandtest import CommandsTest
from webkitpy.commands.upload import *
from webkitpy.mock import Mock
......@@ -67,7 +65,7 @@ class UploadCommandsTest(CommandsTest):
self.assert_execute_outputs(Prepare(), [])
def test_upload(self):
expected_stderr = "Running check-webkit-style\nObsoleting 2 old patches on bug 42\n"
expected_stderr = "Running check-webkit-style\nObsoleting 2 old patches on bug 42\nMOCK: user.open_url: http://example.com/42\n"
self.assert_execute_outputs(Upload(), [42], expected_stderr=expected_stderr)
def test_mark_bug_fixed(self):
......@@ -75,7 +73,11 @@ class UploadCommandsTest(CommandsTest):
tool._scm.last_svn_commit_log = lambda: "r9876 |"
options = Mock()
options.bug_id = 42
expected_stderr = "Bug: <http://example.com/42> Bug with two r+'d and cq+'d patches, one of which has an invalid commit-queue setter.\nRevision: 9876\nAdding comment to Bug 42.\n"
expected_stderr = """Bug: <http://example.com/42> Bug with two r+'d and cq+'d patches, one of which has an invalid commit-queue setter.
Revision: 9876
MOCK: user.open_url: http://example.com/42
Adding comment to Bug 42.
"""
self.assert_execute_outputs(MarkBugFixed(), [], expected_stderr=expected_stderr, tool=tool, options=options)
def test_edit_changelog(self):
......
......@@ -28,10 +28,11 @@
import os
from webkitpy.bugzilla import Bug, Attachment
from webkitpy.committers import CommitterList, Reviewer
from webkitpy.mock import Mock
from webkitpy.scm import CommitMessage
from webkitpy.committers import CommitterList, Reviewer
from webkitpy.bugzilla import Bug, Attachment
from webkitpy.webkit_logging import log
def _id_to_object_dictionary(*objects):
......@@ -333,6 +334,7 @@ class MockUser(object):
return True
def open_url(self, url):
log("MOCK: user.open_url: %s" % url)
pass
......
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