WebKit Bugzilla
Attachment 345901 Details for
Bug 188092
: [LayoutTests][Win] Tests can fail if long paths are not enabled in registry.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
PATCH
188092.diff (text/plain), 6.42 KB, created by
Basuke Suzuki
on 2018-07-26 23:23:43 PDT
(
hide
)
Description:
PATCH
Filename:
MIME Type:
Creator:
Basuke Suzuki
Created:
2018-07-26 23:23:43 PDT
Size:
6.42 KB
patch
obsolete
>diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index bb5a7230ee2..5e2b6c4d339 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,32 @@ >+2018-07-26 Basuke Suzuki <Basuke.Suzuki@sony.com> >+ >+ [LayoutTests][Win] Test fails because of the too long file path error. >+ https://bugs.webkit.org/show_bug.cgi?id=188092 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Windows cannot handle path longer than about 255, even from Python. It requires a >+ special care before passing to the OS call. >+ https://docs.microsoft.com/ja-jp/windows/desktop/FileIO/naming-a-file#maximum-path-length-limitation >+ >+ * Scripts/webkitpy/common/system/filesystem.py: >+ (FileSystem.open_binary_file_for_reading): >+ (FileSystem.read_binary_file): >+ (FileSystem.write_binary_file): >+ (FileSystem.open_text_file_for_reading): >+ (FileSystem.open_text_file_for_writing): >+ (FileSystem.read_text_file): >+ (FileSystem.write_text_file): >+ (FileSystem.copy_from_base_host): >+ (FileSystem): >+ (FileSystem._extended_path): >+ * Scripts/webkitpy/common/system/filesystem_unittest.py: >+ (RealFileSystemTest.test_dirs_under): >+ (RealFileSystemTest): >+ (RealFileSystemTest.test_long_path_read_write_text): >+ (RealFileSystemTest.test_long_path_read_write_binary): >+ (make_long_path): >+ > 2018-07-26 Chris Dumez <cdumez@apple.com> > > Loading a file URL and then issuing a reload right away causes the load to fail due to sandboxing >diff --git a/Tools/Scripts/webkitpy/common/system/filesystem.py b/Tools/Scripts/webkitpy/common/system/filesystem.py >index dfbebeaf93b..525d6f4a92f 100644 >--- a/Tools/Scripts/webkitpy/common/system/filesystem.py >+++ b/Tools/Scripts/webkitpy/common/system/filesystem.py >@@ -40,6 +40,7 @@ import sys > import tempfile > import time > >+_is_win = sys.platform.startswith('win') > > class FileSystem(object): > """FileSystem interface for webkitpy. >@@ -217,26 +218,26 @@ class FileSystem(object): > return f, temp_name > > def open_binary_file_for_reading(self, path): >- return codecs.open(path, 'rb') >+ return codecs.open(self._extended_path(path), 'rb') > > def read_binary_file(self, path): > """Return the contents of the file at the given path as a byte string.""" >- with file(path, 'rb') as f: >+ with file(self._extended_path(path), 'rb') as f: > return f.read() > > def write_binary_file(self, path, contents): >- with file(path, 'wb') as f: >+ with file(self._extended_path(path), 'wb') as f: > f.write(contents) > > def open_text_file_for_reading(self, path, errors='strict'): > # Note: There appears to be an issue with the returned file objects > # not being seekable. See http://stackoverflow.com/questions/1510188/can-seek-and-tell-work-with-utf-8-encoded-documents-in-python . >- return codecs.open(path, 'r', 'utf8', errors) >+ return codecs.open(self._extended_path(path), 'r', 'utf8', errors) > > def open_text_file_for_writing(self, path, should_append=False): > if should_append: >- return codecs.open(path, 'a', 'utf8') >- return codecs.open(path, 'w', 'utf8') >+ return codecs.open(self._extended_path(path), 'a', 'utf8') >+ return codecs.open(self._extended_path(path), 'w', 'utf8') > > def open_stdin(self): > return codecs.StreamReaderWriter(sys.stdin, >@@ -248,14 +249,14 @@ class FileSystem(object): > """Return the contents of the file at the given path as a Unicode string. > > The file is read assuming it is a UTF-8 encoded file with no BOM.""" >- with codecs.open(path, 'r', 'utf8', errors=errors) as f: >+ with codecs.open(self._extended_path(path), 'r', 'utf8', errors=errors) as f: > return f.read() > > def write_text_file(self, path, contents, errors='strict'): > """Write the contents to the file at the given location. > > The file is written encoded as UTF-8 with no BOM.""" >- with codecs.open(path, 'w', 'utf-8', errors=errors) as f: >+ with codecs.open(self._extended_path(path), 'w', 'utf-8', errors=errors) as f: > f.write(contents.decode('utf-8', errors=errors) if type(contents) == str else contents) > > def sha1(self, path): >@@ -339,3 +340,8 @@ class FileSystem(object): > self.copytree(source, destination) > else: > self.copyfile(source, destination) >+ >+ def _extended_path(self, path): >+ """[Windows] Return extended path by appending a special sequence >+ For the reference: https://bit.ly/2uTSPQh """ >+ return path if not _is_win or len(path) <= 255 else '\\\\?\\' + path >diff --git a/Tools/Scripts/webkitpy/common/system/filesystem_unittest.py b/Tools/Scripts/webkitpy/common/system/filesystem_unittest.py >index 4800914746a..c75c0c31abb 100644 >--- a/Tools/Scripts/webkitpy/common/system/filesystem_unittest.py >+++ b/Tools/Scripts/webkitpy/common/system/filesystem_unittest.py >@@ -337,3 +337,38 @@ class RealFileSystemTest(unittest.TestCase, GenericFileSystemTests): > def filter_this_dir(fs, dirpath): > return dirpath != self._this_dir > self.assertFalse(self._this_dir in fs.dirs_under(parentDir, filter_this_dir)) >+ >+ def test_long_path_read_write_text(self): >+ """Test read/write of text file with long path""" >+ fs = FileSystem() >+ unicode_text_string = u'\u016An\u012Dc\u014Dde\u033D' >+ >+ with fs.mkdtemp(prefix='filesystem_unittest_') as d: >+ path = make_long_path(fs, d, 'txt') >+ >+ file = fs.open_text_file_for_writing(path) >+ file.write(unicode_text_string) >+ file.close() >+ >+ file = fs.open_text_file_for_reading(path) >+ read_text = file.read() >+ file.close() >+ >+ self.assertEqual(read_text, unicode_text_string) >+ >+ def test_long_path_read_write_binary(self): >+ """Test read/write of binary file with long path""" >+ fs = FileSystem() >+ test_contents = bytearray(b'\x73\x74\x72\x8b') >+ >+ with fs.mkdtemp(prefix='filesystem_unittest_') as d: >+ path = make_long_path(fs, d, 'bin') >+ >+ fs.write_binary_file(path, test_contents) >+ contents = fs.read_binary_file(path) >+ >+ self.assertEqual(contents, test_contents) >+ >+ >+def make_long_path(fs, directory, ext): >+ return fs.join(directory, 'webkit-' + ('x' * (300 - len(directory))) + '.' + ext)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
ews-watchlist
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188092
: 345901 |
345913