2010-02-23 Dirk Pranke <dpranke@chromium.org>
authordpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Feb 2010 01:07:59 +0000 (01:07 +0000)
committerdpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Feb 2010 01:07:59 +0000 (01:07 +0000)
        Reviewed by David Levin.

        When the run-chromium-webkit-tests code was landed and the code was
        refactored into the 'port' package, I accidentally broke using
        http_server.py or websocket_server.py as command-line scripts
        (the constructors needed a port object they weren't getting). This
        change fixes them so that --server start|stop actually works.

        As a part of this, the two files need to be able to call port.get(),
        but doing that is awkward from a file inside the package, so I moved
        get() into factory.py and imported that into __init__.py so that
        http_server.py and websocket_server.py can just import factory.

        https://bugs.webkit.org/show_bug.cgi?id=35316

        * Scripts/webkitpy/layout_tests/port/__init__.py:
        * Scripts/webkitpy/layout_tests/port/factory.py:
        * Scripts/webkitpy/layout_tests/port/http_server.py:
        * Scripts/webkitpy/layout_tests/port/websocket_server.py:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@55210 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKitTools/ChangeLog
WebKitTools/Scripts/webkitpy/layout_tests/port/__init__.py
WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_mac.py
WebKitTools/Scripts/webkitpy/layout_tests/port/factory.py [new file with mode: 0644]
WebKitTools/Scripts/webkitpy/layout_tests/port/http_server.py
WebKitTools/Scripts/webkitpy/layout_tests/port/websocket_server.py

index 611583d..4558474 100644 (file)
@@ -1,3 +1,25 @@
+2010-02-23  Dirk Pranke  <dpranke@chromium.org>
+
+        Reviewed by David Levin.
+
+        When the run-chromium-webkit-tests code was landed and the code was
+        refactored into the 'port' package, I accidentally broke using
+        http_server.py or websocket_server.py as command-line scripts
+        (the constructors needed a port object they weren't getting). This
+        change fixes them so that --server start|stop actually works.
+
+        As a part of this, the two files need to be able to call port.get(),
+        but doing that is awkward from a file inside the package, so I moved
+        get() into factory.py and imported that into __init__.py so that
+        http_server.py and websocket_server.py can just import factory.
+
+        https://bugs.webkit.org/show_bug.cgi?id=35316
+
+        * Scripts/webkitpy/layout_tests/port/__init__.py:
+        * Scripts/webkitpy/layout_tests/port/factory.py:
+        * Scripts/webkitpy/layout_tests/port/http_server.py:
+        * Scripts/webkitpy/layout_tests/port/websocket_server.py:
+
 2010-02-24  Dirk Pranke  <dpranke@chromium.org>
 
         Reviewed by David Levin.
index 3509675..e3ad6f4 100644 (file)
 
 """Port-specific entrypoints for the layout tests test infrastructure."""
 
-
-import sys
-
-
-def get(port_name=None, options=None):
-    """Returns an object implementing the Port interface. If
-    port_name is None, this routine attempts to guess at the most
-    appropriate port on this platform."""
-    port_to_use = port_name
-    if port_to_use is None:
-        if sys.platform == 'win32':
-            port_to_use = 'chromium-win'
-        elif sys.platform == 'linux2':
-            port_to_use = 'chromium-linux'
-        elif sys.platform == 'darwin':
-            port_to_use = 'chromium-mac'
-
-    if port_to_use == 'test':
-        import test
-        return test.TestPort(port_name, options)
-    elif port_to_use.startswith('mac'):
-        import mac
-        return mac.MacPort(port_name, options)
-    elif port_to_use.startswith('chromium-mac'):
-        import chromium_mac
-        return chromium_mac.ChromiumMacPort(port_name, options)
-    elif port_to_use.startswith('chromium-linux'):
-        import chromium_linux
-        return chromium_linux.ChromiumLinuxPort(port_name, options)
-    elif port_to_use.startswith('chromium-win'):
-        import chromium_win
-        return chromium_win.ChromiumWinPort(port_name, options)
-
-    raise NotImplementedError('unsupported port: %s' % port_to_use)
+from factory import get
index 1001dcd..ece10b0 100644 (file)
@@ -134,10 +134,10 @@ class ChromiumMacPort(chromium.ChromiumPort):
                             'apache2-httpd.conf')
 
     def _path_to_lighttpd(self):
-        return self._lighttp_path('bin', 'lighttp')
+        return self._lighttpd_path('bin', 'lighttpd')
 
     def _path_to_lighttpd_modules(self):
-        return self._lighttp_path('lib')
+        return self._lighttpd_path('lib')
 
     def _path_to_lighttpd_php(self):
         return self._lighttpd_path('bin', 'php-cgi')
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/port/factory.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/factory.py
new file mode 100644 (file)
index 0000000..20da2b9
--- /dev/null
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+# Copyright (C) 2010 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.
+
+"""Factory method to retrieve the appropriate port implementation."""
+
+
+import sys
+
+
+def get(port_name=None, options=None):
+    """Returns an object implementing the Port interface. If
+    port_name is None, this routine attempts to guess at the most
+    appropriate port on this platform."""
+    port_to_use = port_name
+    if port_to_use is None:
+        if sys.platform == 'win32':
+            port_to_use = 'chromium-win'
+        elif sys.platform == 'linux2':
+            port_to_use = 'chromium-linux'
+        elif sys.platform == 'darwin':
+            port_to_use = 'chromium-mac'
+
+    if port_to_use == 'test':
+        import test
+        return test.TestPort(port_name, options)
+    elif port_to_use.startswith('mac'):
+        import mac
+        return mac.MacPort(port_name, options)
+    elif port_to_use.startswith('chromium-mac'):
+        import chromium_mac
+        return chromium_mac.ChromiumMacPort(port_name, options)
+    elif port_to_use.startswith('chromium-linux'):
+        import chromium_linux
+        return chromium_linux.ChromiumLinuxPort(port_name, options)
+    elif port_to_use.startswith('chromium-win'):
+        import chromium_win
+        return chromium_win.ChromiumWinPort(port_name, options)
+
+    raise NotImplementedError('unsupported port: %s' % port_to_use)
index 0315704..e56040c 100755 (executable)
@@ -40,6 +40,7 @@ import tempfile
 import time
 import urllib
 
+import factory
 import http_server_base
 
 
@@ -261,7 +262,9 @@ if '__main__' == __name__:
             # source of tests. Specifying port but no root does not seem
             # meaningful.
             raise 'Specifying port requires also a root.'
-        httpd = Lighttpd(tempfile.gettempdir(),
+        port_obj = factory.get()
+        httpd = Lighttpd(port_obj,
+                         tempfile.gettempdir(),
                          port=options.port,
                          root=options.root,
                          register_cygwin=options.register_cygwin,
index 54c2f6f..cb8e024 100644 (file)
@@ -39,6 +39,7 @@ import tempfile
 import time
 import urllib
 
+import factory
 import http_server
 
 _WS_LOG_PREFIX = 'pywebsocket.ws.log-'
@@ -296,7 +297,8 @@ if '__main__' == __name__:
     if options.pidfile:
         kwds['pidfile'] = options.pidfile
 
-    pywebsocket = PyWebSocket(tempfile.gettempdir(), **kwds)
+    port_obj = factory.get()
+    pywebsocket = PyWebSocket(port_obj, tempfile.gettempdir(), **kwds)
 
     if 'start' == options.server:
         pywebsocket.start()