[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

abarth at webkit.org abarth at webkit.org
Thu Apr 8 00:39:44 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 04ef1fe08f5e7d5e5bc4fef15742b5869f2bb5d5
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 17 07:40:27 2009 +0000

    2009-12-16  Eric Seidel  <eric at webkit.org>
    
            Reviewed by Adam Barth.
    
            post-diff is failing with exception under guess_reviewer_from_bug
            https://bugs.webkit.org/show_bug.cgi?id=32642
    
            Also refactor output capturing code into
            OutputCapture.assert_outputs to share more code between tests.
    
            * Scripts/modules/buildsteps.py:
             - Add the missing include.
             - Give guess_reviewer_from_bug a private underscore.
            * Scripts/modules/buildsteps_unittest.py: Added.
             - Test to make sure _guess_reviewer_from_bug works as expected.
            * Scripts/modules/commands/commandtest.py:
             - Custom code is now obsoleted by OutputCapture.assert_outputs
            * Scripts/modules/commands/queues_unittest.py:
             - ditto
            * Scripts/modules/credentials_unittest.py:
             - ditto
            * Scripts/modules/mock_bugzillatool.py:
             - fetch_reviewed_patches_from_bug can never return None
            * Scripts/modules/multicommandtool_unittest.py:
             - Custom code is now obsoleted by OutputCapture.assert_outputs
            * Scripts/modules/outputcapture.py:
             - Add assert_outputs to share more code between tests.
            * Scripts/run-webkit-unittests:
             - Add buildsteps_unittest.py
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52239 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 8360b35..0ff55cd 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,33 @@
+2009-12-16  Eric Seidel  <eric at webkit.org>
+
+        Reviewed by Adam Barth.
+
+        post-diff is failing with exception under guess_reviewer_from_bug
+        https://bugs.webkit.org/show_bug.cgi?id=32642
+
+        Also refactor output capturing code into
+        OutputCapture.assert_outputs to share more code between tests.
+
+        * Scripts/modules/buildsteps.py:
+         - Add the missing include.
+         - Give guess_reviewer_from_bug a private underscore.
+        * Scripts/modules/buildsteps_unittest.py: Added.
+         - Test to make sure _guess_reviewer_from_bug works as expected.
+        * Scripts/modules/commands/commandtest.py:
+         - Custom code is now obsoleted by OutputCapture.assert_outputs
+        * Scripts/modules/commands/queues_unittest.py:
+         - ditto
+        * Scripts/modules/credentials_unittest.py:
+         - ditto
+        * Scripts/modules/mock_bugzillatool.py:
+         - fetch_reviewed_patches_from_bug can never return None
+        * Scripts/modules/multicommandtool_unittest.py:
+         - Custom code is now obsoleted by OutputCapture.assert_outputs
+        * Scripts/modules/outputcapture.py:
+         - Add assert_outputs to share more code between tests.
+        * Scripts/run-webkit-unittests:
+         - Add buildsteps_unittest.py
+
 2009-12-16  Adam Barth  <abarth at webkit.org>
 
         Unreviewed.  Added a default argument to _update_status so that callers
diff --git a/WebKitTools/Scripts/modules/buildsteps.py b/WebKitTools/Scripts/modules/buildsteps.py
index abff522..fb0e588 100644
--- a/WebKitTools/Scripts/modules/buildsteps.py
+++ b/WebKitTools/Scripts/modules/buildsteps.py
@@ -31,6 +31,7 @@ import os
 from optparse import make_option
 
 from modules.comments import bug_comment_from_commit_text
+from modules.grammar import pluralize
 from modules.logging import log, error
 from modules.webkitport import WebKitPort
 from modules.changelogs import ChangeLog
@@ -230,7 +231,7 @@ class UpdateChangelogsWithReviewerStep(AbstractStep):
             CommandOptions.reviewer,
         ]
 
-    def guess_reviewer_from_bug(self, bug_id):
+    def _guess_reviewer_from_bug(self, bug_id):
         patches = self._tool.bugs.fetch_reviewed_patches_from_bug(bug_id)
         if len(patches) != 1:
             log("%s on bug %s, cannot infer reviewer." % (pluralize("reviewed patch", len(patches)), bug_id))
@@ -247,7 +248,7 @@ class UpdateChangelogsWithReviewerStep(AbstractStep):
             if not bug_id:
                 log("No bug id provided and --reviewer= not provided.  Not updating ChangeLogs with reviewer.")
                 return
-            reviewer = self.guess_reviewer_from_bug(bug_id)
+            reviewer = self._guess_reviewer_from_bug(bug_id)
 
         if not reviewer:
             log("Failed to guess reviewer from bug %s and --reviewer= not provided.  Not updating ChangeLogs with reviewer." % bug_id)
diff --git a/WebKitTools/Scripts/modules/buildsteps_unittest.py b/WebKitTools/Scripts/modules/buildsteps_unittest.py
new file mode 100644
index 0000000..f753e0b
--- /dev/null
+++ b/WebKitTools/Scripts/modules/buildsteps_unittest.py
@@ -0,0 +1,40 @@
+# 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.buildsteps import UpdateChangelogsWithReviewerStep
+from modules.mock_bugzillatool import MockBugzillaTool
+from modules.outputcapture import OutputCapture
+
+class UpdateChangelogsWithReviewerStepTest(unittest.TestCase):
+    def test_guess_reviewer_from_bug(self):
+        capture = OutputCapture()
+        step = UpdateChangelogsWithReviewerStep(MockBugzillaTool(), [])
+        expected_stderr = "0 reviewed patches on bug 1, cannot infer reviewer.\n"
+        capture.assert_outputs(self, step._guess_reviewer_from_bug, [1], expected_stderr=expected_stderr)
diff --git a/WebKitTools/Scripts/modules/commands/commandtest.py b/WebKitTools/Scripts/modules/commands/commandtest.py
index 30c0de5..9384224 100644
--- a/WebKitTools/Scripts/modules/commands/commandtest.py
+++ b/WebKitTools/Scripts/modules/commands/commandtest.py
@@ -34,9 +34,4 @@ from modules.outputcapture import OutputCapture
 
 class CommandsTest(unittest.TestCase):
     def assert_execute_outputs(self, command, args, expected_stdout="", expected_stderr="", options=Mock(), tool=MockBugzillaTool()):
-        capture = OutputCapture()
-        capture.capture_output()
-        command.execute(options, args, tool)
-        (stdout_string, stderr_string) = capture.restore_output()
-        self.assertEqual(stdout_string, expected_stdout)
-        self.assertEqual(stderr_string, expected_stderr)
+        OutputCapture().assert_outputs(self, command.execute, [options, args, tool], expected_stdout=expected_stdout, expected_stderr=expected_stderr)
diff --git a/WebKitTools/Scripts/modules/commands/queues_unittest.py b/WebKitTools/Scripts/modules/commands/queues_unittest.py
index d38159b..9a64604 100644
--- a/WebKitTools/Scripts/modules/commands/queues_unittest.py
+++ b/WebKitTools/Scripts/modules/commands/queues_unittest.py
@@ -39,16 +39,8 @@ class TestQueue(AbstractQueue):
 
 
 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)
+        OutputCapture().assert_outputs(self, 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")
diff --git a/WebKitTools/Scripts/modules/credentials_unittest.py b/WebKitTools/Scripts/modules/credentials_unittest.py
index 20d5bf3..3dec4d5 100644
--- a/WebKitTools/Scripts/modules/credentials_unittest.py
+++ b/WebKitTools/Scripts/modules/credentials_unittest.py
@@ -75,12 +75,8 @@ password: "SECRETSAUCE"
         executive_mock = Mock()
         credentials = Credentials("example.com", executive=executive_mock)
 
-        output = OutputCapture()
-        output.capture_output()
-        credentials._run_security_tool(username)
-        (stdout_output, stderr_output) = output.restore_output()
-        self.assertEqual(stdout_output, "")
-        self.assertEqual(stderr_output, "Reading Keychain for example.com account and password.  Click \"Allow\" to continue...\n")
+        expected_stderr = "Reading Keychain for example.com account and password.  Click \"Allow\" to continue...\n"
+        OutputCapture().assert_outputs(self, credentials._run_security_tool, [username], expected_stderr=expected_stderr)
 
         security_args = ["/usr/bin/security", "find-internet-password", "-g", "-s", "example.com"]
         if username:
diff --git a/WebKitTools/Scripts/modules/mock_bugzillatool.py b/WebKitTools/Scripts/modules/mock_bugzillatool.py
index 6c07f33..0ba9d0d 100644
--- a/WebKitTools/Scripts/modules/mock_bugzillatool.py
+++ b/WebKitTools/Scripts/modules/mock_bugzillatool.py
@@ -66,7 +66,7 @@ class MockBugzilla(Mock):
     def fetch_reviewed_patches_from_bug(self, bug_id):
         if bug_id == 42:
             return [self.patch1, self.patch2]
-        return None
+        return []
 
     def fetch_attachments_from_bug(self, bug_id):
         if bug_id == 42:
diff --git a/WebKitTools/Scripts/modules/multicommandtool_unittest.py b/WebKitTools/Scripts/modules/multicommandtool_unittest.py
index c71cc09..ad872c9 100644
--- a/WebKitTools/Scripts/modules/multicommandtool_unittest.py
+++ b/WebKitTools/Scripts/modules/multicommandtool_unittest.py
@@ -63,14 +63,9 @@ class CommandTest(unittest.TestCase):
 
     def test_required_arguments(self):
         two_required_arguments = TrivialCommand(argument_names="ARG1 ARG2 [ARG3]")
-        capture = OutputCapture()
-        capture.capture_output()
-        exit_code = two_required_arguments.check_arguments_and_execute(["foo"], TrivialTool())
-        (stdout_string, stderr_string) = capture.restore_output()
         expected_missing_args_error = "2 arguments required, 1 argument provided.  Provided: 'foo'  Required: ARG1 ARG2\nSee 'trivial-tool help trivial' for usage.\n"
+        exit_code = OutputCapture().assert_outputs(self, two_required_arguments.check_arguments_and_execute, [["foo"], TrivialTool()], expected_stderr=expected_missing_args_error)
         self.assertEqual(exit_code, 1)
-        self.assertEqual(stdout_string, "")
-        self.assertEqual(stderr_string, expected_missing_args_error)
 
 
 class TrivialTool(MultiCommandTool):
@@ -108,13 +103,9 @@ class MultiCommandToolTest(unittest.TestCase):
         self.assertEqual(tool.command_by_name("trivial").name, "trivial")
         self.assertEqual(tool.command_by_name("bar"), None)
 
-    def _assert_tool_main_outputs(self, tool, main_args, expected_stdout, expected_stderr = "", exit_code=0):
-        capture = OutputCapture()
-        capture.capture_output()
-        exit_code = tool.main(main_args)
-        (stdout_string, stderr_string) = capture.restore_output()
-        self.assertEqual(stdout_string, expected_stdout)
-        self.assertEqual(expected_stderr, expected_stderr)
+    def _assert_tool_main_outputs(self, tool, main_args, expected_stdout, expected_stderr = "", expected_exit_code=0):
+        exit_code = OutputCapture().assert_outputs(self, tool.main, [main_args], expected_stdout=expected_stdout, expected_stderr=expected_stderr)
+        self.assertEqual(exit_code, expected_exit_code)
 
     def test_global_help(self):
         tool = TrivialTool(commands=[TrivialCommand(), UncommonCommand()])
diff --git a/WebKitTools/Scripts/modules/outputcapture.py b/WebKitTools/Scripts/modules/outputcapture.py
index f02fc5d..592a669 100644
--- a/WebKitTools/Scripts/modules/outputcapture.py
+++ b/WebKitTools/Scripts/modules/outputcapture.py
@@ -51,3 +51,12 @@ class OutputCapture(object):
 
     def restore_output(self):
         return (self._restore_output_with_name("stdout"), self._restore_output_with_name("stderr"))
+
+    def assert_outputs(self, testcase, function, args=[], kwargs={}, expected_stdout="", expected_stderr=""):
+        self.capture_output()
+        return_value = function(*args, **kwargs)
+        (stdout_string, stderr_string) = self.restore_output()
+        testcase.assertEqual(stdout_string, expected_stdout)
+        testcase.assertEqual(stderr_string, expected_stderr)
+        # This is a little strange, but I don't know where else to return this information.
+        return return_value
diff --git a/WebKitTools/Scripts/run-webkit-unittests b/WebKitTools/Scripts/run-webkit-unittests
index 4696831..377489a 100755
--- a/WebKitTools/Scripts/run-webkit-unittests
+++ b/WebKitTools/Scripts/run-webkit-unittests
@@ -32,6 +32,7 @@ import unittest
 
 from modules.bugzilla_unittest import *
 from modules.buildbot_unittest import *
+from modules.buildsteps_unittest import *
 from modules.changelogs_unittest import *
 from modules.commands.download_unittest import *
 from modules.commands.upload_unittest import *

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list