| Index: third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer.py
|
| diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer.py b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer.py
|
| index 12b0235808a21a6dfc033474e8b8d16febfdfa49..8b18b1c78263b421fe3006e721cb614925717b7a 100644
|
| --- a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer.py
|
| +++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer.py
|
| @@ -419,11 +419,28 @@ class TestImporter(object):
|
| else:
|
| if not self.import_in_place and not self.options.dry_run:
|
| self.filesystem.copyfile(source_path, dest_path)
|
| - if self.filesystem.read_binary_file(source_path)[:2] == '#!':
|
| - self.filesystem.make_executable(dest_path)
|
| + self._transform_for_presubmit(dest_path)
|
|
|
| return dest_path.replace(self._webkit_root, '')
|
|
|
| + def _transform_for_presubmit(self, path):
|
| + """Changes a file in order to pass the Chromium top-level presubmit.
|
| +
|
| + This should only transform text files; if the Chromium presubmit is
|
| + changed to ignore imported files, then this would be unnecessary.
|
| + """
|
| + # There may be some text files that are encoded with utf-16 or other
|
| + # encodings, but these are rare.
|
| + try:
|
| + text = self.filesystem.read_text_file(path)
|
| + except UnicodeDecodeError:
|
| + return
|
| + if text[:2] == '#!':
|
| + self.filesystem.make_executable(path)
|
| + if '\r\n' in text:
|
| + _log.warning('File %s has CRLF line endings.', path)
|
| + self.filesystem.write_text_file(path, text.replace('\r\n', '\n'))
|
| +
|
| @staticmethod
|
| def should_try_to_convert(file_to_copy, source_path, dest_dir):
|
| """Checks whether we should try to modify the file when importing."""
|
|
|