Commit e37c823e authored by eric@webkit.org's avatar eric@webkit.org

2011-07-06 Eric Seidel <eric@webkit.org>

        Fix WebKit2 expected results search paths for Mac and Qt under new-run-webkit-tests
        https://bugs.webkit.org/show_bug.cgi?id=64056

        Reviewed by Adam Barth.

        This fixes the MacPort's version of baseline_search_path to include
        wk2 fallback like WebKitPort's does.  This also re-works the QtPort
        to set self._name (as other ports do) so that WebKitPort's default
        implementations will understand Qt operating system flavors correctly
        (including when running wk2 tests).

        In trying to test this, I realized that nearly all of our port-tests
        use the default FileSystem(), User() and Executive() objects, which
        is really bad, because they expose details of your system in the unittest results!

        Once I fixed many of the Port() calls to pass MockFileSystem(), then
        MacPort.test_tests_for_other_platforms started failing, and I had to
        teach MockFileSystem.glob how to handle directories to make it work again.

        I removed the useless PortTestCase.test_baseline_search_path and replaced
        it with more useful test_baseline_search_path tests in MacPortTest and QtPortTest.

        * Scripts/webkitpy/common/config/ports.py:
        * Scripts/webkitpy/common/system/filesystem_mock.py:
        * Scripts/webkitpy/layout_tests/port/chromium_linux.py:
        * Scripts/webkitpy/layout_tests/port/chromium_unittest.py:
        * Scripts/webkitpy/layout_tests/port/mac.py:
        * Scripts/webkitpy/layout_tests/port/mac_unittest.py:
        * Scripts/webkitpy/layout_tests/port/port_testcase.py:
        * Scripts/webkitpy/layout_tests/port/qt.py:
        * Scripts/webkitpy/layout_tests/port/test_files.py:
        * Scripts/webkitpy/layout_tests/port/win.py:
        * Scripts/webkitpy/to_be_moved/deduplicate_tests.py:
        * Scripts/webkitpy/tool/mocktool.py:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@90543 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5539ed3e
2011-07-06 Eric Seidel <eric@webkit.org>
Fix WebKit2 expected results search paths for Mac and Qt under new-run-webkit-tests
https://bugs.webkit.org/show_bug.cgi?id=64056
Reviewed by Adam Barth.
This fixes the MacPort's version of baseline_search_path to include
wk2 fallback like WebKitPort's does. This also re-works the QtPort
to set self._name (as other ports do) so that WebKitPort's default
implementations will understand Qt operating system flavors correctly
(including when running wk2 tests).
In trying to test this, I realized that nearly all of our port-tests
use the default FileSystem(), User() and Executive() objects, which
is really bad, because they expose details of your system in the unittest results!
Once I fixed many of the Port() calls to pass MockFileSystem(), then
MacPort.test_tests_for_other_platforms started failing, and I had to
teach MockFileSystem.glob how to handle directories to make it work again.
I removed the useless PortTestCase.test_baseline_search_path and replaced
it with more useful test_baseline_search_path tests in MacPortTest and QtPortTest.
* Scripts/webkitpy/common/config/ports.py:
* Scripts/webkitpy/common/system/filesystem_mock.py:
* Scripts/webkitpy/layout_tests/port/chromium_linux.py:
* Scripts/webkitpy/layout_tests/port/chromium_unittest.py:
* Scripts/webkitpy/layout_tests/port/mac.py:
* Scripts/webkitpy/layout_tests/port/mac_unittest.py:
* Scripts/webkitpy/layout_tests/port/port_testcase.py:
* Scripts/webkitpy/layout_tests/port/qt.py:
* Scripts/webkitpy/layout_tests/port/test_files.py:
* Scripts/webkitpy/layout_tests/port/win.py:
* Scripts/webkitpy/to_be_moved/deduplicate_tests.py:
* Scripts/webkitpy/tool/mocktool.py:
2011-07-06 Adam Barth <abarth@webkit.org>
Wean rebaseline-server off unexpected_results.json
......
......@@ -36,7 +36,6 @@ from webkitpy.common.system.executive import Executive
class WebKitPort(object):
# We might need to pass scm into this function for scm.checkout_root
@classmethod
def script_path(cls, script_name):
......
......@@ -35,7 +35,7 @@ from webkitpy.common.system import ospath
class MockFileSystem(object):
def __init__(self, files=None, cwd='/'):
def __init__(self, files=None, dirs=None, cwd='/'):
"""Initializes a "mock" filesystem that can be used to completely
stub out a filesystem.
......@@ -49,7 +49,7 @@ class MockFileSystem(object):
self._sep = '/'
self.current_tmpno = 0
self.cwd = cwd
self.dirs = {}
self.dirs = dirs or set()
def _get_sep(self):
return self._sep
......@@ -140,13 +140,16 @@ class MockFileSystem(object):
def getcwd(self):
return self.cwd
def glob(self, path):
def glob(self, glob_string):
# FIXME: This only handles a wildcard '*' at the end of the path.
# Maybe it should handle more?
if path[-1] == '*':
return [f for f in self.files if f.startswith(path[:-1])]
if glob_string[-1] == '*':
path_filter = lambda path: path.startswith(glob_string[:-1])
else:
return [f for f in self.files if f == path]
path_filter = lambda path: glob_string == path
existing_files = [path for path, contents in self.files.items() if contents is not None]
return filter(path_filter, existing_files) + filter(path_filter, self.dirs)
def isabs(self, path):
return path.startswith(self.sep)
......@@ -159,7 +162,7 @@ class MockFileSystem(object):
return False
path = self.normpath(path)
if path in self.dirs:
return self.dirs[path] is not None
return True
# We need to use a copy of the keys here in order to avoid switching
# to a different thread and potentially modifying the dict in
......@@ -167,7 +170,7 @@ class MockFileSystem(object):
files = self.files.keys()[:]
result = any(f.startswith(path) for f in files)
if result:
self.dirs[path] = True
self.dirs.add(path)
return result
def join(self, *comps):
......@@ -233,7 +236,7 @@ class MockFileSystem(object):
def maybe_make_directory(self, *path):
norm_path = self.normpath(self.join(*path))
if not self.isdir(norm_path):
self.dirs[norm_path] = True
self.dirs.add(norm_path)
def move(self, source, destination):
if self.files[source] is None:
......@@ -285,9 +288,7 @@ class MockFileSystem(object):
if f.startswith(path):
self.files[f] = None
for d in self.dirs:
if d.startswith(path):
self.dirs[d] = None
self.dirs = set(filter(lambda d: not d.startswith(path), self.dirs))
def split(self, path):
idx = path.rfind(self.sep)
......
......@@ -38,7 +38,6 @@ _log = logging.getLogger(__name__)
class ChromiumLinuxPort(chromium.ChromiumPort):
"""Chromium Linux implementation of the Port class."""
SUPPORTED_ARCHITECTURES = ('x86', 'x86_64')
FALLBACK_PATHS = {
......@@ -53,7 +52,7 @@ class ChromiumLinuxPort(chromium.ChromiumPort):
# in order to be able to find the DRT binary properly.
if port_name.endswith('-linux'):
self._architecture = self._determine_architecture()
# FIXME: this is an ugly hack to avoid renaming the GPU port.
# FIXME: This is an ugly hack to avoid renaming the GPU port.
if port_name == 'chromium-linux':
port_name = port_name + '-' + self._architecture
else:
......@@ -73,8 +72,7 @@ class ChromiumLinuxPort(chromium.ChromiumPort):
file_output = ''
if self._filesystem.exists(driver_path):
# The --dereference flag tells file to follow symlinks
file_output = self._executive.run_command(['file', '--dereference', driver_path],
return_stderr=True)
file_output = self._executive.run_command(['file', '--dereference', driver_path], return_stderr=True)
if 'ELF 32-bit LSB executable' in file_output:
return 'x86'
......@@ -109,8 +107,7 @@ class ChromiumLinuxPort(chromium.ChromiumPort):
def _build_path(self, *comps):
if self.get_option('build_directory'):
return self._filesystem.join(self.get_option('build_directory'),
*comps)
return self._filesystem.join(self.get_option('build_directory'), *comps)
base = self.path_from_chromium_base()
if self._filesystem.exists(self._filesystem.join(base, 'sconsbuild')):
......@@ -123,34 +120,27 @@ class ChromiumLinuxPort(chromium.ChromiumPort):
return self._filesystem.join(base, 'out', *comps)
def _check_apache_install(self):
result = self._check_file_exists(self._path_to_apache(),
"apache2")
result = self._check_file_exists(self._path_to_apache_config_file(),
"apache2 config file") and result
result = self._check_file_exists(self._path_to_apache(), "apache2")
result = self._check_file_exists(self._path_to_apache_config_file(), "apache2 config file") and result
if not result:
_log.error(' Please install using: "sudo apt-get install '
'apache2 libapache2-mod-php5"')
_log.error(' Please install using: "sudo apt-get install apache2 libapache2-mod-php5"')
_log.error('')
return result
def _check_lighttpd_install(self):
result = self._check_file_exists(
self._path_to_lighttpd(), "LigHTTPd executable")
result = self._check_file_exists(self._path_to_lighttpd_php(),
"PHP CGI executable") and result
result = self._check_file_exists(self._path_to_lighttpd_modules(),
"LigHTTPd modules") and result
result = self._check_file_exists(self._path_to_lighttpd_php(), "PHP CGI executable") and result
result = self._check_file_exists(self._path_to_lighttpd_modules(), "LigHTTPd modules") and result
if not result:
_log.error(' Please install using: "sudo apt-get install '
'lighttpd php5-cgi"')
_log.error(' Please install using: "sudo apt-get install lighttpd php5-cgi"')
_log.error('')
return result
def check_wdiff(self, logging=True):
result = self._check_file_exists(self._path_to_wdiff(), 'wdiff')
if not result and logging:
_log.error(' Please install using: "sudo apt-get install '
'wdiff"')
_log.error(' Please install using: "sudo apt-get install wdiff"')
_log.error('')
# FIXME: The ChromiumMac port always returns True.
return result
......@@ -167,8 +157,7 @@ class ChromiumLinuxPort(chromium.ChromiumPort):
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_lighttpd(self):
return "/usr/sbin/lighttpd"
......
......@@ -123,10 +123,6 @@ class ChromiumPortTest(port_testcase.PortTestCase):
# Override this test since ChromiumPort doesn't implement driver_cmd_line().
pass
def test_baseline_search_path(self):
# Override this test since ChromiumPort doesn't implement baseline_search_path().
pass
def test_check_build(self):
# Override this test since ChromiumPort doesn't implement _path_to_driver().
pass
......
......@@ -69,8 +69,7 @@ class MacPort(WebKitPort):
'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'],
'wk2': [], # wk2 does not make sense as a version, this is only here to make the rebaseline unit tests not crash.
}
def __init__(self, port_name=None, os_version_string=None, **kwargs):
......@@ -86,7 +85,10 @@ class MacPort(WebKitPort):
self._operating_system = 'mac'
def baseline_search_path(self):
return map(self._webkit_baseline_path, self.FALLBACK_PATHS[self._version])
search_paths = self.FALLBACK_PATHS[self._version]
if self.get_option('webkit_test_runner'):
search_paths.insert(0, self._wk2_port_name())
return map(self._webkit_baseline_path, search_paths)
def is_crash_reporter(self, process_name):
return re.search(r'ReportCrash', process_name)
......
......@@ -30,18 +30,20 @@ import StringIO
import sys
import unittest
from webkitpy.layout_tests.port import mac
from webkitpy.layout_tests.port.mac import MacPort
from webkitpy.layout_tests.port import port_testcase
from webkitpy.common.system.filesystem_mock import MockFileSystem
from webkitpy.tool.mocktool import MockOptions, MockUser, MockExecutive
class MacTest(port_testcase.PortTestCase):
def port_maker(self, platform):
if platform != 'darwin':
return None
return mac.MacPort
return MacPort
def assert_skipped_file_search_paths(self, port_name, expected_paths):
port = mac.MacPort(port_name=port_name)
port = MacPort(port_name=port_name, filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())
self.assertEqual(port._skipped_file_search_paths(), expected_paths)
def test_skipped_file_search_paths(self):
......@@ -72,23 +74,27 @@ svg/batik/text/smallFonts.svg
]
def test_tests_from_skipped_file_contents(self):
port = mac.MacPort()
port = MacPort(filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())
self.assertEqual(port._tests_from_skipped_file_contents(self.example_skipped_file), self.example_skipped_tests)
def assert_name(self, port_name, os_version_string, expected):
port = mac.MacPort(port_name=port_name,
os_version_string=os_version_string)
port = MacPort(port_name=port_name, os_version_string=os_version_string, filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())
self.assertEquals(expected, port.name())
def test_tests_for_other_platforms(self):
port = mac.MacPort(port_name='mac-snowleopard')
platforms = ['mac', 'chromium-linux', 'mac-snowleopard']
port = MacPort(port_name='mac-snowleopard', filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())
platform_dir_paths = map(port._webkit_baseline_path, platforms)
# Replace our empty mock file system with one which has our expected platform directories.
port._filesystem = MockFileSystem(dirs=platform_dir_paths)
dirs_to_skip = port._tests_for_other_platforms()
self.assertTrue('platform/chromium-linux' in dirs_to_skip)
self.assertFalse('platform/mac' in dirs_to_skip)
self.assertFalse('platform/mac-snowleopard' in dirs_to_skip)
def test_version(self):
port = mac.MacPort()
port = MacPort(filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())
self.assertTrue(port.version())
def test_versions(self):
......@@ -119,6 +125,22 @@ svg/batik/text/smallFonts.svg
self.assertRaises(AssertionError, self.assert_name, None, '10.3.1', 'should-raise-assertion-so-this-value-does-not-matter')
def _assert_search_path(self, search_paths, version, use_webkit2=False):
# FIXME: Port constructors should not "parse" the port name, but
# rather be passed components (directly or via setters). Once
# we fix that, this method will need a re-write.
port = MacPort('mac-%s' % version, options=MockOptions(webkit_test_runner=use_webkit2), filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())
absolute_search_paths = map(port._webkit_baseline_path, search_paths)
self.assertEquals(port.baseline_search_path(), absolute_search_paths)
def test_baseline_search_path(self):
# FIXME: Is this really right? Should mac-leopard fallback to mac-snowleopard?
self._assert_search_path(['mac-leopard', 'mac-snowleopard', 'mac'], 'leopard')
self._assert_search_path(['mac-snowleopard', 'mac'], 'snowleopard')
self._assert_search_path(['mac-wk2', 'mac-leopard', 'mac-snowleopard', 'mac'], 'leopard', use_webkit2=True)
self._assert_search_path(['mac-wk2', 'mac-snowleopard', 'mac'], 'snowleopard', use_webkit2=True)
if __name__ == '__main__':
port_testcase.main()
......@@ -43,8 +43,9 @@ except ImportError:
from webkitpy.layout_tests.servers import http_server_base
from webkitpy.tool import mocktool
mock_options = mocktool.MockOptions(configuration='Release')
from webkitpy.common.system.filesystem_mock import MockFileSystem
from webkitpy.tool.mocktool import MockOptions, MockUser, MockExecutive
mock_options = MockOptions(configuration='Release')
class PortTestCase(unittest.TestCase):
......@@ -65,7 +66,7 @@ class PortTestCase(unittest.TestCase):
if not maker:
return None
return maker(options=options)
return maker(options=options, filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())
def test_default_worker_model(self):
port = self.make_port()
......@@ -83,7 +84,7 @@ class PortTestCase(unittest.TestCase):
return
self.assertTrue(len(port.driver_cmd_line()))
options = mocktool.MockOptions(additional_drt_flag=['--foo=bar', '--foo=baz'])
options = MockOptions(additional_drt_flag=['--foo=bar', '--foo=baz'])
port = self.make_port(options=options)
cmd_line = port.driver_cmd_line()
self.assertTrue('--foo=bar' in cmd_line)
......@@ -343,12 +344,6 @@ class PortTestCase(unittest.TestCase):
return
self.assertTrue(len(port.all_test_configurations()) > 0)
def test_baseline_search_path(self):
port = self.make_port()
if not port:
return
self.assertTrue(port.baseline_path() in port.baseline_search_path())
def integration_test_http_server__loop(self):
port = self.make_port()
if not port:
......
......@@ -42,16 +42,26 @@ _log = logging.getLogger(__name__)
class QtPort(WebKitPort):
port_name = "qt"
def baseline_search_path(self):
port_names = []
if sys.platform.startswith('linux'):
port_names.append("qt-linux")
elif sys.platform in ('win32', 'cygwin'):
port_names.append("qt-win")
elif sys.platform == 'darwin':
port_names.append("qt-mac")
port_names.append("qt")
return map(self._webkit_baseline_path, port_names)
def _operating_system_for_platform(self, platform):
if platform.startswith('linux'):
return "linux"
elif platform in ('win32', 'cygwin'):
return "win"
elif platform == 'darwin':
return "mac"
return None
# sys_platform exists only for unit testing.
def __init__(self, sys_platform=None, **kwargs):
WebKitPort.__init__(self, **kwargs)
self._operating_system = self._operating_system_for_platform(sys_platform or sys.platform)
# 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.
name_components = [self.port_name]
if self._operating_system:
name_components.append(self._operating_system)
self._name = "-".join(name_components)
def _path_to_apache_config_file(self):
# FIXME: This needs to detect the distribution and change config files.
......
......@@ -85,8 +85,7 @@ def normalized_find(filesystem, paths):
else:
paths_to_walk.add(path)
# FIXME: I'm not sure there's much point in this being a set. A list would
# probably be faster.
# FIXME: I'm not sure there's much point in this being a set. A list would probably be faster.
test_files = set()
for path in paths_to_walk:
files = filesystem.files_under(path, _skipped_directories, _is_test_file)
......
......@@ -46,6 +46,7 @@ class WinPort(WebKitPort):
def baseline_search_path(self):
# Based on code from old-run-webkit-tests expectedDirectoryForTest()
# FIXME: This does not work for WebKit2.
port_names = ["win", "mac-snowleopard", "mac"]
return map(self._webkit_baseline_path, port_names)
......
......@@ -59,8 +59,7 @@ def port_fallbacks():
try:
platforms = port_factory.get(port_name).baseline_search_path()
except NotImplementedError:
_log.error("'%s' lacks baseline_search_path(), please fix."
% port_name)
_log.error("'%s' lacks baseline_search_path(), please fix." % port_name)
fallbacks[port_name] = [_BASE_PLATFORM]
continue
fallbacks[port_name] = [os.path.basename(p) for p in platforms][1:]
......@@ -241,4 +240,5 @@ def deduplicate(glob_pattern):
"""
fallbacks = port_fallbacks()
hashes = cluster_file_hashes(glob_pattern)
# FIXME: This should use a FileSystem object and not call os.getcwd() directly.
return list(find_dups(hashes, fallbacks, os.getcwd()))
......@@ -665,7 +665,7 @@ class MockStatusServer(object):
# FIXME: This should not inherit from Mock
# FIXME: Unify with common.system.executive_mock.MockExecutive.
class MockExecutive(Mock):
def __init__(self, should_log, should_throw=False):
def __init__(self, should_log=False, should_throw=False):
self._should_log = should_log
self._should_throw = should_throw
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment