| OLD | NEW |
| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 'reftests': reftests, 'jstests': jstests, 'total_tests': tot
al_tests}) | 258 'reftests': reftests, 'jstests': jstests, 'total_tests': tot
al_tests}) |
| 259 | 259 |
| 260 def import_tests(self): | 260 def import_tests(self): |
| 261 if self.import_list: | 261 if self.import_list: |
| 262 self.setup_destination_directory() | 262 self.setup_destination_directory() |
| 263 | 263 |
| 264 converter = W3CTestConverter() | 264 converter = W3CTestConverter() |
| 265 total_imported_tests = 0 | 265 total_imported_tests = 0 |
| 266 total_imported_reftests = 0 | 266 total_imported_reftests = 0 |
| 267 total_imported_jstests = 0 | 267 total_imported_jstests = 0 |
| 268 total_prefixed_properties = {} |
| 268 | 269 |
| 269 for dir_to_copy in self.import_list: | 270 for dir_to_copy in self.import_list: |
| 270 | 271 |
| 271 total_imported_tests += dir_to_copy['total_tests'] | 272 total_imported_tests += dir_to_copy['total_tests'] |
| 272 total_imported_reftests += dir_to_copy['reftests'] | 273 total_imported_reftests += dir_to_copy['reftests'] |
| 273 total_imported_jstests += dir_to_copy['jstests'] | 274 total_imported_jstests += dir_to_copy['jstests'] |
| 274 | 275 |
| 275 prefixed_properties = [] | 276 prefixed_properties = [] |
| 276 | 277 |
| 277 if not dir_to_copy['copy_list']: | 278 if not dir_to_copy['copy_list']: |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 # FIXME: Maybe doing a file diff is in order here for existi
ng files? | 316 # FIXME: Maybe doing a file diff is in order here for existi
ng files? |
| 316 # In other words, there's no sense in overwriting identical
files, but | 317 # In other words, there's no sense in overwriting identical
files, but |
| 317 # there's no harm in copying the identical thing. | 318 # there's no harm in copying the identical thing. |
| 318 print 'Importing:', orig_filepath | 319 print 'Importing:', orig_filepath |
| 319 print ' As:', new_filepath | 320 print ' As:', new_filepath |
| 320 | 321 |
| 321 # Only html, xml, or css should be converted | 322 # Only html, xml, or css should be converted |
| 322 # FIXME: Eventually, so should js when support is added for this
type of conversion | 323 # FIXME: Eventually, so should js when support is added for this
type of conversion |
| 323 mimetype = mimetypes.guess_type(orig_filepath) | 324 mimetype = mimetypes.guess_type(orig_filepath) |
| 324 if 'html' in str(mimetype[0]) or 'xml' in str(mimetype[0]) or '
css' in str(mimetype[0]): | 325 if 'html' in str(mimetype[0]) or 'xml' in str(mimetype[0]) or '
css' in str(mimetype[0]): |
| 325 | |
| 326 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) |
| 327 | 327 |
| 328 if not converted_file: | 328 if not converted_file: |
| 329 shutil.copyfile(orig_filepath, new_filepath) # The file
was unmodified. | 329 shutil.copyfile(orig_filepath, new_filepath) # The file
was unmodified. |
| 330 else: | 330 else: |
| 331 for prefixed_property in converted_file[0]: |
| 332 total_prefixed_properties.setdefault(prefixed_proper
ty, 0) |
| 333 total_prefixed_properties[prefixed_property] += 1 |
| 334 |
| 331 prefixed_properties.extend(set(converted_file[0]) - set(
prefixed_properties)) | 335 prefixed_properties.extend(set(converted_file[0]) - set(
prefixed_properties)) |
| 332 outfile = open(new_filepath, 'wb') | 336 outfile = open(new_filepath, 'wb') |
| 333 outfile.write(converted_file[1]) | 337 outfile.write(converted_file[1]) |
| 334 outfile.close() | 338 outfile.close() |
| 335 else: | 339 else: |
| 336 shutil.copyfile(orig_filepath, new_filepath) | 340 shutil.copyfile(orig_filepath, new_filepath) |
| 337 | 341 |
| 338 copied_files.append(new_filepath.replace(self._webkit_root, '')) | 342 copied_files.append(new_filepath.replace(self._webkit_root, '')) |
| 339 | 343 |
| 340 self.remove_deleted_files(new_path, copied_files) | 344 self.remove_deleted_files(new_path, copied_files) |
| 341 self.write_import_log(new_path, copied_files, prefixed_properties) | 345 self.write_import_log(new_path, copied_files, prefixed_properties) |
| 342 | 346 |
| 343 print 'Import complete' | 347 print 'Import complete' |
| 344 | 348 |
| 345 print 'IMPORTED ' + str(total_imported_tests) + ' TOTAL TESTS' | 349 print 'IMPORTED ' + str(total_imported_tests) + ' TOTAL TESTS' |
| 346 print 'Imported ' + str(total_imported_reftests) + ' reftests' | 350 print 'Imported ' + str(total_imported_reftests) + ' reftests' |
| 347 print 'Imported ' + str(total_imported_jstests) + ' JS tests' | 351 print 'Imported ' + str(total_imported_jstests) + ' JS tests' |
| 348 print 'Imported ' + str(total_imported_tests - total_imported_jstests -
total_imported_reftests) + ' pixel/manual tests' | 352 print 'Imported ' + str(total_imported_tests - total_imported_jstests -
total_imported_reftests) + ' pixel/manual tests' |
| 353 print |
| 354 print "Properties needing prefixes (by count):" |
| 355 for prefixed_property in sorted(total_prefixed_properties, key=lambda p:
total_prefixed_properties[p]): |
| 356 print " %s: %s" % (prefixed_property, total_prefixed_properties[pre
fixed_property]) |
| 349 | 357 |
| 350 def setup_destination_directory(self): | 358 def setup_destination_directory(self): |
| 351 """ Creates a destination directory that mirrors that of the source appr
oved or submitted directory """ | 359 """ Creates a destination directory that mirrors that of the source appr
oved or submitted directory """ |
| 352 | 360 |
| 353 self.update_test_status() | 361 self.update_test_status() |
| 354 | 362 |
| 355 start = self.source_directory.find(self.test_status) | 363 start = self.source_directory.find(self.test_status) |
| 356 new_subpath = self.source_directory[start:len(self.source_directory)] | 364 new_subpath = self.source_directory[start:len(self.source_directory)] |
| 357 | 365 |
| 358 destination_directory = os.path.join(self.destination_directory, new_sub
path) | 366 destination_directory = os.path.join(self.destination_directory, new_sub
path) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 for prop in prop_list: | 427 for prop in prop_list: |
| 420 import_log.write(prop + '\n') | 428 import_log.write(prop + '\n') |
| 421 else: | 429 else: |
| 422 import_log.write('None\n') | 430 import_log.write('None\n') |
| 423 import_log.write('------------------------------------------------------
------------------\n') | 431 import_log.write('------------------------------------------------------
------------------\n') |
| 424 import_log.write('List of files:\n') | 432 import_log.write('List of files:\n') |
| 425 for item in file_list: | 433 for item in file_list: |
| 426 import_log.write(item + '\n') | 434 import_log.write(item + '\n') |
| 427 | 435 |
| 428 import_log.close() | 436 import_log.close() |
| OLD | NEW |