Changeset 70012 in webkit
- Timestamp:
- Oct 18, 2010 5:40:58 PM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r70006 r70012 1 2010-10-18 Dirk Pranke <dpranke@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 Re-submit a revised version of r69638 - enabling new-run-webkit-tests 6 under cygwin. The initial version had a bug in base:uri_to_test_name 7 that was causing tests to fail. This version corrects that bug, but 8 also makes the code safer by calling cygpath more reliably, and 9 leaving a long-running cygpath process open. 10 11 This patch also corrects a couple of minor bugs in http_lock_unittest, 12 chromium_unittest, and dedpulicate_tests_unittest that showed up 13 while testing this. 14 15 https://bugs.webkit.org/show_bug.cgi?id=47220 16 17 * Scripts/webkitpy/common/system/path.py: 18 * Scripts/webkitpy/common/system/path_unittest.py: 19 * Scripts/webkitpy/layout_tests/deduplicate_tests_unittest.py: 20 * Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py: 21 * Scripts/webkitpy/layout_tests/port/base.py: 22 * Scripts/webkitpy/layout_tests/port/base_unittest.py: 23 * Scripts/webkitpy/layout_tests/port/chromium.py: 24 * Scripts/webkitpy/layout_tests/port/chromium_unittest.py: 25 * Scripts/webkitpy/layout_tests/port/http_lock_unittest.py: 26 * Scripts/webkitpy/layout_tests/run_webkit_tests.py: 27 1 28 2010-10-18 Eric Seidel <eric@webkit.org> 2 29 -
trunk/WebKitTools/Scripts/webkitpy/common/system/path.py
r69674 r70012 28 28 29 29 """generic routines to convert platform-specific paths to URIs.""" 30 from __future__ import with_statement 31 32 import atexit 33 import subprocess 30 34 import sys 35 import threading 31 36 import urllib 32 37 33 38 34 def abspath_to_uri(path, executive,platform=None):39 def abspath_to_uri(path, platform=None): 35 40 """Converts a platform-specific absolute path to a file: URL.""" 36 41 if platform is None: 37 42 platform = sys.platform 38 return "file:" + _escape(_convert_path(path, executive, platform)) 43 return "file:" + _escape(_convert_path(path, platform)) 44 45 46 def cygpath(path): 47 """Converts a cygwin path to Windows path.""" 48 return _CygPath.convert_using_singleton(path) 49 50 51 # Note that this object is not threadsafe and must only be called 52 # from multiple threads under protection of a lock (as is done in cygpath()) 53 class _CygPath(object): 54 """Manages a long-running 'cygpath' process for file conversion.""" 55 _lock = None 56 _singleton = None 57 58 @staticmethod 59 def stop_cygpath_subprocess(): 60 if not _CygPath._lock: 61 return 62 63 with _CygPath._lock: 64 if _CygPath._singleton: 65 _CygPath._singleton.stop() 66 67 @staticmethod 68 def convert_using_singleton(path): 69 if not _CygPath._lock: 70 _CygPath._lock = threading.Lock() 71 72 with _CygPath._lock: 73 if not _CygPath._singleton: 74 _CygPath._singleton = _CygPath() 75 # Make sure the cygpath subprocess always gets shutdown cleanly. 76 atexit.register(_CygPath.stop_cygpath_subprocess) 77 78 return _CygPath._singleton.convert(path) 79 80 def __init__(self): 81 self._child_process = None 82 83 def start(self): 84 assert(self._child_process is None) 85 args = ['cygpath', '-f', '-', '-wa'] 86 self._child_process = subprocess.Popen(args, 87 stdin=subprocess.PIPE, 88 stdout=subprocess.PIPE) 89 90 def is_running(self): 91 if not self._child_process: 92 return False 93 return self._child_process.returncode is None 94 95 def stop(self): 96 if self._child_process: 97 self._child_process.stdin.close() 98 self._child_process.wait() 99 self._child_process = None 100 101 def convert(self, path): 102 if not self.is_running(): 103 self.start() 104 self._child_process.stdin.write("%s\r\n" % path) 105 self._child_process.stdin.flush() 106 return self._child_process.stdout.readline().rstrip() 39 107 40 108 … … 48 116 49 117 50 def _convert_path(path, executive,platform):118 def _convert_path(path, platform): 51 119 """Handles any os-specific path separators, mappings, etc.""" 52 120 if platform == 'win32': 53 121 return _winpath_to_uri(path) 54 122 if platform == 'cygwin': 55 return _winpath_to_uri( _cygpath(path, executive))123 return _winpath_to_uri(cygpath(path)) 56 124 return _unixypath_to_uri(path) 57 125 … … 62 130 63 131 64 def _cygpath(path, executive):65 """Converts a cygwin path to Windows path."""66 return executive.run_command(['cygpath', '-wa', path],67 decode_output=False).rstrip()68 69 70 132 def _unixypath_to_uri(path): 71 133 """Converts a unix-style path to a file: URL.""" -
trunk/WebKitTools/Scripts/webkitpy/common/system/path_unittest.py
r69363 r70012 28 28 29 29 import unittest 30 import sys 30 31 31 32 import path 32 33 33 34 34 class AbspathTest(unittest.TestCase): 35 def run_command(self, args, **kwargs):36 self.assertEqual(args[0], 'cygpath')37 return self.cygpath_result38 39 35 def assertMatch(self, test_path, expected_uri, 40 platform, cygpath_result=None): 41 if platform == 'cygwin': 42 self.cygpath_result = cygpath_result 43 self.assertEqual(path.abspath_to_uri(test_path, executive=self, 44 platform=platform), 36 platform=None): 37 if platform == 'cygwin' and sys.platform != 'cygwin': 38 return 39 self.assertEqual(path.abspath_to_uri(test_path, platform=platform), 45 40 expected_uri) 46 41 47 42 def test_abspath_to_uri_cygwin(self): 43 if sys.platform != 'cygwin': 44 return 45 48 46 self.assertMatch('/cygdrive/c/foo/bar.html', 49 'file:///c:/foo/bar.html', 50 platform='cygwin', 51 cygpath_result='c:\\foo\\bar.html\n') 47 'file:///C:/foo/bar.html', 48 platform='cygwin') 52 49 self.assertEqual(path.abspath_to_uri('/cygdrive/c/foo/bar.html', 53 executive=self,54 50 platform='cygwin'), 55 'file:/// c:/foo/bar.html')51 'file:///C:/foo/bar.html') 56 52 57 53 def test_abspath_to_uri_darwin(self): … … 60 56 platform='darwin') 61 57 self.assertEqual(path.abspath_to_uri("/foo/bar.html", 62 executive=self,63 58 platform='darwin'), 64 59 "file:///foo/bar.html") … … 69 64 platform='darwin') 70 65 self.assertEqual(path.abspath_to_uri("/foo/bar.html", 71 executive=self,72 66 platform='linux2'), 73 67 "file:///foo/bar.html") … … 78 72 platform='win32') 79 73 self.assertEqual(path.abspath_to_uri("c:\\foo\\bar.html", 80 executive=self,81 74 platform='win32'), 82 75 "file:///c:/foo/bar.html") … … 92 85 # Note that you can't have '?' in a filename on windows. 93 86 self.assertMatch('/cygdrive/c/foo/bar + baz%.html', 94 'file:///c:/foo/bar%20+%20baz%25.html', 95 platform='cygwin', 96 cygpath_result='c:\\foo\\bar + baz%.html\n') 87 'file:///C:/foo/bar%20+%20baz%25.html', 88 platform='cygwin') 97 89 90 def test_stop_cygpath_subprocess(self): 91 if sys.platform != 'cygwin': 92 return 93 94 # Call cygpath to ensure the subprocess is running. 95 path.cygpath("/cygdrive/c/foo.txt") 96 self.assertTrue(path._CygPath._singleton.is_running()) 97 98 # Stop it. 99 path._CygPath.stop_cygpath_subprocess() 100 101 # Ensure that it is stopped. 102 self.assertFalse(path._CygPath._singleton.is_running()) 98 103 99 104 if __name__ == '__main__': -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/deduplicate_tests_unittest.py
r67588 r70012 206 206 self.assertEquals(expected, 207 207 deduplicate_tests.get_relative_test_path(*inputs)) 208 209 if __name__ == '__main__': 210 unittest.main() -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/base.py
r69820 r70012 50 50 from webkitpy.common.system import logutils 51 51 from webkitpy.common.system.executive import Executive, ScriptError 52 from webkitpy.common.system.path import abspath_to_uri 52 53 from webkitpy.common.system.user import User 53 54 … … 337 338 return "%s://127.0.0.1:%u/%s" % (protocol, port, relative_path) 338 339 339 abspath = os.path.abspath(filename) 340 341 # On Windows, absolute paths are of the form "c:\foo.txt". However, 342 # all current browsers (except for Opera) normalize file URLs by 343 # prepending an additional "/" as if the absolute path was 344 # "/c:/foo.txt". This means that all file URLs end up with "file:///" 345 # at the beginning. 346 if sys.platform == 'win32': 347 abspath = '/' + abspath.replace('\\', '/') 348 349 return "file://" + abspath 340 return abspath_to_uri(os.path.abspath(filename)) 350 341 351 342 def tests(self, paths): … … 396 387 test = uri 397 388 if uri.startswith("file:///"): 398 if sys.platform == 'win32': 399 test = test.replace('file:///', '') 400 test = test.replace('/', '\\') 401 else: 402 test = test.replace('file://', '') 403 return self.relative_test_filename(test) 389 prefix = abspath_to_uri(self.layout_tests_dir()) + "/" 390 return test[len(prefix):] 404 391 405 392 if uri.startswith("http://127.0.0.1:8880/"): -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/base_unittest.py
r69820 r70012 34 34 import unittest 35 35 36 from webkitpy.common.system.path import abspath_to_uri 36 37 from webkitpy.common.system.executive import Executive, ScriptError 37 38 from webkitpy.thirdparty.mock import Mock … … 245 246 246 247 self.assertEqual(port.filename_to_uri(test_file), 247 prefix + path) 248 248 abspath_to_uri(test_file)) 249 249 250 250 -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py
r69820 r70012 44 44 import webbrowser 45 45 46 from webkitpy.common.system.executive import Executive 47 from webkitpy.common.system.path import cygpath 48 from webkitpy.layout_tests.layout_package import test_expectations 49 46 50 import base 47 51 import http_server … … 345 349 return self.path_from_webkit_base('LayoutTests', 'platform', platform) 346 350 351 def _convert_path(self, path): 352 """Handles filename conversion for subprocess command line args.""" 353 # See note above in diff_image() for why we need this. 354 if sys.platform == 'cygwin': 355 return cygpath(path) 356 return path 357 347 358 def _path_to_image_diff(self): 348 359 binary_name = 'image_diff' … … 364 375 driver_args = [] 365 376 if self._image_path: 366 driver_args.append("--pixel-tests=" + self._image_path) 377 # See note above in diff_image() for why we need _convert_path(). 378 driver_args.append("--pixel-tests=" + 379 self._port._convert_path(self._image_path)) 367 380 368 381 if self._options.use_drt: -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py
r69169 r70012 177 177 return_stderr=True, 178 178 decode_output=False): 179 return self._result 179 if return_exit_code: 180 return self._result 181 return '' 180 182 181 183 options = EmptyOptions() -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/http_lock_unittest.py
r69578 r70012 44 44 def clean_all_lockfile(self): 45 45 if os.path.exists(self.guard_lock_file): 46 os.unlink( guard_lock_file)46 os.unlink(self.guard_lock_file) 47 47 lock_list = glob.glob(self.lock_file_path_prefix + '*') 48 48 for file_name in lock_list:
Note: See TracChangeset
for help on using the changeset viewer.