2010-09-21 Dirk Pranke <dpranke@chromium.org>
authordpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Sep 2010 02:24:51 +0000 (02:24 +0000)
committerdpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Sep 2010 02:24:51 +0000 (02:24 +0000)
        Reviewed by Adam Barth.

        Modify the Port interface to take only a series of keyword arguments
        in the constructor, and modify Port/factory.get() to accomodate that,
        and to accept user=XXX as an argument so we can pass
        webkitpy.common.system.user.User objects in.

        Then, modify new-run-webkit-tests and rebaseline-chromium-webkit-tests
        to use the common routine in webkitpy.common.system.user.open_url()
        to display HTML files.

        There was a routine in the Port interface to do the same thing,
        but I see no need for a port-specific hook for this, since it is
        something that will always be executed by the host environment
        and displaying web pages has nothing to do with running layout tests.

        Note that new-run-webkit-tests used to use test_shell to display
        the page; this is potentially useful so that you can actually click
        from a result to the broken page; however, since DumpRenderTree
        doesn't support this functionality, it will be going away eventually.

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

        * Scripts/webkitpy/layout_tests/port/base.py:
        * Scripts/webkitpy/layout_tests/port/base_unittest.py:
        * Scripts/webkitpy/layout_tests/port/chromium.py:
        * Scripts/webkitpy/layout_tests/port/chromium_linux.py:
        * Scripts/webkitpy/layout_tests/port/chromium_mac.py:
        * Scripts/webkitpy/layout_tests/port/chromium_unittest.py:
        * Scripts/webkitpy/layout_tests/port/chromium_win.py:
        * Scripts/webkitpy/layout_tests/port/dryrun.py:
        * Scripts/webkitpy/layout_tests/port/factory.py:
        * Scripts/webkitpy/layout_tests/port/google_chrome.py:
        * Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py:
        * Scripts/webkitpy/layout_tests/port/gtk.py:
        * Scripts/webkitpy/layout_tests/port/mac.py:
        * Scripts/webkitpy/layout_tests/port/qt.py:
        * Scripts/webkitpy/layout_tests/port/test.py:
        * Scripts/webkitpy/layout_tests/port/webkit.py:
        * Scripts/webkitpy/layout_tests/port/win.py:
        * Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py:
        * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
        * Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py:

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

21 files changed:
WebKitTools/ChangeLog
WebKitTools/Scripts/webkitpy/layout_tests/port/base.py
WebKitTools/Scripts/webkitpy/layout_tests/port/base_unittest.py
WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py
WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_linux.py
WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_mac.py
WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py
WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_win.py
WebKitTools/Scripts/webkitpy/layout_tests/port/dryrun.py
WebKitTools/Scripts/webkitpy/layout_tests/port/factory.py
WebKitTools/Scripts/webkitpy/layout_tests/port/google_chrome.py
WebKitTools/Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py
WebKitTools/Scripts/webkitpy/layout_tests/port/gtk.py
WebKitTools/Scripts/webkitpy/layout_tests/port/mac.py
WebKitTools/Scripts/webkitpy/layout_tests/port/qt.py
WebKitTools/Scripts/webkitpy/layout_tests/port/test.py
WebKitTools/Scripts/webkitpy/layout_tests/port/webkit.py
WebKitTools/Scripts/webkitpy/layout_tests/port/win.py
WebKitTools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py
WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests.py
WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py

index 3977e661e6b8b09902fe13963ffb1c89426acf5d..e04f9bff02098611f32792c67d6de428c6ae8acf 100644 (file)
@@ -1,3 +1,49 @@
+2010-09-21  Dirk Pranke  <dpranke@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        Modify the Port interface to take only a series of keyword arguments
+        in the constructor, and modify Port/factory.get() to accomodate that,
+        and to accept user=XXX as an argument so we can pass
+        webkitpy.common.system.user.User objects in.
+
+        Then, modify new-run-webkit-tests and rebaseline-chromium-webkit-tests
+        to use the common routine in webkitpy.common.system.user.open_url()
+        to display HTML files.
+
+        There was a routine in the Port interface to do the same thing,
+        but I see no need for a port-specific hook for this, since it is
+        something that will always be executed by the host environment
+        and displaying web pages has nothing to do with running layout tests.
+
+        Note that new-run-webkit-tests used to use test_shell to display
+        the page; this is potentially useful so that you can actually click
+        from a result to the broken page; however, since DumpRenderTree
+        doesn't support this functionality, it will be going away eventually.
+
+        https://bugs.webkit.org/show_bug.cgi?id=46128
+
+        * Scripts/webkitpy/layout_tests/port/base.py:
+        * Scripts/webkitpy/layout_tests/port/base_unittest.py:
+        * Scripts/webkitpy/layout_tests/port/chromium.py:
+        * Scripts/webkitpy/layout_tests/port/chromium_linux.py:
+        * Scripts/webkitpy/layout_tests/port/chromium_mac.py:
+        * Scripts/webkitpy/layout_tests/port/chromium_unittest.py:
+        * Scripts/webkitpy/layout_tests/port/chromium_win.py:
+        * Scripts/webkitpy/layout_tests/port/dryrun.py:
+        * Scripts/webkitpy/layout_tests/port/factory.py:
+        * Scripts/webkitpy/layout_tests/port/google_chrome.py:
+        * Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py:
+        * Scripts/webkitpy/layout_tests/port/gtk.py:
+        * Scripts/webkitpy/layout_tests/port/mac.py:
+        * Scripts/webkitpy/layout_tests/port/qt.py:
+        * Scripts/webkitpy/layout_tests/port/test.py:
+        * Scripts/webkitpy/layout_tests/port/webkit.py:
+        * Scripts/webkitpy/layout_tests/port/win.py:
+        * Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py:
+        * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
+        * Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py:
+
 2010-09-21  Lucas De Marchi  <lucas.demarchi@profusion.mobi>
 
         Reviewed by Kenneth Rohde Christiansen.
index 8a1263c1c4c5f1be70f4d6101a1664c8a7d381dc..32a4e1729650160ea4d77be696a4b139f15f267c 100644 (file)
@@ -48,6 +48,7 @@ import websocket_server
 
 from webkitpy.common.system import logutils
 from webkitpy.common.system.executive import Executive, ScriptError
+from webkitpy.common.system.user import User
 
 
 _log = logutils.get_logger(__file__)
@@ -82,14 +83,15 @@ class Port(object):
         }
         return flags_by_configuration[configuration]
 
-    def __init__(self, port_name=None, options=None, executive=Executive()):
-        self._name = port_name
-        self._options = options
+    def __init__(self, **kwargs):
+        self._name = kwargs.get('port_name', None)
+        self._options = kwargs.get('options', None)
+        self._executive = kwargs.get('executive', Executive())
+        self._user = kwargs.get('user', User())
         self._helper = None
         self._http_server = None
         self._webkit_base_dir = None
         self._websocket_server = None
-        self._executive = executive
 
     def default_child_processes(self):
         """Return the number of DumpRenderTree instances to use for this
@@ -462,10 +464,10 @@ class Port(object):
         """
         return os.environ.copy()
 
-    def show_html_results_file(self, results_filename):
+    def show_results_html_file(self, results_filename):
         """This routine should display the HTML file pointed at by
         results_filename in a users' browser."""
-        raise NotImplementedError('Port.show_html_results_file')
+        return self._user.open_url(results_filename)
 
     def create_driver(self, image_path, options):
         """Return a newly created base.Driver subclass for starting/stopping
index 4744928f291448eaba206a51d2afcbecce6e9a97..1a6e410038d9b1c56803b849bd86311ace072e62 100644 (file)
@@ -236,7 +236,6 @@ class VirtualTest(unittest.TestCase):
         self.assertVirtual(port.path_to_test_expectations_file)
         self.assertVirtual(port.test_platform_name)
         self.assertVirtual(port.results_directory)
-        self.assertVirtual(port.show_html_results_file, None)
         self.assertVirtual(port.test_expectations)
         self.assertVirtual(port.test_base_platform_names)
         self.assertVirtual(port.test_platform_name)
index db3dc34e2fdcccd22eef12fefd2f3fdefa195ec8..7a7731abda5c7ef5758f2f93790ff26d2c0ebb76 100644 (file)
@@ -82,8 +82,13 @@ def check_file_exists(path_to_file, file_description, override_step=None,
 class ChromiumPort(base.Port):
     """Abstract base class for Chromium implementations of the Port class."""
 
-    def __init__(self, port_name=None, options=None, **kwargs):
-        base.Port.__init__(self, port_name, options, **kwargs)
+    def __init__(self, **kwargs):
+        if 'options' in kwargs:
+            options = kwargs['options']
+            if (options and (not hasattr(options, 'configuration') or
+                             options.configuration is None)):
+                options.configuration = 'Release'
+        base.Port.__init__(self, **kwargs)
         self._chromium_base_dir = None
 
     def baseline_path(self):
@@ -190,15 +195,6 @@ class ChromiumPort(base.Port):
         if os.path.exists(cachedir):
             shutil.rmtree(cachedir)
 
-    def show_results_html_file(self, results_filename):
-        uri = self.get_absolute_path(results_filename)
-        if self._options.use_drt:
-            # FIXME: This should use User.open_url
-            webbrowser.open(uri, new=1)
-        else:
-            # Note: Not thread safe: http://bugs.python.org/issue2320
-            subprocess.Popen([self._path_to_driver(), uri])
-
     def create_driver(self, image_path, options):
         """Starts a new Driver and returns a handle to it."""
         if options.use_drt and sys.platform == 'darwin':
index 4df43e013202f1873d273af7d2d3148eb84b6bce..176991b7f6a68df779f71d511044132869e1e189 100644 (file)
@@ -41,12 +41,9 @@ _log = logging.getLogger("webkitpy.layout_tests.port.chromium_linux")
 class ChromiumLinuxPort(chromium.ChromiumPort):
     """Chromium Linux implementation of the Port class."""
 
-    def __init__(self, port_name=None, options=None):
-        if port_name is None:
-            port_name = 'chromium-linux'
-        if options and not hasattr(options, 'configuration'):
-            options.configuration = 'Release'
-        chromium.ChromiumPort.__init__(self, port_name, options)
+    def __init__(self, **kwargs):
+        kwargs.setdefault('port_name', 'chromium-linux')
+        chromium.ChromiumPort.__init__(self, **kwargs)
 
     def baseline_search_path(self):
         port_names = ["chromium-linux", "chromium-win", "chromium", "win", "mac"]
index abd84ae5ee44ef93f80f44f703f0eb64e1003d3e..64016ab042cae8a8e27bdcaab461cf5cae3a2f81 100644 (file)
@@ -44,12 +44,9 @@ _log = logging.getLogger("webkitpy.layout_tests.port.chromium_mac")
 class ChromiumMacPort(chromium.ChromiumPort):
     """Chromium Mac implementation of the Port class."""
 
-    def __init__(self, port_name=None, options=None):
-        if port_name is None:
-            port_name = 'chromium-mac'
-        if options and not hasattr(options, 'configuration'):
-            options.configuration = 'Release'
-        chromium.ChromiumPort.__init__(self, port_name, options)
+    def __init__(self, **kwargs):
+        kwargs.setdefault('port_name', 'chromium-mac')
+        chromium.ChromiumPort.__init__(self, **kwargs)
 
     def baseline_search_path(self):
         port_names = ["chromium-mac", "chromium", "mac" + self.version(), "mac"]
index 518cdb92ddc013b1434638f28def603bc77ee217..1cfbde1774aae3e88337d532c98f09e1c4c58c60 100644 (file)
@@ -88,10 +88,12 @@ class ChromiumDriverTest(unittest.TestCase):
             def __init__(self):
                 self.use_drt = True
 
-        port = chromium_linux.ChromiumLinuxPort('test-port', options=MockOptions())
+        port = chromium_linux.ChromiumLinuxPort(port_name='test-port',
+                                                options=MockOptions())
         self.assertTrue(port._path_to_image_diff().endswith(
             '/out/Release/ImageDiff'))
-        port = chromium_mac.ChromiumMacPort('test-port', options=MockOptions())
+        port = chromium_mac.ChromiumMacPort(port_name='test-port',
+                                            options=MockOptions())
         self.assertTrue(port._path_to_image_diff().endswith(
             '/xcodebuild/Release/ImageDiff'))
         # FIXME: Figure out how this is going to work on Windows.
@@ -102,7 +104,8 @@ class ChromiumDriverTest(unittest.TestCase):
             def __init__(self):
                 self.use_drt = True
 
-        port = chromium_linux.ChromiumLinuxPort('test-port', options=MockOptions())
+        port = chromium_linux.ChromiumLinuxPort(port_name='test-port',
+                                                options=MockOptions())
 
         fake_test = os.path.join(port.layout_tests_dir(), "fast/js/not-good.js")
 
index e9a81e78f3f5e431ddad50bd99ad9e46df715e4f..333cfa4a844a01044d1996dc7aa9cca3b24ae0cf 100644 (file)
@@ -41,12 +41,9 @@ _log = logging.getLogger("webkitpy.layout_tests.port.chromium_win")
 class ChromiumWinPort(chromium.ChromiumPort):
     """Chromium Win implementation of the Port class."""
 
-    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"
-        chromium.ChromiumPort.__init__(self, port_name, options)
+    def __init__(self, **kwargs):
+        kwargs.setdefault('port_name', 'chromium-win')
+        chromium.ChromiumPort.__init__(self, **kwargs)
 
     def setup_environ_for_server(self):
         env = chromium.ChromiumPort.setup_environ_for_server(self)
index 35e0e2d2e15eb02f56d63eeb028f82409c3da521..648ccadaae6f45f7d06b2b5eb6cb1edd2ff58b10 100644 (file)
@@ -56,14 +56,14 @@ import factory
 class DryRunPort(object):
     """DryRun implementation of the Port interface."""
 
-    def __init__(self, port_name=None, options=None):
+    def __init__(self, **kwargs):
         pfx = 'dryrun-'
-        if port_name.startswith(pfx):
-            port_name = port_name[len(pfx):]
-        else:
-            port_name = None
-        self._options = options
-        self.__delegate = factory.get(port_name, options)
+        if 'port_name' in kwargs:
+            if kwargs['port_name'].startswith(pfx):
+                kwargs['port_name'] = kwargs['port_name'][len(pfx):]
+            else:
+                kwargs['port_name'] = None
+        self.__delegate = factory.get(**kwargs)
 
     def __getattr__(self, name):
         return getattr(self.__delegate, name)
index 5704f657fc3021c81f90a17f6052b852d65cb384..afe17dff503940d8ce8cfe017294912ede3aedf3 100644 (file)
@@ -37,11 +37,21 @@ ALL_PORT_NAMES = ['test', 'dryrun', 'mac', 'win', 'gtk', 'qt', 'chromium-mac',
                   'google-chrome-mac', 'google-chrome-linux32', 'google-chrome-linux64']
 
 
-def get(port_name=None, options=None):
+def get(port_name=None, options=None, **kwargs):
     """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
+    # Wrapped for backwards-compatibility
+    if port_name:
+        kwargs['port_name'] = port_name
+    if options:
+        kwargs['options'] = options
+    return _get_kwargs(**kwargs)
+
+
+def _get_kwargs(**kwargs):
+    port_to_use = kwargs.get('port_name', None)
+    options = kwargs.get('options', None)
     if port_to_use is None:
         if sys.platform == 'win32' or sys.platform == 'cygwin':
             if options and hasattr(options, 'chromium') and options.chromium:
@@ -62,37 +72,37 @@ def get(port_name=None, options=None):
 
     if port_to_use == 'test':
         import test
-        return test.TestPort(port_name, options)
+        cls = test.TestPort
     elif port_to_use.startswith('dryrun'):
         import dryrun
-        return dryrun.DryRunPort(port_name, options)
+        cls = dryrun.DryRunPort
     elif port_to_use.startswith('mac'):
         import mac
-        return mac.MacPort(port_name, options)
+        cls = mac.MacPort
     elif port_to_use.startswith('win'):
         import win
-        return win.WinPort(port_name, options)
+        cls = win.WinPort
     elif port_to_use.startswith('gtk'):
         import gtk
-        return gtk.GtkPort(port_name, options)
+        cls = gtk.GtkPort
     elif port_to_use.startswith('qt'):
         import qt
-        return qt.QtPort(port_name, options)
+        cls = qt.QtPort
     elif port_to_use.startswith('chromium-mac'):
         import chromium_mac
-        return chromium_mac.ChromiumMacPort(port_name, options)
+        cls = chromium_mac.ChromiumMacPort
     elif port_to_use.startswith('chromium-linux'):
         import chromium_linux
-        return chromium_linux.ChromiumLinuxPort(port_name, options)
+        cls = chromium_linux.ChromiumLinuxPort
     elif port_to_use.startswith('chromium-win'):
         import chromium_win
-        return chromium_win.ChromiumWinPort(port_name, options)
+        cls = chromium_win.ChromiumWinPort
     elif port_to_use.startswith('google-chrome'):
         import google_chrome
-        return google_chrome.GetGoogleChromePort(port_name, options)
-
-    raise NotImplementedError('unsupported port: %s' % port_to_use)
-
+        cls = google_chrome.GetGoogleChromePort
+    else:
+        raise NotImplementedError('unsupported port: %s' % port_to_use)
+    return cls(**kwargs)
 
 def get_all(options=None):
     """Returns all the objects implementing the Port interface."""
index 46ab3ed57a6492f9ff97803130079dbbecff751c..bffc860e22a879e6a174499b2399c6cfbd49ba2a 100644 (file)
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
-def GetGoogleChromePort(port_name, options):
+def GetGoogleChromePort(**kwargs):
     """Some tests have slightly different results when compiled as Google
     Chrome vs Chromium.  In those cases, we prepend an additional directory to
     to the baseline paths."""
+    port_name = kwargs['port_name']
+    del kwargs['port_name']
     if port_name == 'google-chrome-linux32':
         import chromium_linux
 
@@ -39,7 +41,7 @@ def GetGoogleChromePort(port_name, options):
                 paths.insert(0, self._webkit_baseline_path(
                     'google-chrome-linux32'))
                 return paths
-        return GoogleChromeLinux32Port(None, options)
+        return GoogleChromeLinux32Port(**kwargs)
     elif port_name == 'google-chrome-linux64':
         import chromium_linux
 
@@ -50,7 +52,7 @@ def GetGoogleChromePort(port_name, options):
                 paths.insert(0, self._webkit_baseline_path(
                     'google-chrome-linux64'))
                 return paths
-        return GoogleChromeLinux64Port(None, options)
+        return GoogleChromeLinux64Port(**kwargs)
     elif port_name.startswith('google-chrome-mac'):
         import chromium_mac
 
@@ -61,7 +63,7 @@ def GetGoogleChromePort(port_name, options):
                 paths.insert(0, self._webkit_baseline_path(
                     'google-chrome-mac'))
                 return paths
-        return GoogleChromeMacPort(None, options)
+        return GoogleChromeMacPort(**kwargs)
     elif port_name.startswith('google-chrome-win'):
         import chromium_win
 
@@ -72,5 +74,5 @@ def GetGoogleChromePort(port_name, options):
                 paths.insert(0, self._webkit_baseline_path(
                     'google-chrome-win'))
                 return paths
-        return GoogleChromeWinPort(None, options)
+        return GoogleChromeWinPort(**kwargs)
     raise NotImplementedError('unsupported port: %s' % port_name)
index a2d70567a02d50c25c6add8225d1c8c84633c11a..85e9338722af687de7a1ec33b6b224dc6f9ebe54 100644 (file)
@@ -41,6 +41,7 @@ class GetGoogleChromePortTest(unittest.TestCase):
         self._verify_baseline_path('google-chrome-win', 'google-chrome-win-vista')
 
     def _verify_baseline_path(self, expected_path, port_name):
-        port = google_chrome.GetGoogleChromePort(port_name, None)
+        port = google_chrome.GetGoogleChromePort(port_name=port_name,
+                                                 options=None)
         path = port.baseline_search_path()[0]
         self.assertEqual(expected_path, os.path.split(path)[1])
index 59dc1d95d56ae7485a6e7a24881a15e76dda78c1..c60909eb94ed6107532ed3ef90cd63f0bad71354 100644 (file)
@@ -39,10 +39,9 @@ _log = logging.getLogger("webkitpy.layout_tests.port.gtk")
 class GtkPort(WebKitPort):
     """WebKit Gtk implementation of the Port class."""
 
-    def __init__(self, port_name=None, options=None):
-        if port_name is None:
-            port_name = 'gtk'
-        WebKitPort.__init__(self, port_name, options)
+    def __init__(self, **kwargs):
+        kwargs.setdefault('port_name', 'gtk')
+        WebKitPort.__init__(self, **kwargs)
 
     def _tests_for_other_platforms(self):
         # FIXME: This list could be dynamic based on platform name and
index 413b5f2c35d89bb1f7c7f579c02f72574ee6098f..696e3398ea4b28ac76225907dc362ffc3fb86f9e 100644 (file)
@@ -43,10 +43,9 @@ _log = logging.getLogger("webkitpy.layout_tests.port.mac")
 class MacPort(WebKitPort):
     """WebKit Mac implementation of the Port class."""
 
-    def __init__(self, port_name=None, options=None):
-        if port_name is None:
-            port_name = 'mac' + self.version()
-        WebKitPort.__init__(self, port_name, options)
+    def __init__(self, **kwargs):
+        kwargs.setdefault('port_name', 'mac' + self.version())
+        WebKitPort.__init__(self, **kwargs)
 
     def default_child_processes(self):
         # FIXME: new-run-webkit-tests is unstable on Mac running more than
index 158c633780f1c41c37bbfea1baec6e6fdc9adec8..4c8fa0a00b67def65d08dace6404b9a33af66d0b 100644 (file)
@@ -42,10 +42,9 @@ _log = logging.getLogger("webkitpy.layout_tests.port.qt")
 class QtPort(WebKitPort):
     """QtWebKit implementation of the Port class."""
 
-    def __init__(self, port_name=None, options=None):
-        if port_name is None:
-            port_name = 'qt'
-        WebKitPort.__init__(self, port_name, options)
+    def __init__(self, **kwargs):
+        kwargs.setdefault('port_name', 'qt')
+        WebKitPort.__init__(self, **kwargs)
 
     def _tests_for_other_platforms(self):
         # FIXME: This list could be dynamic based on platform name and
index 0dfaa3d0ac619b278a3a4b79c8a3b88a24864e66..3b8116799af3cd4eea6eb1dfdb8da904cd5f9800 100644 (file)
@@ -85,8 +85,8 @@ class TestList:
 class TestPort(base.Port):
     """Test implementation of the Port interface."""
 
-    def __init__(self, port_name=None, options=None):
-        base.Port.__init__(self, port_name, options)
+    def __init__(self, **kwargs):
+        base.Port.__init__(self, **kwargs)
         tests = TestList(self)
         tests.add('passes/image.html')
         tests.add('passes/text.html')
@@ -227,9 +227,6 @@ class TestPort(base.Port):
     def setup_test_run(self):
         pass
 
-    def show_results_html_file(self, filename):
-        pass
-
     def create_driver(self, image_path, options):
         return TestDriver(self, image_path, options, executive=None)
 
index 374ef445b2d49ae54f1131fbd24fb685f9c986f9..27b6c05ae812e6f6005c00f6cb00edebe0f03950 100644 (file)
@@ -58,16 +58,16 @@ _log = logging.getLogger("webkitpy.layout_tests.port.webkit")
 class WebKitPort(base.Port):
     """WebKit implementation of the Port class."""
 
-    def __init__(self, port_name=None, options=None, **kwargs):
-        base.Port.__init__(self, port_name, options, **kwargs)
+    def __init__(self, **kwargs):
+        base.Port.__init__(self, **kwargs)
         self._cached_build_root = None
         self._cached_apache_path = None
 
         # FIXME: disable pixel tests until they are run by default on the
         # build machines.
-        if options and (not hasattr(options, "pixel_tests") or
-           options.pixel_tests is None):
-            options.pixel_tests = False
+        if self._options and (not hasattr(self._options, "pixel_tests") or
+           self._options.pixel_tests is None):
+            self._options.pixel_tests = False
 
     def baseline_path(self):
         return self._webkit_baseline_path(self._name)
@@ -186,10 +186,6 @@ class WebKitPort(base.Port):
         # This port doesn't require any specific configuration.
         pass
 
-    def show_results_html_file(self, results_filename):
-        # FIXME: We should open results in the version of WebKit we built.
-        webbrowser.open(results_filename, new=1)
-
     def create_driver(self, image_path, options):
         return WebKitDriver(self, image_path, options,
                             executive=self._executive)
index e05a69d81ab76705ee3af383ea525bd5192429b7..9e30155100077608dc71f2455a0f4fe262135d65 100644 (file)
@@ -39,10 +39,9 @@ _log = logging.getLogger("webkitpy.layout_tests.port.win")
 class WinPort(WebKitPort):
     """WebKit Win implementation of the Port class."""
 
-    def __init__(self, port_name=None, options=None):
-        if port_name is None:
-            port_name = 'win'
-        WebKitPort.__init__(self, port_name, options)
+    def __init__(self, **kwargs):
+        kwargs.setdefault('port_name', 'win')
+        WebKitPort.__init__(self, **kwargs)
 
     def baseline_search_path(self):
         # Based on code from old-run-webkit-tests expectedDirectoryForTest()
index ac3dfdebdd6bc14fa035282e392b1dfc7cd2ac5c..cdf3bca90d9871c94f502f0b3939fe0d38a69590 100644 (file)
@@ -55,9 +55,9 @@ import sys
 import tempfile
 import time
 import urllib
-import webbrowser
 import zipfile
 
+from webkitpy.common.system import user
 from webkitpy.common.system.executive import run_command, ScriptError
 import webkitpy.common.checkout.scm as scm
 
@@ -730,10 +730,7 @@ class HtmlGenerator(object):
         """Launch the rebaselining html in brwoser."""
 
         _log.info('Launching html: "%s"', self._html_file)
-
-        html_uri = self._target_port.filename_to_uri(self._html_file)
-        webbrowser.open(html_uri, 1)
-
+        user.open_url(self._html_file)
         _log.info('Html launched.')
 
     def _generate_baseline_links(self, test_basename, suffix, platform):
index fd63da9c4497a67718a35ebae98a4518c8f173fd..5193dbdcf3e3cc37b630bbdbd0f477044a9eeab2 100755 (executable)
@@ -73,6 +73,7 @@ from test_types import image_diff
 from test_types import text_diff
 from test_types import test_type_base
 
+from webkitpy.common.system import user
 from webkitpy.thirdparty import simplejson
 
 import port
index e3914e85b63d44792ef55c75de93d2f36aa8c7a5..9d48604de844cd7d4922878707e57e3265630a6a 100644 (file)
@@ -42,6 +42,7 @@ import unittest
 
 from webkitpy.common import array_stream
 from webkitpy.common.system import outputcapture
+from webkitpy.common.system import user
 from webkitpy.layout_tests import port
 from webkitpy.layout_tests import run_webkit_tests
 from webkitpy.layout_tests.layout_package import dump_render_tree_thread
@@ -49,6 +50,14 @@ from webkitpy.layout_tests.layout_package import dump_render_tree_thread
 from webkitpy.thirdparty.mock import Mock
 
 
+class MockUser():
+    def __init__(self):
+        self.url = None
+
+    def open_url(self, url):
+        self.url = url
+
+
 def passing_run(args=[], port_obj=None, record_results=False,
                 tests_included=False):
     new_args = ['--print', 'nothing']
@@ -65,7 +74,8 @@ def passing_run(args=[], port_obj=None, record_results=False,
                          'failures/expected/*'])
     options, parsed_args = run_webkit_tests.parse_args(new_args)
     if port_obj is None:
-        port_obj = port.get(options.platform, options)
+        port_obj = port.get(port_name=options.platform, options=options,
+                            user=MockUser())
     res = run_webkit_tests.run(port_obj, options, parsed_args)
     return res == 0
 
@@ -81,13 +91,14 @@ def logging_run(args=[], tests_included=False):
                          'websocket/tests',
                          'failures/expected/*'])
     options, parsed_args = run_webkit_tests.parse_args(new_args)
-    port_obj = port.get(options.platform, options)
+    user = MockUser()
+    port_obj = port.get(port_name=options.platform, options=options, user=user)
     buildbot_output = array_stream.ArrayStream()
     regular_output = array_stream.ArrayStream()
     res = run_webkit_tests.run(port_obj, options, parsed_args,
                                buildbot_output=buildbot_output,
                                regular_output=regular_output)
-    return (res, buildbot_output, regular_output)
+    return (res, buildbot_output, regular_output, user)
 
 
 class MainTest(unittest.TestCase):
@@ -99,13 +110,13 @@ class MainTest(unittest.TestCase):
         self.assertTrue(passing_run(['--batch-size', '2']))
 
     def test_child_process_1(self):
-        (res, buildbot_output, regular_output) = logging_run(
+        (res, buildbot_output, regular_output, user) = logging_run(
              ['--print', 'config', '--child-processes', '1'])
         self.assertTrue('Running one DumpRenderTree\n'
                         in regular_output.get())
 
     def test_child_processes_2(self):
-        (res, buildbot_output, regular_output) = logging_run(
+        (res, buildbot_output, regular_output, user) = logging_run(
              ['--print', 'config', '--child-processes', '2'])
         self.assertTrue('Running 2 DumpRenderTrees in parallel\n'
                         in regular_output.get())
@@ -119,15 +130,15 @@ class MainTest(unittest.TestCase):
         self.assertTrue(passing_run(['--full-results-html']))
 
     def test_help_printing(self):
-        res, out, err = logging_run(['--help-printing'])
+        res, out, err, user = logging_run(['--help-printing'])
         self.assertEqual(res, 0)
         self.assertTrue(out.empty())
         self.assertFalse(err.empty())
 
     def test_hung_thread(self):
-        res, out, err = logging_run(['--run-singly', '--time-out-ms=50',
-                                     'failures/expected/hang.html'],
-                                    tests_included=True)
+        res, out, err, user = logging_run(['--run-singly', '--time-out-ms=50',
+                                          'failures/expected/hang.html'],
+                                          tests_included=True)
         self.assertEqual(res, 0)
         self.assertFalse(out.empty())
         self.assertFalse(err.empty())
@@ -140,26 +151,27 @@ class MainTest(unittest.TestCase):
 
     def test_last_results(self):
         passing_run(['--clobber-old-results'], record_results=True)
-        (res, buildbot_output, regular_output) = logging_run(
+        (res, buildbot_output, regular_output, user) = logging_run(
             ['--print-last-failures'])
         self.assertEqual(regular_output.get(), ['\n\n'])
         self.assertEqual(buildbot_output.get(), [])
 
     def test_lint_test_files(self):
         # FIXME:  add errors?
-        res, out, err = logging_run(['--lint-test-files'], tests_included=True)
+        res, out, err, user = logging_run(['--lint-test-files'],
+                                          tests_included=True)
         self.assertEqual(res, 0)
         self.assertTrue(out.empty())
         self.assertTrue(any(['lint succeeded' in msg for msg in err.get()]))
 
     def test_no_tests_found(self):
-        res, out, err = logging_run(['resources'], tests_included=True)
+        res, out, err, user = logging_run(['resources'], tests_included=True)
         self.assertEqual(res, -1)
         self.assertTrue(out.empty())
         self.assertTrue('No tests to run.\n' in err.get())
 
     def test_no_tests_found_2(self):
-        res, out, err = logging_run(['foo'], tests_included=True)
+        res, out, err, user = logging_run(['foo'], tests_included=True)
         self.assertEqual(res, -1)
         self.assertTrue(out.empty())
         self.assertTrue('No tests to run.\n' in err.get())
@@ -196,17 +208,19 @@ class MainTest(unittest.TestCase):
         self.assertTrue(passing_run(['--test-list=%s' % filename],
                                     tests_included=True))
         os.remove(filename)
-        res, out, err = logging_run(['--test-list=%s' % filename],
-                                    tests_included=True)
+        res, out, err, user = logging_run(['--test-list=%s' % filename],
+                                          tests_included=True)
         self.assertEqual(res, -1)
         self.assertFalse(err.empty())
 
     def test_unexpected_failures(self):
         # Run tests including the unexpected failures.
-        res, out, err = logging_run(tests_included=True)
+        self._url_opened = None
+        res, out, err, user = logging_run(tests_included=True)
         self.assertEqual(res, 1)
         self.assertFalse(out.empty())
         self.assertFalse(err.empty())
+        self.assertEqual(user.url, '/tmp/layout-test-results/results.html')
 
 
 def _mocked_open(original_open, file_list):
@@ -269,6 +283,7 @@ class RebaselineTest(unittest.TestCase):
         finally:
             codecs.open = original_open
 
+
 class TestRunnerTest(unittest.TestCase):
     def test_results_html(self):
         mock_port = Mock()
@@ -306,11 +321,8 @@ class DryrunTest(unittest.TestCase):
                                      'fast/html']))
 
     def test_test(self):
-        res, out, err = logging_run(['--platform', 'dryrun-test',
-                                     '--pixel-tests'])
-        self.assertEqual(res, 0)
-        self.assertFalse(out.empty())
-        self.assertFalse(err.empty())
+        self.assertTrue(passing_run(['--platform', 'dryrun-test',
+                                           '--pixel-tests']))
 
 
 class TestThread(dump_render_tree_thread.WatchableThread):