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

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

Issue 148173016: Checkpoint work to import new tests from the w3c repos. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: more cleanup Created 6 years, 10 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
« Tools/Scripts/update-w3c-deps ('K') | « Tools/Scripts/update-w3c-deps ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python
2
3 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 1 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
4 # 2 #
5 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions 4 # modification, are permitted provided that the following conditions
7 # are met: 5 # are met:
8 # 6 #
9 # 1. Redistributions of source code must retain the above 7 # 1. Redistributions of source code must retain the above
10 # copyright notice, this list of conditions and the following 8 # copyright notice, this list of conditions and the following
11 # disclaimer. 9 # disclaimer.
12 # 2. Redistributions in binary form must reproduce the above 10 # 2. Redistributions in binary form must reproduce the above
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 self.changeset = self.host.executive.run_command(['hg', 'tip']).spli t('changeset:')[1] 187 self.changeset = self.host.executive.run_command(['hg', 'tip']).spli t('changeset:')[1]
190 except (OSError, ScriptError): 188 except (OSError, ScriptError):
191 self.changeset = CHANGESET_NOT_AVAILABLE 189 self.changeset = CHANGESET_NOT_AVAILABLE
192 190
193 def find_importable_tests(self, directory): 191 def find_importable_tests(self, directory):
194 # FIXME: use filesystem 192 # FIXME: use filesystem
195 paths_to_skip = self.find_paths_to_skip() 193 paths_to_skip = self.find_paths_to_skip()
196 194
197 for root, dirs, files in os.walk(directory): 195 for root, dirs, files in os.walk(directory):
198 cur_dir = root.replace(self.layout_tests_dir + '/', '') + '/' 196 cur_dir = root.replace(self.layout_tests_dir + '/', '') + '/'
199 _log.info('Scanning ' + cur_dir + '...') 197 _log.info(' scanning ' + cur_dir + '...')
200 total_tests = 0 198 total_tests = 0
201 reftests = 0 199 reftests = 0
202 jstests = 0 200 jstests = 0
203 201
204 # "archive" and "data" dirs are internal csswg things that live in e very approved directory. 202 # "archive" and "data" dirs are internal csswg things that live in e very approved directory.
205 # FIXME: skip 'incoming' tests for now, but we should rework the 'te st_status' concept and 203 # FIXME: skip 'incoming' tests for now, but we should rework the 'te st_status' concept and
206 # support reading them as well. 204 # support reading them as well.
207 DIRS_TO_SKIP = ('.git', '.hg', 'data', 'archive', 'incoming') 205 DIRS_TO_SKIP = ('.git', '.hg', 'data', 'archive', 'incoming')
208 if dirs: 206 if dirs:
209 for d in DIRS_TO_SKIP: 207 for d in DIRS_TO_SKIP:
210 if d in dirs: 208 if d in dirs:
211 dirs.remove(d) 209 dirs.remove(d)
212 210
213 for path in paths_to_skip: 211 for path in paths_to_skip:
214 path_base = path.replace(cur_dir, '') 212 path_base = path.replace(cur_dir, '')
215 path_full = self.filesystem.join(root, path_base) 213 path_full = self.filesystem.join(root, path_base)
216 if path_base in dirs: 214 if path_base in dirs:
217 dirs.remove(path_base) 215 dirs.remove(path_base)
218 if not self.options.dry_run and self.import_in_place: 216 if not self.options.dry_run and self.import_in_place:
219 _log.info("Pruning %s" % path_full) 217 _log.info(" pruning %s" % path_base)
220 self.filesystem.rmtree(path_full) 218 self.filesystem.rmtree(path_full)
221 219
222 copy_list = [] 220 copy_list = []
223 221
224 for filename in files: 222 for filename in files:
225 path_full = self.filesystem.join(root, filename) 223 path_full = self.filesystem.join(root, filename)
226 path_base = path_full.replace(self.layout_tests_dir + '/', '') 224 path_base = path_full.replace(self.layout_tests_dir + '/', '')
227 if path_base in paths_to_skip: 225 if path_base in paths_to_skip:
228 if not self.options.dry_run and self.import_in_place: 226 if not self.options.dry_run and self.import_in_place:
229 _log.info("Pruning %s" % path_base) 227 _log.info(" pruning %s" % path_base)
230 self.filesystem.remove(path_full) 228 self.filesystem.remove(path_full)
231 continue 229 continue
232 # FIXME: This block should really be a separate function, but th e early-continues make that difficult. 230 # FIXME: This block should really be a separate function, but th e early-continues make that difficult.
233 231
234 if filename.startswith('.') or filename.endswith('.pl'): 232 if filename.startswith('.') or filename.endswith('.pl'):
235 continue # For some reason the w3c repo contains random per l scripts we don't care about. 233 continue # For some reason the w3c repo contains random per l scripts we don't care about.
236 234
237 fullpath = os.path.join(root, filename) 235 fullpath = os.path.join(root, filename)
238 236
239 mimetype = mimetypes.guess_type(fullpath) 237 mimetype = mimetypes.guess_type(fullpath)
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 _log.warning('%s not found. Possible error in the test.', or ig_filepath) 351 _log.warning('%s not found. Possible error in the test.', or ig_filepath)
354 continue 352 continue
355 353
356 new_filepath = os.path.join(new_path, file_to_copy['dest']) 354 new_filepath = os.path.join(new_path, file_to_copy['dest'])
357 355
358 if not(os.path.exists(os.path.dirname(new_filepath))): 356 if not(os.path.exists(os.path.dirname(new_filepath))):
359 if not self.import_in_place and not self.options.dry_run: 357 if not self.import_in_place and not self.options.dry_run:
360 os.makedirs(os.path.dirname(new_filepath)) 358 os.makedirs(os.path.dirname(new_filepath))
361 359
362 if not self.options.overwrite and os.path.exists(new_filepath): 360 if not self.options.overwrite and os.path.exists(new_filepath):
363 _log.info('Skipping import of existing file ' + new_filepath ) 361 _log.info(' skipping import of existing file ' + new_filepa th)
364 else: 362 else:
365 # FIXME: Maybe doing a file diff is in order here for existi ng files? 363 # FIXME: Maybe doing a file diff is in order here for existi ng files?
366 # In other words, there's no sense in overwriting identical files, but 364 # In other words, there's no sense in overwriting identical files, but
367 # there's no harm in copying the identical thing. 365 # there's no harm in copying the identical thing.
368 _log.info('Importing: %s', orig_filepath) 366 _log.info(' importing %s', os.path.relpath(new_filepath, se lf.layout_tests_dir))
369 _log.info(' As: %s', new_filepath)
370 367
371 # Only html, xml, or css should be converted 368 # Only html, xml, or css should be converted
372 # FIXME: Eventually, so should js when support is added for this type of conversion 369 # FIXME: Eventually, so should js when support is added for this type of conversion
373 mimetype = mimetypes.guess_type(orig_filepath) 370 mimetype = mimetypes.guess_type(orig_filepath)
374 if 'html' in str(mimetype[0]) or 'xml' in str(mimetype[0]) or ' css' in str(mimetype[0]): 371 if 'html' in str(mimetype[0]) or 'xml' in str(mimetype[0]) or ' css' in str(mimetype[0]):
375 converted_file = convert_for_webkit(new_path, filename=orig_ filepath) 372 converted_file = convert_for_webkit(new_path, filename=orig_ filepath)
376 373
377 if not converted_file: 374 if not converted_file:
378 if not self.import_in_place and not self.options.dry_run : 375 if not self.import_in_place and not self.options.dry_run :
379 shutil.copyfile(orig_filepath, new_filepath) # The file was unmodified. 376 shutil.copyfile(orig_filepath, new_filepath) # The file was unmodified.
380 else: 377 else:
381 for prefixed_property in converted_file[0]: 378 for prefixed_property in converted_file[0]:
382 total_prefixed_properties.setdefault(prefixed_proper ty, 0) 379 total_prefixed_properties.setdefault(prefixed_proper ty, 0)
383 total_prefixed_properties[prefixed_property] += 1 380 total_prefixed_properties[prefixed_property] += 1
384 381
385 prefixed_properties.extend(set(converted_file[0]) - set( prefixed_properties)) 382 prefixed_properties.extend(set(converted_file[0]) - set( prefixed_properties))
386 if not self.options.dry_run: 383 if not self.options.dry_run:
387 outfile = open(new_filepath, 'wb') 384 outfile = open(new_filepath, 'wb')
388 outfile.write(converted_file[1]) 385 outfile.write(converted_file[1])
389 outfile.close() 386 outfile.close()
390 else: 387 else:
391 if not self.import_in_place and not self.options.dry_run: 388 if not self.import_in_place and not self.options.dry_run:
392 shutil.copyfile(orig_filepath, new_filepath) 389 shutil.copyfile(orig_filepath, new_filepath)
393 390
394 copied_files.append(new_filepath.replace(self._webkit_root, '')) 391 copied_files.append(new_filepath.replace(self._webkit_root, ''))
395 392
396 if not self.options.import_in_place and not self.options.dry_run: 393 if not self.import_in_place and not self.options.dry_run:
397 self.remove_deleted_files(new_path, copied_files) 394 self.remove_deleted_files(new_path, copied_files)
398 self.write_import_log(new_path, copied_files, prefixed_propertie s) 395 self.write_import_log(new_path, copied_files, prefixed_propertie s)
399 396
397 _log.info('')
400 _log.info('Import complete') 398 _log.info('Import complete')
401 399 _log.info('')
402 _log.info('IMPORTED %d TOTAL TESTS', total_imported_tests) 400 _log.info('IMPORTED %d TOTAL TESTS', total_imported_tests)
403 _log.info('Imported %d reftests', total_imported_reftests) 401 _log.info('Imported %d reftests', total_imported_reftests)
404 _log.info('Imported %d JS tests', total_imported_jstests) 402 _log.info('Imported %d JS tests', total_imported_jstests)
405 _log.info('Imported %d pixel/manual tests', total_imported_tests - total _imported_jstests - total_imported_reftests) 403 _log.info('Imported %d pixel/manual tests', total_imported_tests - total _imported_jstests - total_imported_reftests)
406 _log.info('') 404 _log.info('')
407 _log.info('Properties needing prefixes (by count):') 405 _log.info('Properties needing prefixes (by count):')
408 for prefixed_property in sorted(total_prefixed_properties, key=lambda p: total_prefixed_properties[p]): 406 for prefixed_property in sorted(total_prefixed_properties, key=lambda p: total_prefixed_properties[p]):
409 _log.info(' %s: %s', prefixed_property, total_prefixed_properties[p refixed_property]) 407 _log.info(' %s: %s', prefixed_property, total_prefixed_properties[p refixed_property])
410 408
411 def setup_destination_directory(self): 409 def setup_destination_directory(self):
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 for prop in prop_list: 474 for prop in prop_list:
477 import_log.write(prop + '\n') 475 import_log.write(prop + '\n')
478 else: 476 else:
479 import_log.write('None\n') 477 import_log.write('None\n')
480 import_log.write('------------------------------------------------------ ------------------\n') 478 import_log.write('------------------------------------------------------ ------------------\n')
481 import_log.write('List of files:\n') 479 import_log.write('List of files:\n')
482 for item in file_list: 480 for item in file_list:
483 import_log.write(item + '\n') 481 import_log.write(item + '\n')
484 482
485 import_log.close() 483 import_log.close()
OLDNEW
« Tools/Scripts/update-w3c-deps ('K') | « Tools/Scripts/update-w3c-deps ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698