Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1633)

Unified Diff: third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer.py

Issue 2542963002: W3C Importer: Consolidate and simplify logic for deciding what not to convert. (Closed)
Patch Set: Rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 7d49198a04cb46418ba42eb36fc340625694abee..12b0235808a21a6dfc033474e8b8d16febfdfa49 100644
--- a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer.py
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer.py
@@ -66,6 +66,7 @@ Rules for importing:
import logging
import mimetypes
+import re
import optparse
import os
import sys
@@ -404,26 +405,17 @@ class TestImporter(object):
# there's no harm in copying the identical thing.
_log.info(' %s', relpath)
- # Only HTML, XML, or CSS should be converted.
- # FIXME: Eventually, so should JS when support is added for this type of conversion.
- mimetype = mimetypes.guess_type(source_path)
- if 'is_jstest' not in file_to_copy and (
- 'html' in str(mimetype[0]) or 'xml' in str(mimetype[0]) or 'css' in str(mimetype[0])):
+ if self.should_try_to_convert(file_to_copy, source_path, dest_dir):
converted_file = convert_for_webkit(
dest_dir, filename=source_path,
reference_support_info=reference_support_info,
host=self.host)
+ for prefixed_property in converted_file[0]:
+ self._prefixed_properties.setdefault(prefixed_property, 0)
+ self._prefixed_properties[prefixed_property] += 1
- if not converted_file:
- if not self.import_in_place and not self.options.dry_run:
- self.filesystem.copyfile(source_path, dest_path) # The file was unmodified.
- else:
- for prefixed_property in converted_file[0]:
- self._prefixed_properties.setdefault(prefixed_property, 0)
- self._prefixed_properties[prefixed_property] += 1
-
- if not self.options.dry_run:
- self.filesystem.write_text_file(dest_path, converted_file[1])
+ if not self.options.dry_run:
+ self.filesystem.write_text_file(dest_path, converted_file[1])
else:
if not self.import_in_place and not self.options.dry_run:
self.filesystem.copyfile(source_path, dest_path)
@@ -432,6 +424,21 @@ class TestImporter(object):
return dest_path.replace(self._webkit_root, '')
+ @staticmethod
+ def should_try_to_convert(file_to_copy, source_path, dest_dir):
+ """Checks whether we should try to modify the file when importing."""
+ if file_to_copy.get('is_jstest', False):
+ return False
+
+ # Conversion is not necessary for any tests in wpt now; see http://crbug.com/654081.
+ # Note, we want to move away from converting files, see http://crbug.com/663773.
+ if re.search(r'[/\\]imported[/\\]wpt[/\\]', dest_dir):
+ return False
+
+ # Only HTML, XHTML and CSS files should be converted.
+ mimetype, _ = mimetypes.guess_type(source_path)
+ return mimetype in ('text/html', 'application/xhtml+xml', 'text/css')
+
def path_too_long(self, source_path):
"""Checks whether a source path is too long to import.

Powered by Google App Engine
This is Rietveld 408576698