Diff
Modified: trunk/Tools/ChangeLog (104229 => 104230)
--- trunk/Tools/ChangeLog 2012-01-05 23:04:25 UTC (rev 104229)
+++ trunk/Tools/ChangeLog 2012-01-05 23:07:33 UTC (rev 104230)
@@ -1,3 +1,37 @@
+2012-01-05 Dirk Pranke <[email protected]>
+
+ webkitpy: clean up port factory methods
+ https://bugs.webkit.org/show_bug.cgi?id=75590
+
+ Reviewed by Eric Seidel.
+
+ This change consolidates much of the "factory method" logic
+ of determining which port objects to create for a given set
+ of configurations by merging the separate factory methods in
+ chromium_gpu and google_chrome into PortFactory so that at least
+ all of the logic is in one place.
+
+ * Scripts/webkitpy/layout_tests/port/chromium_gpu.py:
+ * Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py:
+ * Scripts/webkitpy/layout_tests/port/factory.py:
+ (_port_name_from_arguments_and_options):
+ (get):
+ * Scripts/webkitpy/layout_tests/port/factory_unittest.py:
+ (test_google_chrome):
+ * Scripts/webkitpy/layout_tests/port/google_chrome.py:
+ (GoogleChromeLinux32Port):
+ (GoogleChromeLinux32Port.baseline_search_path):
+ (test_expectations_overrides):
+ (architecture):
+ (GoogleChromeLinux64Port):
+ (GoogleChromeLinux64Port.baseline_search_path):
+ (GoogleChromeMacPort):
+ (GoogleChromeMacPort.baseline_search_path):
+ (GoogleChromeWinPort):
+ (GoogleChromeWinPort.baseline_search_path):
+ * Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py:
+ (_verify_baseline_path):
+
2012-01-05 Jochen Eisinger <[email protected]>
Replace webkitpy.common.system.filesystem.file_path_as_url with webkitpy.common.system.path.abspath_to_uri
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_gpu.py (104229 => 104230)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_gpu.py 2012-01-05 23:04:25 UTC (rev 104229)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_gpu.py 2012-01-05 23:07:33 UTC (rev 104230)
@@ -31,34 +31,8 @@
import chromium_win
-def get(host, platform=None, port_name='chromium-gpu', **kwargs):
- """Some tests have slightly different results when run while using
- hardware acceleration. In those cases, we prepend an additional directory
- to the baseline paths."""
- platform = platform or sys.platform
- if port_name == 'chromium-gpu':
- if platform in ('cygwin', 'win32'):
- port_name = 'chromium-gpu-win'
- elif platform.startswith('linux'):
- port_name = 'chromium-gpu-linux'
- elif platform == 'darwin':
- port_name = 'chromium-gpu-mac'
- else:
- raise NotImplementedError('unsupported platform: %s' % platform)
+# FIXME: This whole file needs to go away and we need to eliminate the GPU configuration.
- if port_name.startswith('chromium-gpu-linux'):
- return ChromiumGpuLinuxPort(host, port_name=port_name, **kwargs)
- if port_name.startswith('chromium-gpu-cg-mac'):
- return ChromiumGpuCgMacPort(host, port_name=port_name, **kwargs)
- if port_name.startswith('chromium-gpu-mac'):
- return ChromiumGpuMacPort(host, port_name=port_name, **kwargs)
- if port_name.startswith('chromium-gpu-win'):
- return ChromiumGpuWinPort(host, port_name=port_name, **kwargs)
- raise NotImplementedError('unsupported port: %s' % port_name)
-
-
-# FIXME: These should really be a mixin class.
-
def _set_gpu_options(port, graphics_type='gpu'):
port._graphics_type = graphics_type
if port.get_option('accelerated_2d_canvas') is None:
@@ -90,7 +64,7 @@
paths += ['fast/canvas', 'canvas/philip']
if not paths:
- # FIXME: This is a hack until we can turn of the webkit_gpu
+ # FIXME: This is a hack until we can turn off the webkit_gpu
# tests on the bots. If paths is empty, port.tests()
# finds *everything*. However, we have to return something,
# or NRWT thinks there's something wrong. So, we return a single
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py (104229 => 104230)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py 2012-01-05 23:04:25 UTC (rev 104229)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py 2012-01-05 23:07:33 UTC (rev 104230)
@@ -27,12 +27,12 @@
import sys
import unittest
-import chromium_gpu
-
-from webkitpy.tool.mocktool import MockOptions
from webkitpy.common.host_mock import MockHost
+from webkitpy.common.system.filesystem_mock import MockFileSystem
+from webkitpy.layout_tests.port import chromium_gpu
from webkitpy.layout_tests.port import port_testcase
-from webkitpy.common.system.filesystem_mock import MockFileSystem
+from webkitpy.layout_tests.port.factory import PortFactory
+from webkitpy.tool.mocktool import MockOptions
class ChromiumGpuTest(unittest.TestCase):
@@ -62,9 +62,9 @@
builder_name='foo',
child_processes=None)
if input_name and platform:
- port = chromium_gpu.get(host, platform=platform, port_name=input_name, options=mock_options)
+ port = PortFactory(host).get(host, platform=platform, port_name=input_name, options=mock_options)
else:
- port = chromium_gpu.get(host, port_name=port_name, options=mock_options)
+ port = PortFactory(host).get(host, port_name=port_name, options=mock_options)
self.assertTrue(port._options.accelerated_2d_canvas)
self.assertTrue(port._options.accelerated_video)
self.assertTrue(port._options.experimental_fully_parallel)
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/factory.py (104229 => 104230)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/factory.py 2012-01-05 23:04:25 UTC (rev 104229)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/factory.py 2012-01-05 23:07:33 UTC (rev 104230)
@@ -45,31 +45,38 @@
def __init__(self, host):
self._host = host
- def _port_name_from_arguments_and_options(self, **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:
- port_to_use = 'chromium-win'
- else:
- port_to_use = 'win'
- elif sys.platform.startswith('linux'):
- port_to_use = 'chromium-linux'
- elif sys.platform == 'darwin':
- if options and hasattr(options, 'chromium') and options.chromium:
- port_to_use = 'chromium-cg-mac'
- # FIXME: Add a way to select the chromium-mac port.
- else:
- port_to_use = 'mac'
+ def _port_name_from_arguments_and_options(self, port_name, options, platform):
+ if port_name == 'chromium-gpu':
+ if platform in ('cygwin', 'win32'):
+ return 'chromium-gpu-win'
+ if platform.startswith('linux'):
+ return 'chromium-gpu-linux'
+ if platform == 'darwin':
+ return 'chromium-gpu-mac'
- if port_to_use is None:
- raise NotImplementedError('unknown port; sys.platform = "%s"' % sys.platform)
- return port_to_use
+ if port_name:
+ return port_name
- def _get_kwargs(self, **kwargs):
- port_to_use = self._port_name_from_arguments_and_options(**kwargs)
+ if platform in ('win32', 'cygwin'):
+ if options and hasattr(options, 'chromium') and options.chromium:
+ return 'chromium-win'
+ return 'win'
+ if platform.startswith('linux'):
+ return 'chromium-linux'
+ if platform == 'darwin':
+ if options and hasattr(options, 'chromium') and options.chromium:
+ return 'chromium-cg-mac'
+ # FIXME: Add a way to select the chromium-mac port.
+ return 'mac'
+ raise NotImplementedError('unknown port; platform = "%s"' % platform)
+
+ def get(self, port_name=None, options=None, platform=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."""
+ platform = platform or sys.platform
+ port_to_use = self._port_name_from_arguments_and_options(port_name, options, platform)
if port_to_use.startswith('test'):
import test
maker = test.TestPort
@@ -91,11 +98,25 @@
elif port_to_use.startswith('qt'):
import qt
maker = qt.QtPort
- elif port_to_use.startswith('chromium-gpu'):
+ elif port_to_use.startswith('chromium-gpu-linux'):
import chromium_gpu
- maker = chromium_gpu.get
+ port_name = port_to_use
+ maker = chromium_gpu.ChromiumGpuLinuxPort
+ elif port_to_use.startswith('chromium-gpu-cg-mac'):
+ import chromium_gpu
+ port_name = port_to_use
+ maker = chromium_gpu.ChromiumGpuCgMacPort
+ elif port_to_use.startswith('chromium-gpu-mac'):
+ import chromium_gpu
+ port_name = port_to_use
+ maker = chromium_gpu.ChromiumGpuMacPort
+ elif port_to_use.startswith('chromium-gpu-win'):
+ import chromium_gpu
+ port_name = port_to_use
+ maker = chromium_gpu.ChromiumGpuWinPort
elif port_to_use.startswith('chromium-mac') or port_to_use.startswith('chromium-cg-mac'):
import chromium_mac
+ port_name = port_to_use
maker = chromium_mac.ChromiumMacPort
elif port_to_use.startswith('chromium-linux'):
import chromium_linux
@@ -103,16 +124,27 @@
elif port_to_use.startswith('chromium-win'):
import chromium_win
maker = chromium_win.ChromiumWinPort
- elif port_to_use.startswith('google-chrome'):
+ elif port_to_use == 'google-chrome-linux32':
import google_chrome
- maker = google_chrome.GetGoogleChromePort
+ port_name = 'chromium-linux-x86'
+ maker = google_chrome.GoogleChromeLinux32Port
+ elif port_to_use == 'google-chrome-linux64':
+ import google_chrome
+ port_name = 'chromium-linux-x86_64'
+ maker = google_chrome.GoogleChromeLinux64Port
+ elif port_to_use.startswith('google-chrome-win'):
+ import google_chrome
+ maker = google_chrome.GoogleChromeWinPort
+ elif port_to_use.startswith('google-chrome-mac'):
+ import google_chrome
+ maker = google_chrome.GoogleChromeMacPort
elif port_to_use.startswith('efl'):
import efl
maker = efl.EflPort
else:
raise NotImplementedError('unsupported port: %s' % port_to_use)
- return maker(self._host, **kwargs)
+ return maker(self._host, port_name=port_name, options=options, **kwargs)
def all_port_names(self):
"""Return a list of all valid, fully-specified, "real" port names.
@@ -123,17 +155,6 @@
# FIXME: There's probably a better way to generate this list ...
return builders.all_port_names()
- def get(self, 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."""
- # Wrapped for backwards-compatibility
- if port_name:
- kwargs['port_name'] = port_name
- if options:
- kwargs['options'] = options
- return self._get_kwargs(**kwargs)
-
def get_from_builder_name(self, builder_name):
port_name = builders.port_name_for_builder_name(builder_name)
assert(port_name) # Need to update port_name_for_builder_name
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/factory_unittest.py (104229 => 104230)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/factory_unittest.py 2012-01-05 23:04:25 UTC (rev 104229)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/factory_unittest.py 2012-01-05 23:07:33 UTC (rev 104230)
@@ -64,7 +64,7 @@
def tearDown(self):
sys.platform = self.real_sys_platform
- def assert_port(self, port_name, expected_port, port_obj=None):
+ def assert_port(self, port_name, expected_port, port_obj=None, platform=None):
"""Helper assert for port_name.
Args:
@@ -72,7 +72,7 @@
expected_port: class of expected port object.
port_obj: optional port object
"""
- port_obj = port_obj or self.factory.get(port_name=port_name)
+ port_obj = port_obj or self.factory.get(port_name=port_name, platform=platform)
self.assertTrue(isinstance(port_obj, expected_port))
def assert_platform_port(self, platform, options, expected_port):
@@ -104,12 +104,10 @@
self.assert_platform_port("cygwin", self.webkit_options, win.WinPort)
def test_google_chrome(self):
- # The actual Chrome class names aren't available so we test that the
- # objects we get are at least subclasses of the Chromium versions.
- self.assert_port("google-chrome-linux32", chromium_linux.ChromiumLinuxPort)
- self.assert_port("google-chrome-linux64", chromium_linux.ChromiumLinuxPort)
- self.assert_port("google-chrome-win", chromium_win.ChromiumWinPort)
- self.assert_port("google-chrome-mac", chromium_mac.ChromiumMacPort)
+ self.assert_port("google-chrome-linux32", google_chrome.GoogleChromeLinux32Port)
+ self.assert_port("google-chrome-linux64", google_chrome.GoogleChromeLinux64Port)
+ self.assert_port("google-chrome-win", google_chrome.GoogleChromeWinPort)
+ self.assert_port("google-chrome-mac", google_chrome.GoogleChromeMacPort)
def test_gtk(self):
self.assert_port("gtk", gtk.GtkPort)
@@ -117,6 +115,13 @@
def test_qt(self):
self.assert_port("qt", qt.QtPort)
+ def test_chromium_gpu(self):
+ self.assert_port('chromium-gpu', chromium_gpu.ChromiumGpuMacPort, platform='darwin')
+ self.assert_port('chromium-gpu', chromium_gpu.ChromiumGpuWinPort, platform='win32')
+ self.assert_port('chromium-gpu', chromium_gpu.ChromiumGpuWinPort, platform='cygwin')
+ self.assert_port('chromium-gpu', chromium_gpu.ChromiumGpuLinuxPort, platform='linux2')
+ self.assert_port('chromium-gpu', chromium_gpu.ChromiumGpuLinuxPort, platform='linux3')
+
def test_chromium_gpu_linux(self):
self.assert_port("chromium-gpu-linux", chromium_gpu.ChromiumGpuLinuxPort)
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/google_chrome.py (104229 => 104230)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/google_chrome.py 2012-01-05 23:04:25 UTC (rev 104229)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/google_chrome.py 2012-01-05 23:07:33 UTC (rev 104230)
@@ -24,7 +24,11 @@
# (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 chromium_linux
+import chromium_mac
+import chromium_win
+
def _test_expectations_overrides(port, super):
# The chrome ports use the regular overrides plus anything in the
# official test_expectations as well. Hopefully we don't get collisions.
@@ -42,70 +46,47 @@
return chromium_overrides + port._filesystem.read_text_file(overrides_path)
-def GetGoogleChromePort(host, **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."""
- # FIXME: This whole routine is a tremendous hack that needs to be cleaned up.
+class GoogleChromeLinux32Port(chromium_linux.ChromiumLinuxPort):
+ def baseline_search_path(self):
+ paths = chromium_linux.ChromiumLinuxPort.baseline_search_path(self)
+ paths.insert(0, self._webkit_baseline_path('google-chrome-linux32'))
+ return paths
- port_name = kwargs['port_name']
- del kwargs['port_name']
- if port_name == 'google-chrome-linux32':
- import chromium_linux
+ def test_expectations_overrides(self):
+ return _test_expectations_overrides(self, chromium_linux.ChromiumLinuxPort)
- class GoogleChromeLinux32Port(chromium_linux.ChromiumLinuxPort):
- def baseline_search_path(self):
- paths = chromium_linux.ChromiumLinuxPort.baseline_search_path(self)
- paths.insert(0, self._webkit_baseline_path('google-chrome-linux32'))
- return paths
+ def architecture(self):
+ return 'x86'
- def test_expectations_overrides(self):
- return _test_expectations_overrides(self, chromium_linux.ChromiumLinuxPort)
- def architecture(self):
- return 'x86'
+class GoogleChromeLinux64Port(chromium_linux.ChromiumLinuxPort):
+ def baseline_search_path(self):
+ paths = chromium_linux.ChromiumLinuxPort.baseline_search_path(self)
+ paths.insert(0, self._webkit_baseline_path('google-chrome-linux64'))
+ return paths
- return GoogleChromeLinux32Port(host, port_name='chromium-linux-x86', **kwargs)
- elif port_name == 'google-chrome-linux64':
- import chromium_linux
+ def test_expectations_overrides(self):
+ return _test_expectations_overrides(self, chromium_linux.ChromiumLinuxPort)
- class GoogleChromeLinux64Port(chromium_linux.ChromiumLinuxPort):
- def baseline_search_path(self):
- paths = chromium_linux.ChromiumLinuxPort.baseline_search_path(self)
- paths.insert(0, self._webkit_baseline_path('google-chrome-linux64'))
- return paths
+ def architecture(self):
+ return 'x86_64'
- def test_expectations_overrides(self):
- return _test_expectations_overrides(self, chromium_linux.ChromiumLinuxPort)
- def architecture(self):
- return 'x86_64'
+class GoogleChromeMacPort(chromium_mac.ChromiumMacPort):
+ def baseline_search_path(self):
+ paths = chromium_mac.ChromiumMacPort.baseline_search_path(self)
+ paths.insert(0, self._webkit_baseline_path('google-chrome-mac'))
+ return paths
- return GoogleChromeLinux64Port(host, port_name='chromium-linux-x86_64', **kwargs)
- elif port_name.startswith('google-chrome-mac'):
- import chromium_mac
+ def test_expectations_overrides(self):
+ return _test_expectations_overrides(self, chromium_mac.ChromiumMacPort)
- class GoogleChromeMacPort(chromium_mac.ChromiumMacPort):
- def baseline_search_path(self):
- paths = chromium_mac.ChromiumMacPort.baseline_search_path(self)
- paths.insert(0, self._webkit_baseline_path('google-chrome-mac'))
- return paths
- def test_expectations_overrides(self):
- return _test_expectations_overrides(self, chromium_mac.ChromiumMacPort)
+class GoogleChromeWinPort(chromium_win.ChromiumWinPort):
+ def baseline_search_path(self):
+ paths = chromium_win.ChromiumWinPort.baseline_search_path(self)
+ paths.insert(0, self._webkit_baseline_path('google-chrome-win'))
+ return paths
- return GoogleChromeMacPort(host, **kwargs)
- elif port_name.startswith('google-chrome-win'):
- import chromium_win
-
- class GoogleChromeWinPort(chromium_win.ChromiumWinPort):
- def baseline_search_path(self):
- paths = chromium_win.ChromiumWinPort.baseline_search_path(self)
- paths.insert(0, self._webkit_baseline_path('google-chrome-win'))
- return paths
-
- def test_expectations_overrides(self):
- return _test_expectations_overrides(self, chromium_win.ChromiumWinPort)
-
- return GoogleChromeWinPort(host, **kwargs)
- raise NotImplementedError('unsupported port: %s' % port_name)
+ def test_expectations_overrides(self):
+ return _test_expectations_overrides(self, chromium_win.ChromiumWinPort)
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py (104229 => 104230)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py 2012-01-05 23:04:25 UTC (rev 104229)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py 2012-01-05 23:07:33 UTC (rev 104230)
@@ -27,7 +27,6 @@
import unittest
from webkitpy.common.host_mock import MockHost
-from webkitpy.layout_tests.port import google_chrome
class GetGoogleChromePortTest(unittest.TestCase):
@@ -42,7 +41,7 @@
self._verify_baseline_path('google-chrome-win', 'google-chrome-win-vista')
def _verify_baseline_path(self, expected_path, port_name):
- port = google_chrome.GetGoogleChromePort(MockHost(), port_name=port_name)
+ port = MockHost().port_factory.get(port_name=port_name)
path = port.baseline_search_path()[0]
self.assertEqual(expected_path, port._filesystem.basename(path))
@@ -55,7 +54,7 @@
host = MockHost()
chromium_port = host.port_factory.get("chromium-cg-mac")
chromium_base = chromium_port.path_from_chromium_base()
- port = google_chrome.GetGoogleChromePort(host, port_name=port_name, options=None)
+ port = host.port_factory.get(port_name=port_name, options=None)
expected_chromium_overrides = '// chromium overrides\n'
expected_chrome_overrides = '// chrome overrides\n'