2010-05-17 Fumitoshi Ukai <ukai@chromium.org>
authorukai@chromium.org <ukai@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 May 2010 07:06:50 +0000 (07:06 +0000)
committerukai@chromium.org <ukai@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 May 2010 07:06:50 +0000 (07:06 +0000)
        Reviewed by Eric Seidel.

        Chromium: Add --chromium option to new-run-webkit-websocketserver
        https://bugs.webkit.org/show_bug.cgi?id=37664

        os.environ setup and setup_mount for cygwin are moved in ChromiumWinPort.setup_environ_for_server.

        * Scripts/new-run-webkit-httpd:
          Remove passing register_cygwin.
        * Scripts/new-run-webkit-websocketserver:
          Add --chromium flag.
          Remove passing register_cygwin.
          Create port object using options.
        * Scripts/webkitpy/layout_tests/port/base.py:
          Add setup_environ_for_server().
        * Scripts/webkitpy/layout_tests/port/chromium_win.py:
          Ditto.
        * Scripts/webkitpy/layout_tests/port/factory_unittest.py: Added.
        * Scripts/webkitpy/layout_tests/port/http_server.py:
          Remove register_cygwin_parameter.
          Call setup_environ_for_server().
        * Scripts/webkitpy/layout_tests/port/websocket_server.py:
          Ditto.

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

WebKitTools/ChangeLog
WebKitTools/Scripts/new-run-webkit-httpd
WebKitTools/Scripts/new-run-webkit-websocketserver
WebKitTools/Scripts/webkitpy/layout_tests/port/base.py
WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_win.py
WebKitTools/Scripts/webkitpy/layout_tests/port/factory_unittest.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 e979b18..b218b0c 100644 (file)
@@ -1,3 +1,29 @@
+2010-05-17  Fumitoshi Ukai  <ukai@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        Chromium: Add --chromium option to new-run-webkit-websocketserver
+        https://bugs.webkit.org/show_bug.cgi?id=37664
+
+        os.environ setup and setup_mount for cygwin are moved in ChromiumWinPort.setup_environ_for_server.
+
+        * Scripts/new-run-webkit-httpd:
+          Remove passing register_cygwin.
+        * Scripts/new-run-webkit-websocketserver:
+          Add --chromium flag.
+          Remove passing register_cygwin.
+          Create port object using options.
+        * Scripts/webkitpy/layout_tests/port/base.py:
+          Add setup_environ_for_server().
+        * Scripts/webkitpy/layout_tests/port/chromium_win.py:
+          Ditto.
+        * Scripts/webkitpy/layout_tests/port/factory_unittest.py: Added.
+        * Scripts/webkitpy/layout_tests/port/http_server.py:
+          Remove register_cygwin_parameter.
+          Call setup_environ_for_server().
+        * Scripts/webkitpy/layout_tests/port/websocket_server.py:
+          Ditto.
+
 2010-05-16  Daniel Bates  <dbates@rim.com>
 
         Reviewed by Chris Jerdonek.
index 88ae84e..f6ec164 100755 (executable)
@@ -65,7 +65,6 @@ def run(options):
                                      tempfile.gettempdir(),
                                      port=options.port,
                                      root=options.root,
-                                     register_cygwin=options.register_cygwin,
                                      run_background=options.run_background)
         if options.server == 'start':
             httpd.start()
index e43abab..4f6deaa 100644 (file)
@@ -42,27 +42,32 @@ def main():
     option_parser = optparse.OptionParser()
     option_parser.add_option('--server', type='choice',
                              choices=['start', 'stop'], default='start',
-                             help='Server action (start|stop)')
+                             help='Server action (start|stop).')
     option_parser.add_option('-p', '--port', dest='port',
-                             default=None, help='Port to listen on')
+                             default=None, help='Port to listen on.')
     option_parser.add_option('-r', '--root',
                              help='Absolute path to DocumentRoot '
-                                  '(overrides layout test roots)')
+                                  '(overrides layout test roots).')
     option_parser.add_option('-t', '--tls', dest='use_tls',
                              action='store_true',
-                             default=False, help='use TLS (wss://)')
+                             default=False, help='use TLS (wss://).')
     option_parser.add_option('-k', '--private_key', dest='private_key',
                              default='', help='TLS private key file.')
     option_parser.add_option('-c', '--certificate', dest='certificate',
                              default='', help='TLS certificate file.')
+    option_parser.add_option('--chromium', action='store_true',
+                             dest='chromium',
+                             default=False,
+                             help='Use the Chromium port.')
     option_parser.add_option('--register_cygwin', action="store_true",
                              dest="register_cygwin",
-                             help='Register Cygwin paths (on Win try bots)')
+                             help='Register Cygwin paths (on Win try bots).')
     option_parser.add_option('--pidfile', help='path to pid file.')
     option_parser.add_option('--output-dir', dest='output_dir',
                              default=None, help='output directory.')
     option_parser.add_option('-v', '--verbose', action='store_true',
-                             default=False, help='include debug-level logging')
+                             default=False,
+                             help='Include debug-level logging.')
     options, args = option_parser.parse_args()
 
     if not options.port:
@@ -83,7 +88,6 @@ def main():
         kwds['private_key'] = options.private_key
     if options.certificate:
         kwds['certificate'] = options.certificate
-    kwds['register_cygwin'] = options.register_cygwin
     if options.pidfile:
         kwds['pidfile'] = options.pidfile
 
index 25946af..a4cbe42 100644 (file)
@@ -414,10 +414,17 @@ class Port(object):
         raise NotImplemented('Port.results_directory')
 
     def setup_test_run(self):
-        """This routine can be overridden to perform any port-specific
-        work that shouuld be done at the beginning of a test run."""
+        """Perform port-specific work at the beginning of a test run."""
         pass
 
+    def setup_environ_for_server(self):
+        """Perform port-specific work at the beginning of a server launch.
+
+        Returns:
+           Operating-system's environment.
+        """
+        return os.environ
+
     def show_html_results_file(self, results_filename):
         """This routine should display the HTML file pointed at by
         results_filename in a users' browser."""
index 65c42bb..ad78e61 100644 (file)
@@ -43,11 +43,30 @@ class ChromiumWinPort(chromium.ChromiumPort):
 
     def __init__(self, port_name=None, options=None):
         if port_name is None:
-            port_name = 'chromium-win' + self.version()
-        if options and not hasattr(options, 'configuration'):
-            options.configuration = 'Release'
+            port_name = "chromium-win" + self.version()
+        if options and not hasattr(options, "configuration"):
+            options.configuration = "Release"
         chromium.ChromiumPort.__init__(self, port_name, options)
 
+    def setup_environ_for_server(self):
+        env = chromium.ChromiumPort.setup_environ_for_server(self)
+        # Put the cygwin directory first in the path to find cygwin1.dll.
+        env["PATH"] = "%s;%s" % (
+            self.path_from_chromium_base("third_party", "cygwin", "bin"),
+            env["PATH"])
+        # Configure the cygwin directory so that pywebsocket finds proper
+        # python executable to run cgi program.
+        env["CYGWIN_PATH"] = self.path_from_chromium_base(
+            "third_party", "cygwin", "bin")
+        if (sys.platform == "win32" and self._options and
+            hasattr(self._options, "register_cygwin") and
+            self._options.register_cygwin):
+            setup_mount = self.path_from_chromium_base("third_party",
+                                                       "cygwin",
+                                                       "setup_mount.bat")
+            self._executive.run_command(setup_mount)
+        return env
+
     def baseline_search_path(self):
         port_names = []
         if self._name == 'chromium-win-xp':
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/port/factory_unittest.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/factory_unittest.py
new file mode 100644 (file)
index 0000000..d8dffdf
--- /dev/null
@@ -0,0 +1,138 @@
+# 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.
+
+import sys
+import unittest
+
+import chromium_linux
+import chromium_mac
+import chromium_win
+import dryrun
+import factory
+import gtk
+import mac
+import qt
+import test
+import win
+
+
+class FactoryTest(unittest.TestCase):
+    """Test factory creates proper port object for the target.
+
+    Target is specified by port_name, sys.platform and options.
+
+    """
+    # FIXME: The ports themselves should expose what options they require,
+    # instead of passing generic "options".
+
+    class WebKitOptions(object):
+        """Represents the minimum options for WebKit port."""
+        def __init__(self):
+            self.pixel_tests = False
+
+    class ChromiumOptions(WebKitOptions):
+        """Represents minimum options for Chromium port."""
+        def __init__(self):
+            FactoryTest.WebKitOptions.__init__(self)
+            self.chromium = True
+
+    def setUp(self):
+        self.real_sys_platform = sys.platform
+        self.webkit_options = FactoryTest.WebKitOptions()
+        self.chromium_options = FactoryTest.ChromiumOptions()
+
+    def tearDown(self):
+        sys.platform = self.real_sys_platform
+
+    def assert_port(self, port_name, expected_port):
+        """Helper assert for port_name.
+
+        Args:
+          port_name: port name to get port object.
+          expected_port: class of expected port object.
+
+        """
+        self.assertTrue(isinstance(factory.get(port_name=port_name),
+                                   expected_port))
+
+    def assert_platform_port(self, platform, options, expected_port):
+        """Helper assert for platform and options.
+
+        Args:
+          platform: sys.platform.
+          options: options to get port object.
+          expected_port: class of expected port object.
+
+        """
+        orig_platform = sys.platform
+        sys.platform = platform
+        self.assertTrue(isinstance(factory.get(options=options),
+                                   expected_port))
+        sys.platform = orig_platform
+
+    def test_test(self):
+        self.assert_port("test", test.TestPort)
+
+    def test_dryrun(self):
+        self.assert_port("dryrun-test", dryrun.DryRunPort)
+        self.assert_port("dryrun-mac", dryrun.DryRunPort)
+
+    def test_mac(self):
+        self.assert_port("mac", mac.MacPort)
+        self.assert_platform_port("darwin", None, mac.MacPort)
+        self.assert_platform_port("darwin", self.webkit_options, mac.MacPort)
+
+    def test_win(self):
+        self.assert_port("win", win.WinPort)
+        self.assert_platform_port("win32", None, win.WinPort)
+        self.assert_platform_port("win32", self.webkit_options, win.WinPort)
+        self.assert_platform_port("cygwin", None, win.WinPort)
+        self.assert_platform_port("cygwin", self.webkit_options, win.WinPort)
+
+    def test_gtk(self):
+        self.assert_port("gtk", gtk.GtkPort)
+
+    def test_qt(self):
+        self.assert_port("qt", qt.QtPort)
+
+    def test_chromium_mac(self):
+        self.assert_port("chromium-mac", chromium_mac.ChromiumMacPort)
+        self.assert_platform_port("darwin", self.chromium_options,
+                                  chromium_mac.ChromiumMacPort)
+
+    def test_chromium_linux(self):
+        self.assert_port("chromium-linux", chromium_linux.ChromiumLinuxPort)
+        self.assert_platform_port("linux2", self.chromium_options,
+                                  chromium_linux.ChromiumLinuxPort)
+
+    def test_chromium_win(self):
+        self.assert_port("chromium-win", chromium_win.ChromiumWinPort)
+        self.assert_platform_port("win32", self.chromium_options,
+                                  chromium_win.ChromiumWinPort)
+        self.assert_platform_port("cygwin", self.chromium_options,
+                                  chromium_win.ChromiumWinPort)
index fbe47e3..0f8a21e 100755 (executable)
@@ -55,7 +55,7 @@ class HttpdNotStarted(Exception):
 class Lighttpd(http_server_base.HttpServerBase):
 
     def __init__(self, port_obj, output_dir, background=False, port=None,
-                 root=None, register_cygwin=None, run_background=None):
+                 root=None, run_background=None):
         """Args:
           output_dir: the absolute path to the layout test result directory
         """
@@ -65,7 +65,6 @@ class Lighttpd(http_server_base.HttpServerBase):
         self._process = None
         self._port = port
         self._root = root
-        self._register_cygwin = register_cygwin
         self._run_background = run_background
         if self._port:
             self._port = int(self._port)
@@ -199,20 +198,7 @@ class Lighttpd(http_server_base.HttpServerBase):
             shutil.copyfile(os.path.join(module_path, lib_file),
                             os.path.join(tmp_module_path, lib_file))
 
-        # Put the cygwin directory first in the path to find cygwin1.dll
-        env = os.environ
-        if sys.platform in ('cygwin', 'win32'):
-            env['PATH'] = '%s;%s' % (
-                self._port_obj.path_from_chromium_base('third_party',
-                                                       'cygwin', 'bin'),
-                env['PATH'])
-
-        if sys.platform == 'win32' and self._register_cygwin:
-            setup_mount = self._port_obj.path_from_chromium_base('third_party',
-                'cygwin', 'setup_mount.bat')
-            # FIXME: Should use Executive.run_command
-            subprocess.Popen(setup_mount).wait()
-
+        env = self._port_obj.setup_environ_for_server()
         _log.debug('Starting http server')
         # FIXME: Should use Executive.run_command
         self._process = subprocess.Popen(start_cmd, env=env)
index 55868fa..22ae780 100644 (file)
@@ -97,15 +97,13 @@ class PyWebSocket(http_server.Lighttpd):
 
     def __init__(self, port_obj, output_dir, port=_DEFAULT_WS_PORT,
                  root=None, use_tls=False,
-                 register_cygwin=True,
                  pidfile=None):
         """Args:
           output_dir: the absolute path to the layout test result directory
         """
         http_server.Lighttpd.__init__(self, port_obj, output_dir,
                                       port=_DEFAULT_WS_PORT,
-                                      root=root,
-                                      register_cygwin=register_cygwin)
+                                      root=root)
         self._output_dir = output_dir
         self._process = None
         self._port = port
@@ -188,21 +186,7 @@ class PyWebSocket(http_server.Lighttpd):
             start_cmd.extend(['-t', '-k', self._private_key,
                               '-c', self._certificate])
 
-        # Put the cygwin directory first in the path to find cygwin1.dll
-        env = os.environ
-        if sys.platform in ('cygwin', 'win32'):
-            env['PATH'] = '%s;%s' % (
-                self._port_obj.path_from_chromium_base('third_party',
-                                                       'cygwin', 'bin'),
-                env['PATH'])
-            env['CYGWIN_PATH'] = self._port_obj.path_from_chromium_base(
-                'third_party', 'cygwin', 'bin')
-
-        if sys.platform == 'win32' and self._register_cygwin:
-            setup_mount = self._port_obj.path_from_chromium_base(
-                'third_party', 'cygwin', 'setup_mount.bat')
-            subprocess.Popen(setup_mount).wait()
-
+        env = self._port_obj.setup_environ_for_server()
         env['PYTHONPATH'] = (pywebsocket_base + os.path.pathsep +
                              env.get('PYTHONPATH', ''))