[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.16-1409-g5afdf4d

eric at webkit.org eric at webkit.org
Thu Dec 3 13:44:04 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit a2fd0fa8824db38a8b967b28876cea976f226447
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Nov 24 23:19:28 2009 +0000

    2009-11-24  Eric Seidel  <eric at webkit.org>
    
            Reviewed by Adam Barth.
    
            queries_unittest.py should test command output
            https://bugs.webkit.org/show_bug.cgi?id=31845
    
            * Scripts/modules/commands/queries_unittest.py:
             - Capture stdout and stderr and compare with expected strings.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51362 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index bd8441e..b6c17ce 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,13 @@
+2009-11-24  Eric Seidel  <eric at webkit.org>
+
+        Reviewed by Adam Barth.
+
+        queries_unittest.py should test command output
+        https://bugs.webkit.org/show_bug.cgi?id=31845
+
+        * Scripts/modules/commands/queries_unittest.py:
+         - Capture stdout and stderr and compare with expected strings.
+
 2009-11-24  Simon Fraser  <simon.fraser at apple.com>
 
         No Review.
diff --git a/WebKitTools/Scripts/modules/commands/queries_unittest.py b/WebKitTools/Scripts/modules/commands/queries_unittest.py
index 5e8ddc1..6bae722 100644
--- a/WebKitTools/Scripts/modules/commands/queries_unittest.py
+++ b/WebKitTools/Scripts/modules/commands/queries_unittest.py
@@ -27,20 +27,48 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 import unittest
+from StringIO import StringIO
 
 from modules.commands.queries import *
 from modules.mock_bugzillatool import *
 
 class QueryCommandsTest(unittest.TestCase):
+    def _capture_output_with_name(output_name):
+        self.saved_outputs[output_name] = getattr(sys, output_name)
+        setattr(sys, output_name, StringIO.StringIO())
+
+    def _release_output_with_name(output_name):
+        captured_output = getattr(sys, output_name).getvalue()
+        setattr(sys, output_name, self.saved_outputs[output_name])
+        del self.saved_outputs[output_name]
+        return captured_output
+
+    def _capture_output(self):
+        self._capture_output_with_name("stdout")
+        self._capture_output_with_name("stderr")
+
+    def _restore_output(self):
+        return (self._release_output_with_name("stdout"), self._release_output_with_name("stderr"))
+
+    def _assert_execute_outputs(self, command, command_args, expected_stdout, expected_stderr = ""):
+        self._capture_output()
+        command.execute(None, command_args, MockBugzillaTool())
+        (stdout_string, stderr_string) = self._restore_output()
+        self.assertEqual(stdout_string, expected_stdout)
+        self.assertEqual(expected_stderr, expected_stderr)
+
     def test_bugs_to_commit(self):
-        BugsToCommit().execute(None, None, MockBugzillaTool())
+        self._assert_execute_outputs(BugsToCommit(), None, "42\n75\n")
 
     def test_patches_to_commit(self):
-        PatchesToCommit().execute(None, None, MockBugzillaTool())
+        expected_stdout = "http://example.com/197\nhttp://example.com/128\n"
+        expected_stderr = "Patches in commit queue:\n"
+        self._assert_execute_outputs(PatchesToCommit(), None, expected_stdout, expected_stderr)
 
     def test_reviewed_patches(self):
-        args = [42]
-        ReviewedPatches().execute(None, args, MockBugzillaTool())
+        expected_stdout = "http://example.com/197\nhttp://example.com/128\n"
+        self._assert_execute_outputs(ReviewedPatches(), [42], expected_stdout)
 
     def test_tree_status(self):
-        TreeStatus().execute(None, None, MockBugzillaTool())
+        expected_stdout = "ok   : Builder1\nok   : Builder2\n"
+        self._assert_execute_outputs(TreeStatus(), None, expected_stdout)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list