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

Side by Side Diff: Tools/Scripts/webkitpy/w3c/test_importer.py

Issue 15366004: update w3c import script to actually work :). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 3 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
4 # 4 #
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions 6 # modification, are permitted provided that the following conditions
7 # are met: 7 # are met:
8 # 8 #
9 # 1. Redistributions of source code must retain the above 9 # 1. Redistributions of source code must retain the above
10 # copyright notice, this list of conditions and the following 10 # copyright notice, this list of conditions and the following
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 This can also be overridden by a -n or --no-overwrite flag 65 This can also be overridden by a -n or --no-overwrite flag
66 66
67 - All files are converted to work in WebKit: 67 - All files are converted to work in WebKit:
68 1. .xht extensions are changed to .xhtml to make new-run-webkit-tests h appy 68 1. .xht extensions are changed to .xhtml to make new-run-webkit-tests h appy
69 2. Paths to testharness.js files are modified point to Webkit's copy of them in 69 2. Paths to testharness.js files are modified point to Webkit's copy of them in
70 LayoutTests/resources, using the correct relative path from the new location 70 LayoutTests/resources, using the correct relative path from the new location
71 3. All CSS properties requiring the -webkit-vendor prefix are prefixed - this current 71 3. All CSS properties requiring the -webkit-vendor prefix are prefixed - this current
72 list of what needs prefixes is read from Source/WebCore/CSS/CSSPrope rties.in 72 list of what needs prefixes is read from Source/WebCore/CSS/CSSPrope rties.in
73 4. Each reftest has its own copy of its reference file following the na ming conventions 73 4. Each reftest has its own copy of its reference file following the na ming conventions
74 new-run-webkit-tests expects 74 new-run-webkit-tests expects
75 5. If a a reference files lives outside the directory of the test that uses it, it is checked 75 5. If a reference files lives outside the directory of the test that us es it, it is checked
76 for paths to support files as it will be imported into a different r elative position to the 76 for paths to support files as it will be imported into a different r elative position to the
77 test file (in the same directory) 77 test file (in the same directory)
78 78
79 - Upon completion, script outputs the total number tests imported, broken d own by test type 79 - Upon completion, script outputs the total number tests imported, broken d own by test type
80 80
81 - Also upon completion, each directory where files are imported will have w 3c-import.log written 81 - Also upon completion, each directory where files are imported will have w 3c-import.log written
82 with a timestamp, the W3C Mercurial changeset if available, the list of C SS properties used that 82 with a timestamp, the W3C Mercurial changeset if available, the list of C SS properties used that
83 require prefixes, the list of imported files, and guidance for future tes t modification and 83 require prefixes, the list of imported files, and guidance for future tes t modification and
84 maintenance. 84 maintenance.
85 85
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 self.changeset = CHANGESET_NOT_AVAILABLE 178 self.changeset = CHANGESET_NOT_AVAILABLE
179 179
180 def find_importable_tests(self, directory): 180 def find_importable_tests(self, directory):
181 # FIXME: use filesystem 181 # FIXME: use filesystem
182 for root, dirs, files in os.walk(directory): 182 for root, dirs, files in os.walk(directory):
183 print 'Scanning ' + root + '...' 183 print 'Scanning ' + root + '...'
184 total_tests = 0 184 total_tests = 0
185 reftests = 0 185 reftests = 0
186 jstests = 0 186 jstests = 0
187 187
188 # Ignore any repo stuff 188 # "archive" and "data" dirs are internal csswg things that live in e very approved directory.
189 if '.git' in dirs: 189 DIRS_TO_SKIP = ('.git', '.hg', 'data', 'archive')
190 dirs.remove('.git') 190 for d in DIRS_TO_SKIP:
191 if '.hg' in dirs: 191 if d in dirs:
192 dirs.remove('.hg') 192 dirs.remove(d)
193
194 # archive and data dirs are internal csswg things that live in every approved directory
195 if 'data' in dirs:
196 dirs.remove('data')
197 if 'archive' in dirs:
198 dirs.remove('archive')
199 193
200 copy_list = [] 194 copy_list = []
201 195
202 for filename in files: 196 for filename in files:
203 # FIXME: This block should really be a separate function, but th e early-continues make that difficult. 197 # FIXME: This block should really be a separate function, but th e early-continues make that difficult.
204 198
205 if filename.startswith('.') or filename.endswith('.pl'): 199 if filename.startswith('.') or filename.endswith('.pl'):
206 continue # For some reason the w3c repo contains random per l scripts we don't care about. 200 continue # For some reason the w3c repo contains random per l scripts we don't care about.
207 201
208 fullpath = os.path.join(root, filename) 202 fullpath = os.path.join(root, filename)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 copy_list.append({'src': fullpath, 'dest': filename}) 245 copy_list.append({'src': fullpath, 'dest': filename})
252 else: 246 else:
253 total_tests += 1 247 total_tests += 1
254 copy_list.append({'src': fullpath, 'dest': filename}) 248 copy_list.append({'src': fullpath, 'dest': filename})
255 249
256 if not total_tests: 250 if not total_tests:
257 # We can skip the support directory if no tests were found. 251 # We can skip the support directory if no tests were found.
258 if 'support' in dirs: 252 if 'support' in dirs:
259 dirs.remove('support') 253 dirs.remove('support')
260 254
261 if copy_list: 255 if copy_list:
262 # Only add this directory to the list if there's something t o import 256 # Only add this directory to the list if there's something to im port
263 self.import_list.append({'dirname': root, 'copy_list': copy_ list, 257 self.import_list.append({'dirname': root, 'copy_list': copy_list ,
264 'reftests': reftests, 'jstests': jstests, 'total_tests': total_tests}) 258 'reftests': reftests, 'jstests': jstests, 'total_tests': tot al_tests})
265 259
266 def import_tests(self): 260 def import_tests(self):
267 if self.import_list: 261 if self.import_list:
268 self.setup_destination_directory() 262 self.setup_destination_directory()
269 263
270 converter = W3CTestConverter() 264 converter = W3CTestConverter()
271 total_imported_tests = 0 265 total_imported_tests = 0
272 total_imported_reftests = 0 266 total_imported_reftests = 0
273 total_imported_jstests = 0 267 total_imported_jstests = 0
274 268
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 # FIXME: Eventually, so should js when support is added for this type of conversion 322 # FIXME: Eventually, so should js when support is added for this type of conversion
329 mimetype = mimetypes.guess_type(orig_filepath) 323 mimetype = mimetypes.guess_type(orig_filepath)
330 if 'html' in str(mimetype[0]) or 'xml' in str(mimetype[0]) or ' css' in str(mimetype[0]): 324 if 'html' in str(mimetype[0]) or 'xml' in str(mimetype[0]) or ' css' in str(mimetype[0]):
331 325
332 converted_file = converter.convert_for_webkit(new_path, file name=orig_filepath) 326 converted_file = converter.convert_for_webkit(new_path, file name=orig_filepath)
333 327
334 if not converted_file: 328 if not converted_file:
335 shutil.copyfile(orig_filepath, new_filepath) # The file was unmodified. 329 shutil.copyfile(orig_filepath, new_filepath) # The file was unmodified.
336 else: 330 else:
337 prefixed_properties.extend(set(converted_file[0]) - set( prefixed_properties)) 331 prefixed_properties.extend(set(converted_file[0]) - set( prefixed_properties))
338 outfile = open(new_filepath, 'w') 332 outfile = open(new_filepath, 'wb')
339 outfile.write(converted_file[1]) 333 outfile.write(converted_file[1])
340 outfile.close() 334 outfile.close()
341 else: 335 else:
342 shutil.copyfile(orig_filepath, new_filepath) 336 shutil.copyfile(orig_filepath, new_filepath)
343 337
344 copied_files.append(new_filepath.replace(self._webkit_root, '')) 338 copied_files.append(new_filepath.replace(self._webkit_root, ''))
345 339
346 self.remove_deleted_files(new_path, copied_files) 340 self.remove_deleted_files(new_path, copied_files)
347 self.write_import_log(new_path, copied_files, prefixed_properties) 341 self.write_import_log(new_path, copied_files, prefixed_properties)
348 342
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 for prop in prop_list: 419 for prop in prop_list:
426 import_log.write(prop + '\n') 420 import_log.write(prop + '\n')
427 else: 421 else:
428 import_log.write('None\n') 422 import_log.write('None\n')
429 import_log.write('------------------------------------------------------ ------------------\n') 423 import_log.write('------------------------------------------------------ ------------------\n')
430 import_log.write('List of files:\n') 424 import_log.write('List of files:\n')
431 for item in file_list: 425 for item in file_list:
432 import_log.write(item + '\n') 426 import_log.write(item + '\n')
433 427
434 import_log.close() 428 import_log.close()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698