Title: [90410] trunk/Tools
Revision
90410
Author
[email protected]
Date
2011-07-05 15:52:01 -0700 (Tue, 05 Jul 2011)

Log Message

2011-07-05  Adam Barth  <[email protected]>

        Add trivial garden-o-matic command (with server)
        https://bugs.webkit.org/show_bug.cgi?id=63872

        Reviewed by Eric Seidel.

        This patch adds a trivial "Hello, world" garden-o-matic command,
        complete with an HTTP server.  This command re-uses a bunch of code
        from the existing rebaseline-server command.  Over time, this command
        will grow to be a tool useful for gardening the WebKit tree.

        * Scripts/webkitpy/tool/commands/__init__.py:
        * Scripts/webkitpy/tool/commands/abstractservercommand.py: Added.
        * Scripts/webkitpy/tool/commands/gardenomatic.py: Added.
        * Scripts/webkitpy/tool/commands/rebaselineserver.py:
        * Scripts/webkitpy/tool/servers/data/gardeningserver/index.html: Added.
        * Scripts/webkitpy/tool/servers/gardeningserver.py: Added.
        * Scripts/webkitpy/tool/servers/rebaselineserver.py:

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (90409 => 90410)


--- trunk/Tools/ChangeLog	2011-07-05 22:20:53 UTC (rev 90409)
+++ trunk/Tools/ChangeLog	2011-07-05 22:52:01 UTC (rev 90410)
@@ -1,3 +1,23 @@
+2011-07-05  Adam Barth  <[email protected]>
+
+        Add trivial garden-o-matic command (with server)
+        https://bugs.webkit.org/show_bug.cgi?id=63872
+
+        Reviewed by Eric Seidel.
+
+        This patch adds a trivial "Hello, world" garden-o-matic command,
+        complete with an HTTP server.  This command re-uses a bunch of code
+        from the existing rebaseline-server command.  Over time, this command
+        will grow to be a tool useful for gardening the WebKit tree.
+
+        * Scripts/webkitpy/tool/commands/__init__.py:
+        * Scripts/webkitpy/tool/commands/abstractservercommand.py: Added.
+        * Scripts/webkitpy/tool/commands/gardenomatic.py: Added.
+        * Scripts/webkitpy/tool/commands/rebaselineserver.py:
+        * Scripts/webkitpy/tool/servers/data/gardeningserver/index.html: Added.
+        * Scripts/webkitpy/tool/servers/gardeningserver.py: Added.
+        * Scripts/webkitpy/tool/servers/rebaselineserver.py:
+
 2011-07-05  Adam Roben  <[email protected]>
 
         Make prepare-ChangeLog include modified Perl functions in its ChangeLog template

Modified: trunk/Tools/Scripts/webkitpy/tool/commands/__init__.py (90409 => 90410)


--- trunk/Tools/Scripts/webkitpy/tool/commands/__init__.py	2011-07-05 22:20:53 UTC (rev 90409)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/__init__.py	2011-07-05 22:52:01 UTC (rev 90410)
@@ -1,9 +1,10 @@
 # Required for Python to search this directory for module files
 
+from webkitpy.tool.commands.bugfortest import BugForTest
 from webkitpy.tool.commands.bugsearch import BugSearch
-from webkitpy.tool.commands.bugfortest import BugForTest
 from webkitpy.tool.commands.download import *
 from webkitpy.tool.commands.earlywarningsystem import *
+from webkitpy.tool.commands.gardenomatic import GardenOMatic
 from webkitpy.tool.commands.openbugs import OpenBugs
 from webkitpy.tool.commands.prettydiff import PrettyDiff
 from webkitpy.tool.commands.queries import *

Added: trunk/Tools/Scripts/webkitpy/tool/commands/abstractlocalservercommand.py (0 => 90410)


--- trunk/Tools/Scripts/webkitpy/tool/commands/abstractlocalservercommand.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/abstractlocalservercommand.py	2011-07-05 22:52:01 UTC (rev 90410)
@@ -0,0 +1,54 @@
+# 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:
+#
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  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.
+#
+# 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 optparse import make_option
+import threading
+
+from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand
+
+
+class AbstractLocalServerCommand(AbstractDeclarativeCommand):
+    server = None
+
+    def __init__(self):
+        options = [
+            make_option("--httpd-port", action="" type="int", default=8127, help="Port to use for the HTTP server"),
+        ]
+        AbstractDeclarativeCommand.__init__(self, options=options)
+
+    def _prepare_config(self, options, args, tool):
+        return None
+
+    def execute(self, options, args, tool):
+        config = self._prepare_config(options, args, tool)
+
+        server_url = "http://localhost:%d/" % options.httpd_port
+        print "Starting server at %s" % server_url
+        print "Use the 'Exit' link in the UI, %squitquitquit or Ctrl-C to stop" % server_url
+
+        # FIXME: This seems racy.
+        threading.Timer(0.1, lambda: self._tool.user.open_url(server_url)).start()
+
+        httpd = self.server(httpd_port=options.httpd_port, config=config)
+        httpd.serve_forever()

Added: trunk/Tools/Scripts/webkitpy/tool/commands/gardenomatic.py (0 => 90410)


--- trunk/Tools/Scripts/webkitpy/tool/commands/gardenomatic.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/gardenomatic.py	2011-07-05 22:52:01 UTC (rev 90410)
@@ -0,0 +1,33 @@
+# 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:
+#
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  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.
+#
+# 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.tool.commands.abstractlocalservercommand import AbstractLocalServerCommand
+from webkitpy.tool.servers.gardeningserver import GardeningHTTPServer
+
+
+class GardenOMatic(AbstractLocalServerCommand):
+    name = "garden-o-matic"
+    help_text = "Experimental command for gardening the WebKit tree."
+
+    server = GardeningHTTPServer

Modified: trunk/Tools/Scripts/webkitpy/tool/commands/rebaselineserver.py (90409 => 90410)


--- trunk/Tools/Scripts/webkitpy/tool/commands/rebaselineserver.py	2011-07-05 22:20:53 UTC (rev 90409)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/rebaselineserver.py	2011-07-05 22:52:01 UTC (rev 90410)
@@ -32,15 +32,12 @@
 
 import os
 import os.path
-import threading
 
-from optparse import make_option
-
 from webkitpy.common import system
 from webkitpy.common.net import resultsjsonparser
 from webkitpy.layout_tests.layout_package import json_results_generator
 from webkitpy.layout_tests.port import factory
-from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand
+from webkitpy.tool.commands.abstractlocalservercommand import AbstractLocalServerCommand
 from webkitpy.tool.servers.rebaselineserver import RebaselineHTTPServer, STATE_NEEDS_REBASELINE
 
 
@@ -54,49 +51,26 @@
         self.scm = scm
 
 
-class RebaselineServer(AbstractDeclarativeCommand):
+class RebaselineServer(AbstractLocalServerCommand):
     name = "rebaseline-server"
     help_text = __doc__
     argument_names = "/path/to/results/directory"
 
-    def __init__(self):
-        options = [
-            make_option("--httpd-port", action="" type="int", default=8127, help="Port to use for the the rebaseline HTTP server"),
-        ]
-        AbstractDeclarativeCommand.__init__(self, options=options)
+    server = RebaselineHTTPServer
 
-    def execute(self, options, args, tool):
+    def _prepare_config(self, options, args, tool):
         results_directory = args[0]
         filesystem = system.filesystem.FileSystem()
         scm = self._tool.scm()
 
-        if options.dry_run:
-
-            def no_op_copyfile(src, dest):
-                pass
-
-            def no_op_add(path, return_exit_code=False):
-                if return_exit_code:
-                    return 0
-
-            filesystem.copyfile = no_op_copyfile
-            scm.add = no_op_add
-
         print 'Parsing unexpected_results.json...'
         results_json_path = filesystem.join(results_directory, 'unexpected_results.json')
         results_json = json_results_generator.load_json(filesystem, results_json_path)
 
         port = factory.get()
         layout_tests_directory = port.layout_tests_dir()
-        platforms = filesystem.listdir(
-            filesystem.join(layout_tests_directory, 'platform'))
-        test_config = TestConfig(
-            port,
-            layout_tests_directory,
-            results_directory,
-            platforms,
-            filesystem,
-            scm)
+        platforms = filesystem.listdir(filesystem.join(layout_tests_directory, 'platform'))
+        test_config = TestConfig(port, layout_tests_directory, results_directory, platforms, filesystem, scm)
 
         print 'Gathering current baselines...'
         # Rebaseline server and it's associated _javascript_ expected the tests subtree to
@@ -112,20 +86,11 @@
         resultsjsonparser.for_each_test(results_json['tests'], gather_baselines)
         results_json['tests'] = new_tests_subtree
 
-        server_url = "http://localhost:%d/" % options.httpd_port
-        print "Starting server at %s" % server_url
-        print ("Use the 'Exit' link in the UI, %squitquitquit "
-            "or Ctrl-C to stop") % server_url
-
-        threading.Timer(
-            .1, lambda: self._tool.user.open_url(server_url)).start()
-
-        httpd = RebaselineHTTPServer(
-            httpd_port=options.httpd_port,
-            test_config=test_config,
-            results_json=results_json,
-            platforms_json={
+        return {
+            'test_config': test_config,
+            "results_json": results_json,
+            "platforms_json": {
                 'platforms': platforms,
                 'defaultPlatform': port.name(),
-            })
-        httpd.serve_forever()
+            },
+        }

Added: trunk/Tools/Scripts/webkitpy/tool/servers/data/gardeningserver/index.html (0 => 90410)


--- trunk/Tools/Scripts/webkitpy/tool/servers/data/gardeningserver/index.html	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/tool/servers/data/gardeningserver/index.html	2011-07-05 22:52:01 UTC (rev 90410)
@@ -0,0 +1,2 @@
+<h1>Hello, world!</h1>
+<a href=""

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


--- trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver.py	2011-07-05 22:52:01 UTC (rev 90410)
@@ -0,0 +1,42 @@
+# 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:
+#
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  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.
+#
+# 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 BaseHTTPServer
+import os
+
+from webkitpy.tool.servers.reflectionhandler import ReflectionHandler
+
+
+class GardeningHTTPServer(BaseHTTPServer.HTTPServer):
+    def __init__(self, httpd_port, config):
+        server_name = ""
+        BaseHTTPServer.HTTPServer.__init__(self, (server_name, httpd_port), GardeningHTTPRequestHandler)
+
+
+class GardeningHTTPRequestHandler(ReflectionHandler):
+    STATIC_FILE_NAMES = frozenset([
+        "index.html",
+    ])
+
+    STATIC_FILE_DIRECTORY = os.path.join(os.path.dirname(__file__), "data", "gardeningserver")

Modified: trunk/Tools/Scripts/webkitpy/tool/servers/rebaselineserver.py (90409 => 90410)


--- trunk/Tools/Scripts/webkitpy/tool/servers/rebaselineserver.py	2011-07-05 22:20:53 UTC (rev 90409)
+++ trunk/Tools/Scripts/webkitpy/tool/servers/rebaselineserver.py	2011-07-05 22:52:01 UTC (rev 90410)
@@ -196,11 +196,12 @@
 
 
 class RebaselineHTTPServer(BaseHTTPServer.HTTPServer):
-    def __init__(self, httpd_port, test_config, results_json, platforms_json):
-        BaseHTTPServer.HTTPServer.__init__(self, ("", httpd_port), RebaselineHTTPRequestHandler)
-        self.test_config = test_config
-        self.results_json = results_json
-        self.platforms_json = platforms_json
+    def __init__(self, httpd_port, config):
+        server_name = ""
+        BaseHTTPServer.HTTPServer.__init__(self, (server_name, httpd_port), RebaselineHTTPRequestHandler)
+        self.test_config = config['test_config']
+        self.results_json = config['results_json']
+        self.platforms_json = config['platforms_json']
 
 
 class RebaselineHTTPRequestHandler(ReflectionHandler):
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to