Skip to content
Permalink
Browse files
Make Port subclasses override the operating_system method rather than…
… setting an attribute

Without this patch, any use of Port.operating_system() within a port's __init__ method would
return the default value ("mac"). This was confusing the version-checking logic inside
ApplePort.__init__ on Windows.

Fixes <http://webkit.org/b/75479> <rdar://problem/10637385> REGRESSION (r102161): NRWT
crashes on launch on Windows 7 SP1

Reviewed by Eric Seidel.

* Scripts/webkitpy/layout_tests/port/apple.py:
(ApplePort.__init__): Replaced uses of self._operating_system with self.operating_system().

* Scripts/webkitpy/layout_tests/port/base.py:
(Port.__init__): Removed code that set the self._operating_system attribute. Subclasses
should now override the operating_system method instead.
(Port.operating_system): Changed to always return "mac". Subclasses should override to
return something else.

* Scripts/webkitpy/layout_tests/port/chromium_linux.py:
(ChromiumLinuxPort.__init__):
(ChromiumLinuxPort.operating_system):
* Scripts/webkitpy/layout_tests/port/chromium_mac.py:
(ChromiumMacPort.__init__):
(ChromiumMacPort.operating_system):
* Scripts/webkitpy/layout_tests/port/chromium_win.py:
(ChromiumWinPort.__init__):
(ChromiumWinPort.operating_system):
* Scripts/webkitpy/layout_tests/port/mac.py:
(MacPort.__init__):
(MacPort.operating_system):
* Scripts/webkitpy/layout_tests/port/win.py:
(WinPort.__init__):
(WinPort.operating_system):
Changed to override the operating_system method rather than setting the _operating_system
attribute, since setting the attribute isn't sufficient for code inside __init__ methods.

* Scripts/webkitpy/layout_tests/port/qt.py:
(QtPort.__init__):
(QtPort._path_to_webcore_library):
Changed to use self.operating_system() instead of self._operating_system, for consistency
with other Port-related code.

(QtPort.operating_system): Added this override of Port.operating_system that returns the
value we determined in our __init__ method.

* Scripts/webkitpy/layout_tests/port/test.py:
(TestPort.operating_system): Added this override of Port.operating_system that returns the
value we determined in our __init__ method.

* Scripts/webkitpy/layout_tests/port/base_unittest.py:
(PortTest.test_operating_system):
* Scripts/webkitpy/layout_tests/port/chromium_linux_unittest.py:
(ChromiumLinuxPortTest.test_operating_system):
* Scripts/webkitpy/layout_tests/port/chromium_mac_unittest.py:
(ChromiumMacPortTest.test_operating_system):
* Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py:
(ChromiumWinPortTest.test_operating_system):
* Scripts/webkitpy/layout_tests/port/mac_unittest.py:
(MacPortTest.test_operating_system):
* Scripts/webkitpy/layout_tests/port/qt_unittest.py:
(QtPortTest.test_operating_system):
* Scripts/webkitpy/layout_tests/port/win_unittest.py:
(WinPortTest.test_operating_system):
Test that all ports return the expected operating system string.

Canonical link: https://commits.webkit.org/92249@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@103952 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
aroben committed Jan 3, 2012
1 parent 18dd051 commit e8d40781d2358d9ec974580113f313bf14afff17
@@ -1,3 +1,72 @@
2012-01-03 Adam Roben <aroben@apple.com>

Make Port subclasses override the operating_system method rather than setting an attribute

Without this patch, any use of Port.operating_system() within a port's __init__ method would
return the default value ("mac"). This was confusing the version-checking logic inside
ApplePort.__init__ on Windows.

Fixes <http://webkit.org/b/75479> <rdar://problem/10637385> REGRESSION (r102161): NRWT
crashes on launch on Windows 7 SP1

Reviewed by Eric Seidel.

* Scripts/webkitpy/layout_tests/port/apple.py:
(ApplePort.__init__): Replaced uses of self._operating_system with self.operating_system().

* Scripts/webkitpy/layout_tests/port/base.py:
(Port.__init__): Removed code that set the self._operating_system attribute. Subclasses
should now override the operating_system method instead.
(Port.operating_system): Changed to always return "mac". Subclasses should override to
return something else.

* Scripts/webkitpy/layout_tests/port/chromium_linux.py:
(ChromiumLinuxPort.__init__):
(ChromiumLinuxPort.operating_system):
* Scripts/webkitpy/layout_tests/port/chromium_mac.py:
(ChromiumMacPort.__init__):
(ChromiumMacPort.operating_system):
* Scripts/webkitpy/layout_tests/port/chromium_win.py:
(ChromiumWinPort.__init__):
(ChromiumWinPort.operating_system):
* Scripts/webkitpy/layout_tests/port/mac.py:
(MacPort.__init__):
(MacPort.operating_system):
* Scripts/webkitpy/layout_tests/port/win.py:
(WinPort.__init__):
(WinPort.operating_system):
Changed to override the operating_system method rather than setting the _operating_system
attribute, since setting the attribute isn't sufficient for code inside __init__ methods.

* Scripts/webkitpy/layout_tests/port/qt.py:
(QtPort.__init__):
(QtPort._path_to_webcore_library):
Changed to use self.operating_system() instead of self._operating_system, for consistency
with other Port-related code.

(QtPort.operating_system): Added this override of Port.operating_system that returns the
value we determined in our __init__ method.

* Scripts/webkitpy/layout_tests/port/test.py:
(TestPort.operating_system): Added this override of Port.operating_system that returns the
value we determined in our __init__ method.

* Scripts/webkitpy/layout_tests/port/base_unittest.py:
(PortTest.test_operating_system):
* Scripts/webkitpy/layout_tests/port/chromium_linux_unittest.py:
(ChromiumLinuxPortTest.test_operating_system):
* Scripts/webkitpy/layout_tests/port/chromium_mac_unittest.py:
(ChromiumMacPortTest.test_operating_system):
* Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py:
(ChromiumWinPortTest.test_operating_system):
* Scripts/webkitpy/layout_tests/port/mac_unittest.py:
(MacPortTest.test_operating_system):
* Scripts/webkitpy/layout_tests/port/qt_unittest.py:
(QtPortTest.test_operating_system):
* Scripts/webkitpy/layout_tests/port/win_unittest.py:
(WinPortTest.test_operating_system):
Test that all ports return the expected operating system string.

2012-01-03 Mario Sanchez Prada <msanchez@igalia.com>

[GTK] run-gtk-test should ignore files with names without a "test" or "Test" prefix
@@ -70,7 +70,7 @@ def __init__(self, host, port_name=None, os_version_string=None, **kwargs):
self._version = self._detect_version(os_version_string) or self.FUTURE_VERSION
self._name = self.port_name + '-' + self._version
else:
allowed_port_names = self.VERSION_FALLBACK_ORDER + [self._operating_system + "-future"]
allowed_port_names = self.VERSION_FALLBACK_ORDER + [self.operating_system() + "-future"]
assert port_name in allowed_port_names, "%s is not in %s" % (port_name, allowed_port_names)
self._version = self._strip_port_name_prefix(port_name)

@@ -92,7 +92,6 @@ def __init__(self, host, port_name=None, options=None, config=None, **kwargs):

# These are default values that should be overridden in a subclasses.
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'
self._graphics_type = 'cpu'
@@ -635,7 +634,8 @@ def real_name(self):
return self.name()

def operating_system(self):
return self._operating_system
# Subclasses should override this default implementation.
return 'mac'

def version(self):
"""Returns a string indicating the version of a given platform, e.g.
@@ -348,6 +348,9 @@ def test_parse_reftest_list(self):
'bar/test-2.html': [('!=', 'bar/test-notref.html')],
'bar/test-3.html': [('==', 'bar/test-ref.html'), ('==', 'bar/test-ref2.html'), ('!=', 'bar/test-notref.html')]})

def test_operating_system(self):
self.assertEqual('mac', self.make_port().operating_system())


class VirtualTest(unittest.TestCase):
"""Tests that various methods expected to be virtual are."""
@@ -74,7 +74,6 @@ def __init__(self, host, port_name=None, **kwargs):
'chromium-linux-x86', 'chromium-linux-x86_64',
'chromium-gpu-linux-x86_64')
self._name = port_name
self._operating_system = 'linux'
self._version = 'lucid' # We only support lucid right now.

def _determine_architecture(self):
@@ -111,6 +110,9 @@ def check_build(self, needs_http):
_log.error(' http://code.google.com/p/chromium/wiki/LinuxBuildInstructions')
return result

def operating_system(self):
return 'linux'

#
# PROTECTED METHODS
#
@@ -86,6 +86,9 @@ def test_determine_architecture_fails(self):
host.executive = executive_mock.MockExecutive2(exception=AssertionError)
self.assertRaises(AssertionError, chromium_linux.ChromiumLinuxPort, host)

def test_operating_system(self):
self.assertEqual('linux', self.make_port().operating_system())


if __name__ == '__main__':
port_testcase.main()
@@ -125,7 +125,6 @@ def __init__(self, host, port_name=None, os_version_string=None, **kwargs):
self._graphics_type = 'cpu-cg'
else:
self._graphics_type = 'cpu'
self._operating_system = 'mac'

def baseline_search_path(self):
fallback_paths = self.FALLBACK_PATHS
@@ -150,6 +149,9 @@ def default_child_processes(self):
return 1
return chromium.ChromiumPort.default_child_processes(self)

def operating_system(self):
return 'mac'

#
# PROTECTED METHODS
#
@@ -85,6 +85,9 @@ def test_graphics_type(self):
# Mac defaults to cpu graphics type.
self.assertEquals('cpu', self.make_port().graphics_type())

def test_operating_system(self):
self.assertEqual('mac', self.make_port().operating_system())


if __name__ == '__main__':
port_testcase.main()
@@ -95,7 +95,6 @@ def __init__(self, host, port_name=None, windows_version=None, **kwargs):
else:
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, server_name=None):
@@ -131,6 +130,9 @@ def check_build(self, needs_http):
_log.error(' http://dev.chromium.org/developers/how-tos/build-instructions-windows')
return result

def operating_system(self):
return 'win'

def relative_test_filename(self, filename):
path = filename[len(self.layout_tests_dir()) + 1:]
return path.replace('\\', '/')
@@ -126,3 +126,6 @@ def test_build_path(self):
self.assertEquals(
'/mock-checkout/Source/WebKit/chromium/build/Debug/DumpRenderTree.exe',
port._path_to_driver('Debug'))

def test_operating_system(self):
self.assertEqual('win', self.make_port().operating_system())
@@ -75,7 +75,6 @@ def _detect_version(self, os_version_string):
return os_version(os_version_string)

def __init__(self, host, **kwargs):
self._operating_system = 'mac'
ApplePort.__init__(self, host, **kwargs)
self._leak_detector = LeakDetector(self)
if self.get_option("leaks"):
@@ -105,6 +104,9 @@ def setup_environ_for_server(self, server_name=None):
env['XML_CATALOG_FILES'] = '' # work around missing /etc/catalog <rdar://problem/4292995>
return env

def operating_system(self):
return 'mac'

# Belongs on a Platform object.
def is_leopard(self):
return self._version == "leopard"
@@ -162,3 +162,6 @@ def test_show_results_html_file(self):
port._executive = MockExecutive(should_log=True)
expected_stderr = "MOCK run_command: ['Tools/Scripts/run-safari', '--release', '-NSOpen', 'test.html'], cwd=/mock-checkout\n"
OutputCapture().assert_outputs(self, port.show_results_html_file, ["test.html"], expected_stderr=expected_stderr)

def test_operating_system(self):
self.assertEqual('mac', self.make_port().operating_system())
@@ -63,7 +63,7 @@ def __init__(self, host, port_name=None, sys_platform=None, **kwargs):
port_name = port_name or self.port_name
WebKitPort.__init__(self, host, port_name=None, **kwargs)
self._operating_system = self._operating_system_for_platform(sys_platform or sys.platform)
self._version = self._operating_system
self._version = self.operating_system()

# FIXME: This will allow WebKitPort.baseline_search_path and WebKitPort._skipped_file_search_paths
# to do the right thing, but doesn't include support for qt-4.8 or qt-arm (seen in LayoutTests/platform) yet.
@@ -72,8 +72,8 @@ def __init__(self, host, port_name=None, sys_platform=None, **kwargs):
self._name = port_name
else:
name_components = [self.port_name]
if self._operating_system:
name_components.append(self._operating_system)
if self.operating_system():
name_components.append(self.operating_system())
self._name = "-".join(name_components)

def _generate_all_test_configurations(self):
@@ -94,7 +94,7 @@ def _path_to_image_diff(self):
return self._build_path('bin/ImageDiff')

def _path_to_webcore_library(self):
if self._operating_system == 'mac':
if self.operating_system() == 'mac':
return self._build_path('lib/QtWebKit.framework/QtWebKit')
else:
return self._build_path('lib/libQtWebKit.so')
@@ -155,3 +155,6 @@ def show_results_html_file(self, results_filename):
run_launcher_args.append('-2')
run_launcher_args.append("file://%s" % results_filename)
self._run_script("run-launcher", run_launcher_args)

def operating_system(self):
return self._operating_system
@@ -83,3 +83,9 @@ def test_setup_environ_for_server(self):
port = self.make_port()
env = port.setup_environ_for_server(port.driver_name())
self.assertEquals(env['QTWEBKIT_PLUGIN_PATH'], 'MOCK output of child process/lib/plugins')

def test_operating_system(self):
self.assertEqual('linux', self.make_port(sys_platform='linux').operating_system())
self.assertEqual('mac', self.make_port(sys_platform='darwin').operating_system())
self.assertEqual('win', self.make_port(sys_platform='cygwin').operating_system())
self.assertEqual('win', self.make_port(sys_platform='win32').operating_system())
@@ -377,6 +377,9 @@ def layout_tests_dir(self):
def name(self):
return self._name

def operating_system(self):
return self._operating_system

def _path_to_wdiff(self):
return None

@@ -74,10 +74,6 @@ def _detect_version(self, os_version_string=None, run_on_non_windows_platforms=N
version_tuple = tuple(map(int, match_object.groups()))
return self._version_string_from_windows_version_tuple(version_tuple)

def __init__(self, host, **kwargs):
self._operating_system = 'win'
ApplePort.__init__(self, host, **kwargs)

def compare_text(self, expected_text, actual_text):
# Sanity was restored in WK2, so we don't need this hack there.
if self.get_option('webkit_test_runner'):
@@ -108,6 +104,9 @@ def baseline_search_path(self):
fallback_names.extend(['mac-lion', 'mac'])
return map(self._webkit_baseline_path, fallback_names)

def operating_system(self):
return 'win'

# This port may need to override setup_environ_for_server
# to match behavior of setPathForRunningWebKitApp from ORWT.
# $env->{PATH} = join(':', productDir(), dirname(installedSafariPath()), appleApplicationSupportPath(), $env->{PATH} || "");
@@ -103,3 +103,6 @@ def test_compare_text(self):
# This hack doesn't exist in WK2.
port._options = MockOptions(webkit_test_runner=True)
self.assertTrue(port.compare_text(expected, "foo\n"))

def test_operating_system(self):
self.assertEqual('win', self.make_port().operating_system())

0 comments on commit e8d4078

Please sign in to comment.