Title: [90070] trunk/Tools
Revision
90070
Author
[email protected]
Date
2011-06-29 17:02:16 -0700 (Wed, 29 Jun 2011)

Log Message

2011-06-29  Eric Seidel  <[email protected]>

        Reviewed by Adam Barth.

        Simplify skipped file finding in preparation for adding wk2 skipped list fallback
        https://bugs.webkit.org/show_bug.cgi?id=63501

        The goal was to add support for wk2 skipped lists.
        However, I found that our skipped list computation was a
        manual hack (which only worked for the mac port).

        So I fixed a FIXME to move the skipped list finding
        into WebKitPort instead of MacPort.
        Doing so required the concept of a "port_name", since previously
        the only name accessible from a port object was name()
        which includes many things beyond "mac" or "chromium", etc.

        Eventually I believe we'll want to re-think the way that we pass
        in a port_name argument to Port subclasses and expect them to parse
        it.  But for now I just added a cls.port_name variable which contains
        the static information needed to compute wk2 names as well as
        compute Skipped list fallback which works for Mac/Win/Qt and Gtk.

        In order to test my new _skipped_file_search_paths method, I
        fixed another FIXME by making it return relative paths.

        I also fixed the test_expectations_path code in WebKitPort to use port_name.
        It was using name() which would return PORT-VERSION so MacPort was overriding
        it to use just PORT.  After fixing test_expectations_path to use port_name
        (and making it aware of webkit2) I was able to remove the MacPort implementation.

        * Scripts/webkitpy/layout_tests/port/base.py:
         - Add port_name() to access "mac", since name() returns "mac-leopard" etc.
         - Document that real_name() seems to have no purpose.
        * Scripts/webkitpy/layout_tests/port/chromium_linux.py:
         - Add _parse_port_name(), eventually we might call this from WebKitPort directly.
        * Scripts/webkitpy/layout_tests/port/chromium_mac.py:
         - Add _parse_port_name.
        * Scripts/webkitpy/layout_tests/port/chromium_win.py:
         - Add _parse_port_name.
        * Scripts/webkitpy/layout_tests/port/gtk.py:
        * Scripts/webkitpy/layout_tests/port/mac.py:
         - Move Skipped-file finding code down to WebKitPort
        * Scripts/webkitpy/layout_tests/port/mac_unittest.py:
        * Scripts/webkitpy/layout_tests/port/qt.py:
        * Scripts/webkitpy/layout_tests/port/webkit.py:
        * Scripts/webkitpy/layout_tests/port/webkit_unittest.py:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (90069 => 90070)


--- trunk/Tools/ChangeLog	2011-06-29 23:59:49 UTC (rev 90069)
+++ trunk/Tools/ChangeLog	2011-06-30 00:02:16 UTC (rev 90070)
@@ -1,3 +1,51 @@
+2011-06-29  Eric Seidel  <[email protected]>
+
+        Reviewed by Adam Barth.
+
+        Simplify skipped file finding in preparation for adding wk2 skipped list fallback
+        https://bugs.webkit.org/show_bug.cgi?id=63501
+
+        The goal was to add support for wk2 skipped lists.
+        However, I found that our skipped list computation was a
+        manual hack (which only worked for the mac port).
+
+        So I fixed a FIXME to move the skipped list finding
+        into WebKitPort instead of MacPort.
+        Doing so required the concept of a "port_name", since previously
+        the only name accessible from a port object was name()
+        which includes many things beyond "mac" or "chromium", etc.
+
+        Eventually I believe we'll want to re-think the way that we pass
+        in a port_name argument to Port subclasses and expect them to parse
+        it.  But for now I just added a cls.port_name variable which contains
+        the static information needed to compute wk2 names as well as
+        compute Skipped list fallback which works for Mac/Win/Qt and Gtk.
+
+        In order to test my new _skipped_file_search_paths method, I
+        fixed another FIXME by making it return relative paths.
+
+        I also fixed the test_expectations_path code in WebKitPort to use port_name.
+        It was using name() which would return PORT-VERSION so MacPort was overriding
+        it to use just PORT.  After fixing test_expectations_path to use port_name
+        (and making it aware of webkit2) I was able to remove the MacPort implementation.
+
+        * Scripts/webkitpy/layout_tests/port/base.py:
+         - Add port_name() to access "mac", since name() returns "mac-leopard" etc.
+         - Document that real_name() seems to have no purpose.
+        * Scripts/webkitpy/layout_tests/port/chromium_linux.py:
+         - Add _parse_port_name(), eventually we might call this from WebKitPort directly.
+        * Scripts/webkitpy/layout_tests/port/chromium_mac.py:
+         - Add _parse_port_name.
+        * Scripts/webkitpy/layout_tests/port/chromium_win.py:
+         - Add _parse_port_name.
+        * Scripts/webkitpy/layout_tests/port/gtk.py:
+        * Scripts/webkitpy/layout_tests/port/mac.py:
+         - Move Skipped-file finding code down to WebKitPort
+        * Scripts/webkitpy/layout_tests/port/mac_unittest.py:
+        * Scripts/webkitpy/layout_tests/port/qt.py:
+        * Scripts/webkitpy/layout_tests/port/webkit.py:
+        * Scripts/webkitpy/layout_tests/port/webkit_unittest.py:
+
 2011-06-29  Adam Barth  <[email protected]>
 
         Reviewed by Dirk Pranke.

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py (90069 => 90070)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py	2011-06-29 23:59:49 UTC (rev 90069)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py	2011-06-30 00:02:16 UTC (rev 90070)
@@ -66,11 +66,8 @@
 
 
 class DummyOptions(object):
-    """Fake implementation of optparse.Values. Cloned from
-    webkitpy.tool.mocktool.MockOptions.
+    """Fake implementation of optparse.Values. Cloned from webkitpy.tool.mocktool.MockOptions."""
 
-    """
-
     def __init__(self, **kwargs):
         # The caller can set option values using keyword arguments. We don't
         # set any values by default because we don't know how this
@@ -81,20 +78,21 @@
             self.__dict__[key] = value
 
 
-# FIXME: This class should merge with webkitpy.webkit_port at some point.
+# FIXME: This class should merge with webkitpy.common.config.ports.
 class Port(object):
     """Abstract class for Port-specific hooks for the layout_test package."""
 
+    port_name = None  # Subclasses override this
+
     def __init__(self, port_name=None, options=None,
                  executive=None,
                  user=None,
                  filesystem=None,
                  config=None,
                  **kwargs):
-        self._name = port_name
 
         # These are default values that should be overridden in a subclasses.
-        # FIXME: These should really be passed in.
+        self._name = port_name or self.port_name  # Subclasses may append a -VERSION (like mac-leopard) or other qualifiers.
         self._operating_system = 'mac'
         self._version = ''
         self._architecture = 'x86'
@@ -112,9 +110,8 @@
 
         self._helper = None
         self._http_server = None
-        self._webkit_base_dir = None
         self._websocket_server = None
-        self._http_lock = None
+        self._http_lock = None  # FIXME: Why does this live on the port object?
 
         # Python's Popen has a bug that causes any pipes opened to a
         # process that can't be executed to be leaked.  Since this
@@ -132,12 +129,11 @@
         self._wdiff_available = None
 
         # FIXME: prettypatch.py knows this path, why is it copied here?
-        self._pretty_patch_path = self.path_from_webkit_base("Websites",
-            "bugs.webkit.org", "PrettyPatch", "prettify.rb")
+        self._pretty_patch_path = self.path_from_webkit_base("Websites", "bugs.webkit.org", "PrettyPatch", "prettify.rb")
         self._pretty_patch_available = None
 
         self.set_option_default('configuration', self.default_configuration())
-        self._test_configuration = None
+        self._test_configuration = None  # FIXME: This does not belong on the real object.
         self._multiprocessing_is_available = (multiprocessing is not None)
         self._results_directory = None
         self.set_option_default('use_apache', self._default_to_apache())
@@ -153,8 +149,7 @@
         return self._pretty_patch_available
 
     def default_child_processes(self):
-        """Return the number of DumpRenderTree instances to use for this
-        port."""
+        """Return the number of DumpRenderTree instances to use for this port."""
         return self._executive.cpu_count()
 
     def default_worker_model(self):
@@ -163,10 +158,8 @@
         return 'threads'
 
     def baseline_path(self):
-        """Return the absolute path to the directory to store new baselines
-        in for this port."""
-        baseline_search_paths = \
-            self.get_option('additional_platform_directory', []) + self.baseline_search_path()
+        """Return the absolute path to the directory to store new baselines in for this port."""
+        baseline_search_paths = self.get_option('additional_platform_directory', []) + self.baseline_search_path()
         return baseline_search_paths[0]
 
     def baseline_search_path(self):
@@ -247,11 +240,11 @@
         return expected_text != actual_text
 
     def compare_audio(self, expected_audio, actual_audio):
+        # FIXME: If we give this method a better name it won't need this docstring (e.g. are_audio_results_equal()).
         """Return whether the two audio files are *not* equal."""
         return expected_audio != actual_audio
 
-    def diff_image(self, expected_contents, actual_contents,
-                   diff_filename=None, tolerance=0):
+    def diff_image(self, expected_contents, actual_contents, diff_filename=None, tolerance=0):
         """Compare two images and produce a delta image file.
 
         Return True if the two images are different, False if they are the same.
@@ -333,8 +326,7 @@
 
         baselines = []
         for platform_dir in baseline_search_path:
-            if self.path_exists(self._filesystem.join(platform_dir,
-                                                      baseline_filename)):
+            if self.path_exists(self._filesystem.join(platform_dir, baseline_filename)):
                 baselines.append((platform_dir, baseline_filename))
 
             if not all_baselines and baselines:
@@ -371,8 +363,8 @@
         This routine is generic but is implemented here to live alongside
         the other baseline and filename manipulation routines.
         """
-        platform_dir, baseline_filename = self.expected_baselines(
-            filename, suffix)[0]
+        # FIXME: The [0] here is very mysterious, as is the destructured return.
+        platform_dir, baseline_filename = self.expected_baselines(filename, suffix)[0]
         if platform_dir:
             return self._filesystem.join(platform_dir, baseline_filename)
         return self._filesystem.join(self.layout_tests_dir(), baseline_filename)
@@ -456,9 +448,7 @@
         return test_files.find(self, paths)
 
     def test_dirs(self):
-        """Returns the list of top-level test directories.
-
-        Used by --clobber-old-results."""
+        """Returns the list of top-level test directories."""
         layout_tests_dir = self.layout_tests_dir()
         return filter(lambda x: self._filesystem.isdir(self._filesystem.join(layout_tests_dir, x)),
                       self._filesystem.listdir(layout_tests_dir))
@@ -539,9 +529,16 @@
         self._filesystem.maybe_make_directory(*path)
 
     def name(self):
-        """Return the name of the port (e.g., 'mac', 'chromium-win-xp')."""
+        """Returns a name that uniquely identifies this particular type of port
+        (e.g., "mac-snowleopard" or "chromium-gpu-linux-x86_x64" and can be passed
+        to factory.get() to instantiate the port."""
         return self._name
 
+    def real_name(self):
+        # FIXME: Seems this is only used for MockDRT and should be removed.
+        """Returns the name of the port as passed to the --platform command line argument."""
+        return self.name()
+
     def operating_system(self):
         return self._operating_system
 
@@ -568,10 +565,6 @@
     def architecture(self):
         return self._architecture
 
-    def real_name(self):
-        """Returns the actual name of the port, not the delegate's."""
-        return self.name()
-
     def get_option(self, name, default_value=None):
         # FIXME: Eventually we should not have to do a test for
         # hasattr(), and we should be able to just do
@@ -641,8 +634,7 @@
         return self._user.open_url(results_filename)
 
     def create_driver(self, worker_number):
-        """Return a newly created base.Driver subclass for starting/stopping
-        the test driver."""
+        """Return a newly created base.Driver subclass for starting/stopping the test driver."""
         raise NotImplementedError('Port.create_driver')
 
     def start_helper(self):
@@ -876,8 +868,7 @@
         raise NotImplementedError('Port._path_to_helper')
 
     def _path_to_image_diff(self):
-        """Returns the full path to the image_diff binary, or None if it
-        is not available.
+        """Returns the full path to the image_diff binary, or None if it is not available.
 
         This is likely used only by diff_image()"""
         raise NotImplementedError('Port.path_to_image_diff')

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium.py (90069 => 90070)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium.py	2011-06-29 23:59:49 UTC (rev 90069)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium.py	2011-06-30 00:02:16 UTC (rev 90070)
@@ -53,9 +53,11 @@
 _log = logging.getLogger("webkitpy.layout_tests.port.chromium")
 
 
-# FIXME: This function doesn't belong in this package.
 class ChromiumPort(base.Port):
     """Abstract base class for Chromium implementations of the Port class."""
+
+    port_name = "chromium"
+
     ALL_BASELINE_VARIANTS = [
         'chromium-mac-snowleopard', 'chromium-mac-leopard',
         'chromium-win-win7', 'chromium-win-vista', 'chromium-win-xp',
@@ -346,8 +348,6 @@
 
 
 class ChromiumDriver(base.Driver):
-    """Abstract interface for DRT."""
-
     def __init__(self, port, worker_number):
         self._port = port
         self._worker_number = worker_number

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_linux.py (90069 => 90070)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_linux.py	2011-06-29 23:59:49 UTC (rev 90069)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_linux.py	2011-06-30 00:02:16 UTC (rev 90070)
@@ -48,7 +48,6 @@
     def __init__(self, port_name=None, **kwargs):
         port_name = port_name or 'chromium-linux'
         chromium.ChromiumPort.__init__(self, port_name=port_name, **kwargs)
-
         # We re-set the port name once the base object is fully initialized
         # in order to be able to find the DRT binary properly.
         if port_name.endswith('-linux'):

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_mac.py (90069 => 90070)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_mac.py	2011-06-29 23:59:49 UTC (rev 90069)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_mac.py	2011-06-30 00:02:16 UTC (rev 90070)
@@ -76,7 +76,7 @@
             self._version = mac.os_version(os_version_string, self.SUPPORTED_OS_VERSIONS)
             self._name = port_name + '-' + self._version
         else:
-            self._version = port_name[port_name.index('-mac-') + 5:]
+            self._version = port_name[port_name.index('-mac-') + len('-mac-'):]
             assert self._version in self.SUPPORTED_OS_VERSIONS
         self._operating_system = 'mac'
 

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win.py (90069 => 90070)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win.py	2011-06-29 23:59:49 UTC (rev 90069)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win.py	2011-06-30 00:02:16 UTC (rev 90070)
@@ -74,9 +74,8 @@
             self._version = os_version(windows_version)
             self._name = port_name + '-' + self._version
         else:
-            self._version = port_name[port_name.index('-win-') + 5:]
-            assert self._version in self.SUPPORTED_VERSIONS
-
+            self._version = port_name[port_name.index('-win-') + len('-win-'):]
+            assert self._version in self.SUPPORTED_VERSIONS, "%s is not in %s" % (self._version, self.SUPPORTED_VERSIONS)
         self._operating_system = 'win'
 
     def setup_environ_for_server(self):

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/gtk.py (90069 => 90070)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/gtk.py	2011-06-29 23:59:49 UTC (rev 90069)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/gtk.py	2011-06-30 00:02:16 UTC (rev 90070)
@@ -39,8 +39,6 @@
 
 
 class GtkDriver(webkit.WebKitDriver):
-    """WebKit Gtk implementation of the Driver class."""
-
     def start(self):
         display_id = self._worker_number + 1
         run_xvfb = ["Xvfb", ":%d" % (display_id)]
@@ -57,27 +55,20 @@
 
 
 class GtkPort(webkit.WebKitPort):
-    """WebKit Gtk implementation of the Port class."""
+    port_name = "gtk"
 
-    def __init__(self, **kwargs):
-        kwargs.setdefault('port_name', 'gtk')
-        webkit.WebKitPort.__init__(self, **kwargs)
-
     def create_driver(self, worker_number):
         return GtkDriver(self, worker_number)
 
     def _path_to_apache_config_file(self):
         # FIXME: This needs to detect the distribution and change config files.
-        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf',
-                                     'apache2-debian-httpd.conf')
+        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', 'apache2-debian-httpd.conf')
 
     def _path_to_driver(self):
         return self._build_path('Programs', self.driver_name())
 
     def check_build(self, needs_http):
-        if not self._check_driver():
-            return False
-        return True
+        return self._check_driver()
 
     def _path_to_apache(self):
         if self._is_redhat_based():
@@ -91,8 +82,7 @@
         else:
             config_name = 'apache2-debian-httpd.conf'
 
-        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf',
-                            config_name)
+        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', config_name)
 
     def _path_to_wdiff(self):
         if self._is_redhat_based():
@@ -115,7 +105,5 @@
             if os.path.isfile(full_library):
                 return full_library
 
-        return None
-
     def _runtime_feature_list(self):
         return None

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/mac.py (90069 => 90070)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/mac.py	2011-06-29 23:59:49 UTC (rev 90069)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/mac.py	2011-06-30 00:02:16 UTC (rev 90070)
@@ -48,6 +48,7 @@
     version_strings = {
         5: 'leopard',
         6: 'snowleopard',
+        # Add 7: 'lion' here?
     }
     assert release_version >= min(version_strings.keys())
     version_string = version_strings.get(release_version, 'future')
@@ -57,7 +58,8 @@
 
 
 class MacPort(WebKitPort):
-    """WebKit Mac implementation of the Port class."""
+    port_name = "mac"
+
     # FIXME: 'wk2' probably shouldn't be a version, it should probably be
     # a modifier, like 'chromium-gpu' is to 'chromium'.
     SUPPORTED_VERSIONS = ('leopard', 'snowleopard', 'future', 'wk2')
@@ -66,6 +68,7 @@
         'leopard': ['mac-leopard', 'mac-snowleopard', 'mac'],
         'snowleopard': ['mac-snowleopard', 'mac'],
         'future': ['mac'],
+        # FIXME: This isn't quite right for wk2, it should include mac-VERSION as well.
         'wk2': ['mac-wk2', 'mac'],
     }
 
@@ -76,8 +79,9 @@
             self._version = os_version(os_version_string)
             self._name = port_name + '-' + self._version
         else:
-            self._version = port_name[4:]
-            assert self._version in self.SUPPORTED_VERSIONS
+            assert port_name.startswith('mac')
+            self._version = port_name[len('mac-'):]
+            assert self._version in self.SUPPORTED_VERSIONS, "%s is not in %s" % (self._version, self.SUPPORTED_VERSIONS)
         self._operating_system = 'mac'
         if not hasattr(self._options, 'time-out-ms') or self._options.time_out_ms is None:
             self._options.time_out_ms = 35000
@@ -94,24 +98,9 @@
     def baseline_search_path(self):
         return map(self._webkit_baseline_path, self.FALLBACK_PATHS[self._version])
 
-    def path_to_test_expectations_file(self):
-        return self.path_from_webkit_base('LayoutTests', 'platform',
-           'mac', 'test_expectations.txt')
-
     def is_crash_reporter(self, process_name):
         return re.search(r'ReportCrash', process_name)
 
-    def _skipped_file_paths(self):
-        # FIXME: This method will need to be made work for non-mac
-        # platforms and moved into base.Port.
-        skipped_files = []
-        if self._name in ('mac-leopard', 'mac-snowleopard'):
-            skipped_files.append(self._filesystem.join(
-                self._webkit_baseline_path(self._name), 'Skipped'))
-        skipped_files.append(self._filesystem.join(self._webkit_baseline_path('mac'),
-                                          'Skipped'))
-        return skipped_files
-
     def _build_java_test_support(self):
         java_tests_path = self._filesystem.join(self.layout_tests_dir(), "java")
         build_java = ["/usr/bin/make", "-C", java_tests_path]
@@ -124,8 +113,7 @@
         return self._build_java_test_support()
 
     def _path_to_apache_config_file(self):
-        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf',
-                                     'apache2-httpd.conf')
+        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', 'apache2-httpd.conf')
 
     def _path_to_webcore_library(self):
         return self._build_path('WebCore.framework/Versions/A/WebCore')

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/mac_unittest.py (90069 => 90070)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/mac_unittest.py	2011-06-29 23:59:49 UTC (rev 90069)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/mac_unittest.py	2011-06-30 00:02:16 UTC (rev 90070)
@@ -40,25 +40,21 @@
             return None
         return mac.MacPort
 
-    def assert_skipped_files_for_version(self, port_name, expected_paths):
+    def assert_skipped_file_search_paths(self, port_name, expected_paths):
         port = mac.MacPort(port_name=port_name)
-        skipped_paths = port._skipped_file_paths()
-        # FIXME: _skipped_file_paths should return WebKit-relative paths.
-        # So to make it unit testable, we strip the WebKit directory from the path.
-        relative_paths = [path[len(port.path_from_webkit_base()):] for path in skipped_paths]
-        self.assertEqual(relative_paths, expected_paths)
+        self.assertEqual(port._skipped_file_search_paths(), expected_paths)
 
-    def test_skipped_file_paths(self):
-        # We skip this on win32 because we use '/' as the dir separator and it's
-        # not worth making platform-independent.
+    def test_skipped_file_search_paths(self):
+        # FIXME: This should no longer be necessary, but I'm not brave enough to remove it.
         if sys.platform == 'win32':
             return None
 
-        self.assert_skipped_files_for_version('mac-snowleopard',
-            ['/LayoutTests/platform/mac-snowleopard/Skipped', '/LayoutTests/platform/mac/Skipped'])
-        self.assert_skipped_files_for_version('mac-leopard',
-            ['/LayoutTests/platform/mac-leopard/Skipped', '/LayoutTests/platform/mac/Skipped'])
+        self.assert_skipped_file_search_paths('mac-snowleopard', set(['mac-snowleopard', 'mac']))
+        self.assert_skipped_file_search_paths('mac-leopard', set(['mac-leopard', 'mac']))
+        # We cannot test just "mac" here as the MacPort constructor automatically fills in the version from the running OS.
+        # self.assert_skipped_file_search_paths('mac', ['mac'])
 
+
     example_skipped_file = u"""
 # <rdar://problem/5647952> fast/events/mouseout-on-window.html needs mac DRT to issue mouse out events
 fast/events/mouseout-on-window.html

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/qt.py (90069 => 90070)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/qt.py	2011-06-29 23:59:49 UTC (rev 90069)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/qt.py	2011-06-30 00:02:16 UTC (rev 90070)
@@ -39,12 +39,8 @@
 
 
 class QtPort(WebKitPort):
-    """QtWebKit implementation of the Port class."""
+    port_name = "qt"
 
-    def __init__(self, **kwargs):
-        kwargs.setdefault('port_name', 'qt')
-        WebKitPort.__init__(self, **kwargs)
-
     def baseline_search_path(self):
         port_names = []
         if sys.platform.startswith('linux'):
@@ -58,8 +54,7 @@
 
     def _path_to_apache_config_file(self):
         # FIXME: This needs to detect the distribution and change config files.
-        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf',
-                                     'apache2-debian-httpd.conf')
+        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', 'apache2-debian-httpd.conf')
 
     def _build_driver(self):
         # The Qt port builds DRT as part of the main build step

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py (90069 => 90070)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py	2011-06-29 23:59:49 UTC (rev 90069)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py	2011-06-30 00:02:16 UTC (rev 90070)
@@ -36,26 +36,20 @@
 import operator
 import os
 import re
-import signal
-import sys
 import time
-import webbrowser
 
-
 from webkitpy.common.net.buildbot import BuildBot
-from webkitpy.common.system import ospath
 from webkitpy.common.system.executive import ScriptError
 from webkitpy.layout_tests.port import base, builders, server_process
 
-_log = logging.getLogger("webkitpy.layout_tests.port.webkit")
 
+_log = logging.getLogger(__file__)
 
+
 class WebKitPort(base.Port):
-    """WebKit implementation of the Port class."""
-
     def __init__(self, **kwargs):
         base.Port.__init__(self, **kwargs)
-        self._cached_apache_path = None
+        self._cached_apache_path = None  # FIXME: This class should use @memoized instead.
 
         # FIXME: disable pixel tests until they are run by default on the build machines.
         self.set_option_default("pixel_tests", False)
@@ -65,12 +59,21 @@
             return "WebKitTestRunner"
         return "DumpRenderTree"
 
+    # FIXME: This is not a very useful default implementation, as its wrong for any
+    # port which uses version-specific fallback (e.g. ['mac-leapard', 'mac']).
+    # We should replace this with a smarter implementation shared by all ports.
     def baseline_search_path(self):
-        return [self._webkit_baseline_path(self._name)]
+        search_paths = [self.name()]
+        if self.get_option('webkit_test_runner'):
+            search_paths.insert(0, self._wk2_port_name())
+        return search_paths
 
+    def _expectations_search_path(self):
+        # test_expectations are always in mac/ not mac-leopard/ by convention, hence we use port_name instead of name().
+        return self._wk2_port_name() if self.get_option('webkit_test_runner') else self.port_name
+
     def path_to_test_expectations_file(self):
-        return self._filesystem.join(self._webkit_baseline_path(self._name),
-                                     'test_expectations.txt')
+        return self._filesystem.join(self._webkit_baseline_path(self._expectations_search_path()), 'test_expectations.txt')
 
     def _results_for_platform(self, platform):
         builder_name = builders.builder_name_for_platform(platform)
@@ -284,12 +287,26 @@
             tests_to_skip.append(line)
         return tests_to_skip
 
-    def _skipped_file_paths(self):
-        return [self._filesystem.join(self._webkit_baseline_path(self._name), 'Skipped')]
+    def _wk2_port_name(self):
+        # By current convention, the WebKit2 name is always mac-wk2, win-wk2, not mac-leopard-wk2, etc.
+        return "%s-wk2" % self.port_name
 
+    def _skipped_file_search_paths(self):
+        # Unlike baseline_search_path, we only want to search [WK2-PORT, PORT-VERSION, PORT] not the full casade.
+        # Note order doesn't matter since the Skipped file contents are all combined.
+        search_paths = set([self.port_name, self.name()])
+        if self.get_option('webkit_test_runner'):
+            # Quoting old-run-webkit-tests:
+            # Because nearly all of the skipped tests for WebKit 2 on Mac are due to
+            # cross-platform issues, the Windows and Qt ports use the Mac skipped list
+            # additionally to their own to avoid maintaining separate lists.
+            search_paths.update([self._wk2_port_name(), "mac-wk2"])
+        return search_paths
+
     def _expectations_from_skipped_files(self):
         tests_to_skip = []
-        for filename in self._skipped_file_paths():
+        for search_path in self._skipped_file_search_paths():
+            filename = self._filesystem.join(self._webkit_baseline_path(search_path), "Skipped")
             if not self._filesystem.exists(filename):
                 _log.warn("Failed to open Skipped file: %s" % filename)
                 continue
@@ -298,12 +315,14 @@
         return tests_to_skip
 
     def test_expectations(self):
-        # The WebKit mac port uses a combination of a test_expectations file
-        # and 'Skipped' files.
+        # This allows ports to use a combination of test_expectations.txt files and Skipped lists.
+        expectations = self._skipped_list_as_expectations()
         expectations_path = self.path_to_test_expectations_file()
-        return self._filesystem.read_text_file(expectations_path) + self._skips()
+        if self._filesystem.exists(expectations_path):
+            expectations = self._filesystem.read_text_file(expectations_path) + expectations
+        return expectations
 
-    def _skips(self):
+    def _skipped_list_as_expectations(self):
         # Each Skipped file contains a list of files
         # or directories to be skipped during the test run. The total list
         # of tests to skipped is given by the contents of the generic
@@ -313,8 +332,7 @@
         # format expected by test_expectations.
 
         tests_to_skip = self.skipped_layout_tests()
-        skip_lines = map(lambda test_path: "BUG_SKIPPED SKIP : %s = FAIL" %
-                                test_path, tests_to_skip)
+        skip_lines = map(lambda test_path: "BUG_SKIPPED SKIP : %s = FAIL" % test_path, tests_to_skip)
         return "\n".join(skip_lines)
 
     def skipped_layout_tests(self):

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit_unittest.py (90069 => 90070)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit_unittest.py	2011-06-29 23:59:49 UTC (rev 90069)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit_unittest.py	2011-06-30 00:02:16 UTC (rev 90070)
@@ -37,6 +37,8 @@
 
 
 class TestWebKitPort(WebKitPort):
+    port_name = "testwebkitport"
+
     def __init__(self, symbol_list=None, feature_list=None,
                  expectations_file=None, skips_file=None,
                  executive=None, filesystem=None, user=None,
@@ -46,7 +48,7 @@
         executive = executive or MockExecutive(should_log=False)
         filesystem = filesystem or MockFileSystem()
         user = user or MockUser()
-        WebKitPort.__init__(self, port_name="testwebkitport", executive=executive, filesystem=filesystem, user=MockUser(), **kwargs)
+        WebKitPort.__init__(self, executive=executive, filesystem=filesystem, user=MockUser(), **kwargs)
 
     def _runtime_feature_list(self):
         return self.feature_list
@@ -89,6 +91,14 @@
     def test_skipped_layout_tests(self):
         self.assertEqual(TestWebKitPort(None, None).skipped_layout_tests(), set(["media"]))
 
+    def test_skipped_file_search_paths(self):
+        port = TestWebKitPort()
+        self.assertEqual(port._skipped_file_search_paths(), set(['testwebkitport']))
+        port._name = "testwebkitport-version"
+        self.assertEqual(port._skipped_file_search_paths(), set(['testwebkitport', 'testwebkitport-version']))
+        port._options = MockOptions(webkit_test_runner=True)
+        self.assertEqual(port._skipped_file_search_paths(), set(['testwebkitport', 'testwebkitport-version', 'testwebkitport-wk2', 'mac-wk2']))
+
     def test_test_expectations(self):
         # Check that we read both the expectations file and anything in a
         # Skipped file, and that we include the feature and platform checks.

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/win.py (90069 => 90070)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/win.py	2011-06-29 23:59:49 UTC (rev 90069)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/win.py	2011-06-30 00:02:16 UTC (rev 90070)
@@ -32,23 +32,21 @@
 
 from webkitpy.layout_tests.port.webkit import WebKitPort
 
-_log = logging.getLogger("webkitpy.layout_tests.port.win")
+_log = logging.getLogger(__file__)
 
 
 class WinPort(WebKitPort):
-    """WebKit Win implementation of the Port class."""
+    port_name = "win"
 
-    def __init__(self, port_name=None, **kwargs):
-        port_name = port_name or 'win'
-        WebKitPort.__init__(self, port_name=port_name, **kwargs)
+    def __init__(self, **kwargs):
+        WebKitPort.__init__(self, **kwargs)
         self._version = 'win7'
         self._operating_system = 'win'
 
     def baseline_search_path(self):
         # Based on code from old-run-webkit-tests expectedDirectoryForTest()
-        port_names = ["win", "mac-snowleopard", "mac"]
-        return map(self._webkit_baseline_path, port_names)
+        search_paths = ["win", "mac-snowleopard", "mac"]
+        return map(self._webkit_baseline_path, search_paths)
 
     def _path_to_apache_config_file(self):
-        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf',
-                                     'cygwin-httpd.conf')
+        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', 'cygwin-httpd.conf')

Modified: trunk/Tools/Scripts/webkitpy/tool/commands/rebaselineserver_unittest.py (90069 => 90070)


--- trunk/Tools/Scripts/webkitpy/tool/commands/rebaselineserver_unittest.py	2011-06-29 23:59:49 UTC (rev 90069)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/rebaselineserver_unittest.py	2011-06-30 00:02:16 UTC (rev 90070)
@@ -291,6 +291,7 @@
         mock_filesystem.files[file_path] = ''
 
     class TestMacPort(WebKitPort):
+        port_name = 'testmacport'
         def __init__(self):
             # FIXME: This should use MockExecutive and MockUser as well.
             WebKitPort.__init__(self, filesystem=mock_filesystem)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to