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

abarth at webkit.org abarth at webkit.org
Wed Apr 7 23:58:47 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 1035754f18e3d7fc7a26db0d76f844af71f1900d
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Nov 27 17:37:46 2009 +0000

    2009-11-27  Adam Barth  <abarth at webkit.org>
    
            Reviewed by Eric Seidel.
    
            [bzt] Unit test download commands
            https://bugs.webkit.org/show_bug.cgi?id=31923
    
            Adds download_unittest and fixes a bug found while testing.
    
            * Scripts/modules/commands/commandtest.py:
            * Scripts/modules/commands/download.py:
                Fixed a bug where we'd throw an error because [].append returns
                None.
            * Scripts/modules/commands/download_unittest.py: Added.
            * Scripts/modules/mock_bugzillatool.py:
            * Scripts/run-webkit-unittests:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51442 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 1338d79..ce5e402 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,5 +1,22 @@
 2009-11-27  Adam Barth  <abarth at webkit.org>
 
+        Reviewed by Eric Seidel.
+
+        [bzt] Unit test download commands
+        https://bugs.webkit.org/show_bug.cgi?id=31923
+
+        Adds download_unittest and fixes a bug found while testing.
+
+        * Scripts/modules/commands/commandtest.py:
+        * Scripts/modules/commands/download.py:
+            Fixed a bug where we'd throw an error because [].append returns
+            None.
+        * Scripts/modules/commands/download_unittest.py: Added.
+        * Scripts/modules/mock_bugzillatool.py:
+        * Scripts/run-webkit-unittests:
+
+2009-11-27  Adam Barth  <abarth at webkit.org>
+
         Unreviewed "build" fix found while writing unit tests.
 
         * Scripts/modules/commands/download.py:
diff --git a/WebKitTools/Scripts/modules/commands/download.py b/WebKitTools/Scripts/modules/commands/download.py
index 98a8ebb..365b407 100644
--- a/WebKitTools/Scripts/modules/commands/download.py
+++ b/WebKitTools/Scripts/modules/commands/download.py
@@ -79,6 +79,7 @@ class Build(Command):
         sequence.run_and_handle_errors()
 
 
+# FIXME: Requires unit test. Blocking issue: WebKitApplyingScripts
 class ApplyAttachment(Command):
     name = "apply-attachment"
     show_in_main_help = True
@@ -94,6 +95,7 @@ class ApplyAttachment(Command):
         WebKitApplyingScripts.apply_patches_with_options(tool.scm(), [attachment], options)
 
 
+# FIXME: Requires unit test. Blocking issue: WebKitApplyingScripts
 class ApplyPatches(Command):
     name = "apply-patches"
     show_in_main_help = True
@@ -229,7 +231,7 @@ class AbstractPatchProcessingCommand(Command):
         bugs_to_patches = {}
         for patch in patches:
             bug_id = patch["bug_id"]
-            bugs_to_patches[bug_id] = bugs_to_patches.get(bug_id, []).append(patch)
+            bugs_to_patches[bug_id] = bugs_to_patches.get(bug_id, []) + [patch]
         return bugs_to_patches
 
     def execute(self, options, args, tool):
@@ -350,6 +352,7 @@ class LandPatches(AbstractPatchLandingCommand):
         return all_patches
 
 
+# FIXME: Requires unit test.
 class Rollout(Command):
     name = "rollout"
     show_in_main_help = True
diff --git a/WebKitTools/Scripts/modules/commands/download_unittest.py b/WebKitTools/Scripts/modules/commands/download_unittest.py
new file mode 100644
index 0000000..d0fff6e
--- /dev/null
+++ b/WebKitTools/Scripts/modules/commands/download_unittest.py
@@ -0,0 +1,65 @@
+# 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.download import *
+from modules.mock import Mock
+
+class DownloadCommandsTest(CommandsTest):
+    def _default_options(self):
+        options = Mock()
+        options.force_clean = False
+        options.clean = True
+        options.check_builders = True
+        options.quiet = False
+        options.non_interactive = False
+        options.update = True
+        options.build = True
+        options.test = True
+        options.close_bug = True
+        return options
+
+    def test_build(self):
+        self.assert_execute_outputs(Build(), [], options=self._default_options())
+
+    def test_land_diff(self):
+        self.assert_execute_outputs(LandDiff(), [42], options=self._default_options())
+
+    def test_check_style(self):
+        self.assert_execute_outputs(CheckStyle(), [197], options=self._default_options())
+
+    def test_build_attachment(self):
+        self.assert_execute_outputs(BuildAttachment(), [197], options=self._default_options())
+
+    def test_land_attachment(self):
+        self.assert_execute_outputs(LandAttachment(), [197], options=self._default_options())
+
+    def test_land_patches(self):
+        self.assert_execute_outputs(LandPatches(), [42], options=self._default_options())
diff --git a/WebKitTools/Scripts/modules/mock_bugzillatool.py b/WebKitTools/Scripts/modules/mock_bugzillatool.py
index 8015f10..9ebb287 100644
--- a/WebKitTools/Scripts/modules/mock_bugzillatool.py
+++ b/WebKitTools/Scripts/modules/mock_bugzillatool.py
@@ -26,11 +26,26 @@
 # (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 os
+
+from modules.mock import Mock
 from modules.scm import CommitMessage
 
-class MockBugzilla():
-    patch1 = { "id": 197, "bug_id": 42, "url": "http://example.com/197", "is_obsolete": False }
-    patch2 = { "id": 128, "bug_id": 42, "url": "http://example.com/128", "is_obsolete": False }
+class MockBugzilla(Mock):
+    patch1 = {
+        "id": 197,
+        "bug_id": 42,
+        "url": "http://example.com/197",
+        "is_obsolete": False,
+        "reviewer": "Reviewer1"
+    }
+    patch2 = {
+        "id": 128,
+        "bug_id": 42,
+        "url": "http://example.com/128",
+        "is_obsolete": False,
+        "reviewer": "Reviewer2"
+    }
 
     def fetch_bug_ids_from_commit_queue(self):
         return [42, 75]
@@ -53,17 +68,15 @@ class MockBugzilla():
             return [self.patch1, self.patch2]
         return None
 
-    def close_bug_as_fixed(self, bug_id, comment_text=None):
-        pass
-
-    def obsolete_attachment(self, attachment_id, comment_text=None):
-        pass
-
-    def add_patch_to_bug(self, bug_id, patch_file_object, description, comment_text=None, mark_for_review=False, mark_for_commit_queue=False):
-        pass
+    def fetch_attachment(self, attachment_id):
+        if attachment_id == 197:
+            return self.patch1
+        if attachment_id == 128:
+            return self.patch2
+        raise Exception("Bogus attachment_id in fetch_attachment.")
 
 
-class MockBuildBot():
+class MockBuildBot(Mock):
     def builder_statuses(self):
         return [{
             "name": "Builder1",
@@ -74,7 +87,11 @@ class MockBuildBot():
         }]
 
 
-class MockSCM():
+class MockSCM(Mock):
+    def __init__(self):
+        Mock.__init__(self)
+        self.checkout_root = os.getcwd()
+
     def create_patch(self):
         return "Patch1"
 
@@ -95,11 +112,18 @@ class MockSCM():
             return "Patch2"
         raise Exception("Bogus commit_id in commit_message_for_local_commit.")
 
+    def modified_changelogs(self):
+        # Ideally we'd return something more interesting here.
+        # The problem is that LandDiff will try to actually read the path from disk!
+        return []
+
 
 class MockBugzillaTool():
-    bugs = MockBugzilla()
-    buildbot = MockBuildBot()
+    def __init__(self):
+        self.bugs = MockBugzilla()
+        self.buildbot = MockBuildBot()
+        self.steps = Mock()
+        self._scm = MockSCM()
 
-    _scm = MockSCM()
     def scm(self):
         return self._scm
diff --git a/WebKitTools/Scripts/run-webkit-unittests b/WebKitTools/Scripts/run-webkit-unittests
index f447dfa..42bfe65 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.changelogs_unittest import *
+from modules.commands.download_unittest import *
 from modules.commands.upload_unittest import *
 from modules.commands.queries_unittest import *
 from modules.committers_unittest import *

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list