Diff
Modified: trunk/Tools/ChangeLog (119519 => 119520)
--- trunk/Tools/ChangeLog 2012-06-05 20:41:41 UTC (rev 119519)
+++ trunk/Tools/ChangeLog 2012-06-05 20:47:42 UTC (rev 119520)
@@ -1,3 +1,58 @@
+2012-06-04 Dirk Pranke <[email protected]>
+
+ webkitpy: clean up win-specific path handling and tests
+ https://bugs.webkit.org/show_bug.cgi?id=88281
+
+ Reviewed by Adam Barth.
+
+ There was a bunch of inconsistent logic for handling path
+ conversions for win32 and cygwin paths due to us sometimes
+ looking at sys.platform and sometimes using mock hosts. This
+ patch cleans everything up so that we are required to pass
+ PlatformInfo objects to the path module and stop trying to do
+ different things when running on cygwin or win32 hosts (except
+ in the path_unittest module itself).
+
+ This may slightly reduce test coverage for the win32 code paths
+ but will be a lot easier to follow and maintain.
+
+ * Scripts/webkitpy/common/system/path.py:
+ (abspath_to_uri):
+ (_convert_path):
+ * Scripts/webkitpy/common/system/path_unittest.py:
+ (AbspathTest.platforminfo):
+ (AbspathTest.test_abspath_to_uri_cygwin):
+ (AbspathTest.test_abspath_to_uri_unixy):
+ (AbspathTest.test_abspath_to_uri_win):
+ (AbspathTest.test_abspath_to_uri_escaping_unixy):
+ (AbspathTest.test_abspath_to_uri_escaping_cygwin):
+ (AbspathTest.test_stop_cygpath_subprocess):
+ * Scripts/webkitpy/common/system/platforminfo.py:
+ (PlatformInfo.__init__):
+ (PlatformInfo.is_cygwin):
+ * Scripts/webkitpy/common/system/platforminfo_mock.py:
+ (MockPlatformInfo.is_cygwin):
+ * Scripts/webkitpy/layout_tests/port/base.py:
+ (Port.to.show_results_html_file):
+ * Scripts/webkitpy/layout_tests/port/driver.py:
+ (Driver.test_to_uri):
+ (Driver.uri_to_test):
+ * Scripts/webkitpy/layout_tests/port/driver_unittest.py:
+ (DriverTest.test_test_to_uri):
+ (DriverTest.test_uri_to_test):
+ * Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py:
+ (MockDRTPortTest.make_port):
+ (MockDRTTest.input_line):
+ (MockChromiumDRTTest.test_pixeltest__fails):
+ * Scripts/webkitpy/layout_tests/port/test.py:
+ * Scripts/webkitpy/layout_tests/port/win.py:
+ (WinPort.show_results_html_file):
+ * Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:
+ (MainTest.test_unexpected_failures):
+ (MainTest.test_results_directory_absolute):
+ (MainTest.test_results_directory_default):
+ (MainTest.test_results_directory_relative):
+
2012-06-05 Jon Lee <[email protected]>
Workaround buildbot bug when merging build requests.
Modified: trunk/Tools/Scripts/webkitpy/common/system/path.py (119519 => 119520)
--- trunk/Tools/Scripts/webkitpy/common/system/path.py 2012-06-05 20:41:41 UTC (rev 119519)
+++ trunk/Tools/Scripts/webkitpy/common/system/path.py 2012-06-05 20:47:42 UTC (rev 119520)
@@ -35,11 +35,9 @@
import urllib
-def abspath_to_uri(path, platform=None):
+def abspath_to_uri(platform, path):
"""Converts a platform-specific absolute path to a file: URL."""
- if platform is None:
- platform = sys.platform
- return "file:" + _escape(_convert_path(path, platform))
+ return "file:" + _escape(_convert_path(platform, path))
def cygpath(path):
@@ -118,12 +116,12 @@
return urllib.quote(path, safe='/+:')
-def _convert_path(path, platform):
+def _convert_path(platform, path):
"""Handles any os-specific path separators, mappings, etc."""
- if platform == 'win32':
- return _winpath_to_uri(path)
- if platform == 'cygwin':
+ if platform.is_cygwin():
return _winpath_to_uri(cygpath(path))
+ if platform.is_win():
+ return _winpath_to_uri(path)
return _unixypath_to_uri(path)
Modified: trunk/Tools/Scripts/webkitpy/common/system/path_unittest.py (119519 => 119520)
--- trunk/Tools/Scripts/webkitpy/common/system/path_unittest.py 2012-06-05 20:41:41 UTC (rev 119519)
+++ trunk/Tools/Scripts/webkitpy/common/system/path_unittest.py 2012-06-05 20:47:42 UTC (rev 119520)
@@ -29,69 +29,41 @@
import unittest
import sys
-import path
+from webkitpy.common.system.systemhost import SystemHost
+from webkitpy.common.system.platforminfo import PlatformInfo
+from webkitpy.common.system.platforminfo_mock import MockPlatformInfo
+from webkitpy.common.system import path
class AbspathTest(unittest.TestCase):
- def assertMatch(self, test_path, expected_uri,
- platform=None):
- if platform == 'cygwin' and sys.platform != 'cygwin':
- return
- self.assertEqual(path.abspath_to_uri(test_path, platform=platform),
- expected_uri)
+ def platforminfo(self):
+ return SystemHost().platform
def test_abspath_to_uri_cygwin(self):
if sys.platform != 'cygwin':
return
+ self.assertEquals(path.abspath_to_uri(self.platforminfo(), '/cygdrive/c/foo/bar.html'),
+ 'file:///C:/foo/bar.html')
- self.assertMatch('/cygdrive/c/foo/bar.html',
- 'file:///C:/foo/bar.html',
- platform='cygwin')
- self.assertEqual(path.abspath_to_uri('/cygdrive/c/foo/bar.html',
- platform='cygwin'),
- 'file:///C:/foo/bar.html')
+ def test_abspath_to_uri_unixy(self):
+ self.assertEquals(path.abspath_to_uri(MockPlatformInfo(), "/foo/bar.html"),
+ 'file:///foo/bar.html')
- def test_abspath_to_uri_darwin(self):
- self.assertMatch('/foo/bar.html',
- 'file:///foo/bar.html',
- platform='darwin')
- self.assertEqual(path.abspath_to_uri("/foo/bar.html",
- platform='darwin'),
- "file:///foo/bar.html")
-
- def test_abspath_to_uri_linux2(self):
- self.assertMatch('/foo/bar.html',
- 'file:///foo/bar.html',
- platform='darwin')
- self.assertEqual(path.abspath_to_uri("/foo/bar.html",
- platform='linux2'),
- "file:///foo/bar.html")
- self.assertEqual(path.abspath_to_uri("/foo/bar.html",
- platform='linux3'),
- "file:///foo/bar.html")
-
def test_abspath_to_uri_win(self):
- self.assertMatch('c:\\foo\\bar.html',
- 'file:///c:/foo/bar.html',
- platform='win32')
- self.assertEqual(path.abspath_to_uri("c:\\foo\\bar.html",
- platform='win32'),
- "file:///c:/foo/bar.html")
+ if sys.platform != 'win32':
+ return
+ self.assertEquals(path.abspath_to_uri(self.platforminfo(), 'c:\\foo\\bar.html'),
+ 'file:///c:/foo/bar.html')
- def test_abspath_to_uri_escaping(self):
- self.assertMatch('/foo/bar + baz%?.html',
- 'file:///foo/bar%20+%20baz%25%3F.html',
- platform='darwin')
- self.assertMatch('/foo/bar + baz%?.html',
- 'file:///foo/bar%20+%20baz%25%3F.html',
- platform='linux2')
- self.assertMatch('/foo/bar + baz%?.html',
- 'file:///foo/bar%20+%20baz%25%3F.html',
- platform='linux3')
+ def test_abspath_to_uri_escaping_unixy(self):
+ self.assertEquals(path.abspath_to_uri(MockPlatformInfo(), '/foo/bar + baz%?.html'),
+ 'file:///foo/bar%20+%20baz%25%3F.html')
# Note that you can't have '?' in a filename on windows.
- self.assertMatch('/cygdrive/c/foo/bar + baz%.html',
- 'file:///C:/foo/bar%20+%20baz%25.html',
- platform='cygwin')
+ def test_abspath_to_uri_escaping_cygwin(self):
+ if sys.platform != 'cygwin':
+ return
+ self.assertEquals(path.abspath_to_uri(self.platforminfo(), '/cygdrive/c/foo/bar + baz%.html'),
+ 'file:///C:/foo/bar%20+%20baz%25.html')
def test_stop_cygpath_subprocess(self):
if sys.platform != 'cygwin':
@@ -106,6 +78,3 @@
# Ensure that it is stopped.
self.assertFalse(path._CygPath._singleton.is_running())
-
-if __name__ == '__main__':
- unittest.main()
Modified: trunk/Tools/Scripts/webkitpy/common/system/platforminfo.py (119519 => 119520)
--- trunk/Tools/Scripts/webkitpy/common/system/platforminfo.py 2012-06-05 20:41:41 UTC (rev 119519)
+++ trunk/Tools/Scripts/webkitpy/common/system/platforminfo.py 2012-06-05 20:47:42 UTC (rev 119520)
@@ -54,6 +54,7 @@
self.os_version = self._determine_mac_version(platform_module.mac_ver()[0])
if self.os_name.startswith('win'):
self.os_version = self._determine_win_version(self._win_version_tuple(sys_module))
+ self._is_cygwin = sys_module.platform == 'cygwin'
def is_mac(self):
return self.os_name == 'mac'
@@ -61,6 +62,9 @@
def is_win(self):
return self.os_name == 'win'
+ def is_cygwin(self):
+ return self._is_cygwin
+
def is_linux(self):
return self.os_name == 'linux'
Modified: trunk/Tools/Scripts/webkitpy/common/system/platforminfo_mock.py (119519 => 119520)
--- trunk/Tools/Scripts/webkitpy/common/system/platforminfo_mock.py 2012-06-05 20:41:41 UTC (rev 119519)
+++ trunk/Tools/Scripts/webkitpy/common/system/platforminfo_mock.py 2012-06-05 20:47:42 UTC (rev 119520)
@@ -41,6 +41,9 @@
def is_win(self):
return self.os_name == 'win'
+ def is_cygwin(self):
+ return False
+
def is_freebsd(self):
return self.os_name == 'freebsd'
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py (119519 => 119520)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py 2012-06-05 20:41:41 UTC (rev 119519)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py 2012-06-05 20:47:42 UTC (rev 119520)
@@ -776,7 +776,7 @@
def show_results_html_file(self, results_filename):
"""This routine should display the HTML file pointed at by
results_filename in a users' browser."""
- return self.host.user.open_url(path.abspath_to_uri(results_filename))
+ return self.host.user.open_url(path.abspath_to_uri(self.host.platform, results_filename))
def create_driver(self, worker_number, no_timeout=False):
"""Return a newly created Driver subclass for starting/stopping the test driver."""
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/driver.py (119519 => 119520)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/driver.py 2012-06-05 20:41:41 UTC (rev 119519)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/driver.py 2012-06-05 20:47:42 UTC (rev 119520)
@@ -132,7 +132,7 @@
def test_to_uri(self, test_name):
"""Convert a test name to a URI."""
if not self.is_http_test(test_name):
- return path.abspath_to_uri(self._port.abspath_for_test(test_name))
+ return path.abspath_to_uri(self._port.host.platform, self._port.abspath_for_test(test_name))
relative_path = test_name[len(self.HTTP_DIR):]
@@ -150,7 +150,7 @@
"""
if uri.startswith("file:///"):
- prefix = path.abspath_to_uri(self._port.layout_tests_dir())
+ prefix = path.abspath_to_uri(self._port.host.platform, self._port.layout_tests_dir())
if not prefix.endswith('/'):
prefix += '/'
return uri[len(prefix):]
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/driver_unittest.py (119519 => 119520)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/driver_unittest.py 2012-06-05 20:41:41 UTC (rev 119519)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/driver_unittest.py 2012-06-05 20:47:42 UTC (rev 119520)
@@ -29,7 +29,6 @@
import sys
import unittest
-from webkitpy.common.system.path import abspath_to_uri
from webkitpy.common.system.systemhost_mock import MockSystemHost
from webkitpy.layout_tests.port import Port, Driver, DriverOutput
@@ -105,20 +104,14 @@
def test_test_to_uri(self):
port = self.make_port()
driver = Driver(port, None, pixel_tests=False)
- if sys.platform in ('cygwin', 'win32'):
- self.assertEqual(driver.test_to_uri('foo/bar.html'), 'file:///%s/foo/bar.html' % port.layout_tests_dir())
- else:
- self.assertEqual(driver.test_to_uri('foo/bar.html'), 'file://%s/foo/bar.html' % port.layout_tests_dir())
+ self.assertEqual(driver.test_to_uri('foo/bar.html'), 'file://%s/foo/bar.html' % port.layout_tests_dir())
self.assertEqual(driver.test_to_uri('http/tests/foo.html'), 'http://127.0.0.1:8000/foo.html')
self.assertEqual(driver.test_to_uri('http/tests/ssl/bar.html'), 'https://127.0.0.1:8443/ssl/bar.html')
def test_uri_to_test(self):
port = self.make_port()
driver = Driver(port, None, pixel_tests=False)
- if sys.platform in ('cygwin', 'win32'):
- self.assertEqual(driver.uri_to_test('file:///%s/foo/bar.html' % port.layout_tests_dir()), 'foo/bar.html')
- else:
- self.assertEqual(driver.uri_to_test('file://%s/foo/bar.html' % port.layout_tests_dir()), 'foo/bar.html')
+ self.assertEqual(driver.uri_to_test('file://%s/foo/bar.html' % port.layout_tests_dir()), 'foo/bar.html')
self.assertEqual(driver.uri_to_test('http://127.0.0.1:8000/foo.html'), 'http/tests/foo.html')
self.assertEqual(driver.uri_to_test('https://127.0.0.1:8443/ssl/bar.html'), 'http/tests/ssl/bar.html')
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py (119519 => 119520)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py 2012-06-05 20:41:41 UTC (rev 119519)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py 2012-06-05 20:47:42 UTC (rev 119520)
@@ -49,11 +49,6 @@
def make_port(self, options=mock_options):
host = MockSystemHost()
test.add_unit_tests_to_mock_filesystem(host.filesystem)
- if sys.platform == 'win32':
- # We use this because the 'win' port doesn't work yet.
- host.platform.os_name = 'win'
- host.platform.os_version = 'xp'
- return mock_drt.MockDRTPort(host, port_name='mock-chromium-win', options=options)
return mock_drt.MockDRTPort(host, port_name='mock-mac', options=options)
def test_port_name_in_constructor(self):
@@ -93,10 +88,7 @@
def input_line(self, port, test_name, checksum=None):
url = ""
if url.startswith('file://'):
- if sys.platform == 'win32':
- url = ""
- else:
- url = ""
+ url = ""
if checksum:
return url + "'" + checksum + '\n'
@@ -247,9 +239,6 @@
def test_pixeltest__fails(self):
host = MockSystemHost()
url = ''
- if sys.platform == 'win32':
- host = MockSystemHost(os_name='win', os_version='xp')
- url = ''
url = "" + '%s/failures/expected/image_checksum.html' % PortFactory(host).get('test').layout_tests_dir()
self.assertTest('failures/expected/image_checksum.html', pixel_tests=True,
expected_checksum='image_checksum',
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/test.py (119519 => 119520)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/test.py 2012-06-05 20:41:41 UTC (rev 119519)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/test.py 2012-06-05 20:47:42 UTC (rev 119520)
@@ -233,12 +233,8 @@
# this works. The path contains a '.' in the name because we've seen bugs
# related to this before.
-if sys.platform == 'win32':
- LAYOUT_TEST_DIR = 'c:/test.checkout/LayoutTests'
- PERF_TEST_DIR = 'c:/test.checkout/PerformanceTests'
-else:
- LAYOUT_TEST_DIR = '/test.checkout/LayoutTests'
- PERF_TEST_DIR = '/test.checkout/PerformanceTests'
+LAYOUT_TEST_DIR = '/test.checkout/LayoutTests'
+PERF_TEST_DIR = '/test.checkout/PerformanceTests'
# Here we synthesize an in-memory filesystem from the test list
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/win.py (119519 => 119520)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/win.py 2012-06-05 20:41:41 UTC (rev 119519)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/win.py 2012-06-05 20:47:42 UTC (rev 119520)
@@ -30,6 +30,7 @@
import re
import sys
+from webkitpy.common.system.systemhost import SystemHost
from webkitpy.common.system.executive import ScriptError, Executive
from webkitpy.common.system.path import abspath_to_uri
from webkitpy.layout_tests.port.apple import ApplePort
@@ -75,7 +76,7 @@
return 'win'
def show_results_html_file(self, results_filename):
- self._run_script('run-safari', [abspath_to_uri(results_filename)])
+ self._run_script('run-safari', [abspath_to_uri(SystemHost().platform, results_filename)])
# FIXME: webkitperl/httpd.pm installs /usr/lib/apache/libphp4.dll on cycwin automatically
# as part of running old-run-webkit-tests. That's bad design, but we may need some similar hack.
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py (119519 => 119520)
--- trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py 2012-06-05 20:41:41 UTC (rev 119519)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py 2012-06-05 20:47:42 UTC (rev 119520)
@@ -537,7 +537,7 @@
self.assertEqual(res, unexpected_tests_count)
self.assertNotEmpty(out)
self.assertNotEmpty(err)
- self.assertEqual(user.opened_urls, [path.abspath_to_uri('/tmp/layout-test-results/results.html')])
+ self.assertEqual(user.opened_urls, [path.abspath_to_uri(MockHost().platform, '/tmp/layout-test-results/results.html')])
def test_missing_and_unexpected_results(self):
# Test that we update expectations in place. If the expectation
@@ -715,7 +715,7 @@
with host.filesystem.mkdtemp() as tmpdir:
res, out, err, user = logging_run(['--results-directory=' + str(tmpdir)],
tests_included=True, host=host)
- self.assertEqual(user.opened_urls, [path.abspath_to_uri(host.filesystem.join(tmpdir, 'results.html'))])
+ self.assertEqual(user.opened_urls, [path.abspath_to_uri(host.platform, host.filesystem.join(tmpdir, 'results.html'))])
def test_results_directory_default(self):
# We run a configuration that should fail, to generate output, then
@@ -723,7 +723,7 @@
# This is the default location.
res, out, err, user = logging_run(tests_included=True)
- self.assertEqual(user.opened_urls, [path.abspath_to_uri('/tmp/layout-test-results/results.html')])
+ self.assertEqual(user.opened_urls, [path.abspath_to_uri(MockHost().platform, '/tmp/layout-test-results/results.html')])
def test_results_directory_relative(self):
# We run a configuration that should fail, to generate output, then
@@ -733,7 +733,7 @@
host.filesystem.chdir('/tmp/cwd')
res, out, err, user = logging_run(['--results-directory=foo'],
tests_included=True, host=host)
- self.assertEqual(user.opened_urls, [path.abspath_to_uri('/tmp/cwd/foo/results.html')])
+ self.assertEqual(user.opened_urls, [path.abspath_to_uri(host.platform, '/tmp/cwd/foo/results.html')])
def test_retrying_and_flaky_tests(self):
host = MockHost()