Title: [90762] trunk/Tools
Revision
90762
Author
aba...@webkit.org
Date
2011-07-11 10:51:04 -0700 (Mon, 11 Jul 2011)

Log Message

garden-o-matic should be able to roll out patches
https://bugs.webkit.org/show_bug.cgi?id=64185

Reviewed by Eric Seidel.

This gardening server API is simply a binding to the rollout machinery
already present in webkit-patch.

* Scripts/webkitpy/tool/commands/gardenomatic.py:
* Scripts/webkitpy/tool/servers/gardeningserver.py:
* Scripts/webkitpy/tool/servers/gardeningserver_unittest.py: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (90761 => 90762)


--- trunk/Tools/ChangeLog	2011-07-11 17:35:51 UTC (rev 90761)
+++ trunk/Tools/ChangeLog	2011-07-11 17:51:04 UTC (rev 90762)
@@ -1,3 +1,17 @@
+2011-07-11  Adam Barth  <aba...@webkit.org>
+
+        garden-o-matic should be able to roll out patches
+        https://bugs.webkit.org/show_bug.cgi?id=64185
+
+        Reviewed by Eric Seidel.
+
+        This gardening server API is simply a binding to the rollout machinery
+        already present in webkit-patch.
+
+        * Scripts/webkitpy/tool/commands/gardenomatic.py:
+        * Scripts/webkitpy/tool/servers/gardeningserver.py:
+        * Scripts/webkitpy/tool/servers/gardeningserver_unittest.py: Added.
+
 2011-07-11  Csaba Osztrogonác  <o...@webkit.org>
 
         [Qt][Mac] Unreviewed fix after r90746.

Modified: trunk/Tools/Scripts/webkitpy/tool/commands/gardenomatic.py (90761 => 90762)


--- trunk/Tools/Scripts/webkitpy/tool/commands/gardenomatic.py	2011-07-11 17:35:51 UTC (rev 90761)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/gardenomatic.py	2011-07-11 17:51:04 UTC (rev 90762)
@@ -31,3 +31,8 @@
     help_text = "Experimental command for gardening the WebKit tree."
 
     server = GardeningHTTPServer
+
+    def _prepare_config(self, options, args, tool):
+        return {
+            'tool': tool,
+        }

Modified: trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver.py (90761 => 90762)


--- trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver.py	2011-07-11 17:35:51 UTC (rev 90761)
+++ trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver.py	2011-07-11 17:51:04 UTC (rev 90762)
@@ -30,7 +30,8 @@
 
 class GardeningHTTPServer(BaseHTTPServer.HTTPServer):
     def __init__(self, httpd_port, config):
-        server_name = ""
+        server_name = ''
+        self.tool = config['tool']
         BaseHTTPServer.HTTPServer.__init__(self, (server_name, httpd_port), GardeningHTTPRequestHandler)
 
 
@@ -47,3 +48,17 @@
     ])
 
     STATIC_FILE_DIRECTORY = os.path.join(os.path.dirname(__file__), "data", "gardeningserver")
+
+    def _run_webkit_patch(self, args):
+        return self.server.tool.executive.run_command([self.server.tool.path()] + args)
+
+    def rollout(self):
+        revision = self.query['revision'][0]
+        reason = self.query['reason'][0]
+        self._run_webkit_patch([
+            'rollout',
+            '--force-clean',
+            '--non-interactive',
+            revision,
+            reason,
+        ])

Added: trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver_unittest.py (0 => 90762)


--- trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver_unittest.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver_unittest.py	2011-07-11 17:51:04 UTC (rev 90762)
@@ -0,0 +1,58 @@
+# Copyright (C) 2011 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 webkitpy.common.system.outputcapture import OutputCapture
+from webkitpy.thirdparty.mock import Mock
+from webkitpy.tool.mocktool import MockTool, MockExecutive
+from webkitpy.tool.servers.gardeningserver import *
+
+
+class MockServer(object):
+    def __init__(self):
+        self.tool = MockTool()
+        self.tool.executive = MockExecutive(should_log=True)
+
+
+# The real GardeningHTTPRequestHandler has a constructor that's too hard to
+# call in a unit test, so we create a subclass that's easier to constrcut.
+class TestGardeningHTTPRequestHandler(GardeningHTTPRequestHandler):
+    def __init__(self, server):
+        self.server = server
+
+
+class GardeningServerTest(unittest.TestCase):
+    def _post_to_path(self, path, expected_stderr=None):
+        handler = TestGardeningHTTPRequestHandler(MockServer())
+        handler.path = path
+        OutputCapture().assert_outputs(self, handler.do_POST, expected_stderr=expected_stderr)
+
+    def test_empty_state(self):
+        expected_stderr = "MOCK run_command: ['echo', 'rollout', '--force-clean', '--non-interactive', '2314', 'MOCK rollout reason']\n"
+        self._post_to_path("/rollout?revision=2314&reason=MOCK+rollout+reason", expected_stderr=expected_stderr)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to