| OLD | NEW |
| 1 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 1 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions | 4 # modification, are permitted provided that the following conditions |
| 5 # are met: | 5 # are met: |
| 6 # | 6 # |
| 7 # 1. Redistributions of source code must retain the above | 7 # 1. Redistributions of source code must retain the above |
| 8 # copyright notice, this list of conditions and the following | 8 # copyright notice, this list of conditions and the following |
| 9 # disclaimer. | 9 # disclaimer. |
| 10 # 2. Redistributions in binary form must reproduce the above | 10 # 2. Redistributions in binary form must reproduce the above |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 from webkitpy.common.host import Host | 82 from webkitpy.common.host import Host |
| 83 from webkitpy.common.webkit_finder import WebKitFinder | 83 from webkitpy.common.webkit_finder import WebKitFinder |
| 84 from webkitpy.common.system.executive import ScriptError | 84 from webkitpy.common.system.executive import ScriptError |
| 85 from webkitpy.layout_tests.models.test_expectations import TestExpectationParser | 85 from webkitpy.layout_tests.models.test_expectations import TestExpectationParser |
| 86 from webkitpy.w3c.test_parser import TestParser | 86 from webkitpy.w3c.test_parser import TestParser |
| 87 from webkitpy.w3c.test_converter import convert_for_webkit | 87 from webkitpy.w3c.test_converter import convert_for_webkit |
| 88 | 88 |
| 89 | 89 |
| 90 CHANGESET_NOT_AVAILABLE = 'Not Available' | 90 CHANGESET_NOT_AVAILABLE = 'Not Available' |
| 91 | 91 |
| 92 # Maximum length of import path starting from top of source repository. |
| 93 MAX_PATH_LENGTH = 110 |
| 94 |
| 95 # Maximum length of import path starting from top of source repository. |
| 96 MAX_PATH_LENGTH = 110 |
| 97 |
| 92 | 98 |
| 93 _log = logging.getLogger(__name__) | 99 _log = logging.getLogger(__name__) |
| 94 | 100 |
| 95 | 101 |
| 96 def main(_argv, _stdout, _stderr): | 102 def main(_argv, _stdout, _stderr): |
| 97 options, args = parse_args() | 103 options, args = parse_args() |
| 98 dir_to_import = os.path.normpath(os.path.abspath(args[0])) | 104 dir_to_import = os.path.normpath(os.path.abspath(args[0])) |
| 99 if len(args) == 1: | 105 if len(args) == 1: |
| 100 top_of_repo = dir_to_import | 106 top_of_repo = dir_to_import |
| 101 else: | 107 else: |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 self.import_list = [] | 178 self.import_list = [] |
| 173 | 179 |
| 174 def do_import(self): | 180 def do_import(self): |
| 175 _log.info("Importing %s into %s", self.dir_to_import, self.destination_d
irectory) | 181 _log.info("Importing %s into %s", self.dir_to_import, self.destination_d
irectory) |
| 176 self.find_importable_tests(self.dir_to_import) | 182 self.find_importable_tests(self.dir_to_import) |
| 177 self.load_changeset() | 183 self.load_changeset() |
| 178 self.import_tests() | 184 self.import_tests() |
| 179 | 185 |
| 180 def load_changeset(self): | 186 def load_changeset(self): |
| 181 """Returns the current changeset from mercurial or "Not Available".""" | 187 """Returns the current changeset from mercurial or "Not Available".""" |
| 188 # TODO(qyearsley): Remove this, since mercurial isn't used for w3c repos
any more, so this is not applicable. |
| 182 try: | 189 try: |
| 183 self.changeset = self.host.executive.run_command(['hg', 'tip']).spli
t('changeset:')[1] | 190 self.changeset = self.host.executive.run_command(['hg', 'tip']).spli
t('changeset:')[1] |
| 184 except (OSError, ScriptError): | 191 except (OSError, ScriptError): |
| 185 self.changeset = CHANGESET_NOT_AVAILABLE | 192 self.changeset = CHANGESET_NOT_AVAILABLE |
| 186 | 193 |
| 187 def find_importable_tests(self, directory): | 194 def find_importable_tests(self, directory): |
| 188 # FIXME: use filesystem | 195 # FIXME: use filesystem |
| 189 paths_to_skip = self.find_paths_to_skip() | 196 paths_to_skip = self.find_paths_to_skip() |
| 190 | 197 |
| 191 for root, dirs, files in os.walk(directory): | 198 for root, dirs, files in os.walk(directory): |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 | 344 |
| 338 if os.path.isdir(orig_filepath): | 345 if os.path.isdir(orig_filepath): |
| 339 # FIXME: Figure out what is triggering this and what to do a
bout it. | 346 # FIXME: Figure out what is triggering this and what to do a
bout it. |
| 340 _log.error('%s refers to a directory' % orig_filepath) | 347 _log.error('%s refers to a directory' % orig_filepath) |
| 341 continue | 348 continue |
| 342 | 349 |
| 343 if not(os.path.exists(orig_filepath)): | 350 if not(os.path.exists(orig_filepath)): |
| 344 _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) |
| 345 continue | 352 continue |
| 346 | 353 |
| 354 if self.path_too_long(orig_filepath): |
| 355 _log.warning('%s is too long. Skipping.', orig_filepath) |
| 356 |
| 347 new_filepath = os.path.join(new_path, file_to_copy['dest']) | 357 new_filepath = os.path.join(new_path, file_to_copy['dest']) |
| 348 if 'reference_support_info' in file_to_copy.keys() and file_to_c
opy['reference_support_info'] != {}: | 358 if 'reference_support_info' in file_to_copy.keys() and file_to_c
opy['reference_support_info'] != {}: |
| 349 reference_support_info = file_to_copy['reference_support_inf
o'] | 359 reference_support_info = file_to_copy['reference_support_inf
o'] |
| 350 else: | 360 else: |
| 351 reference_support_info = None | 361 reference_support_info = None |
| 352 | 362 |
| 353 if not(os.path.exists(os.path.dirname(new_filepath))): | 363 if not(os.path.exists(os.path.dirname(new_filepath))): |
| 354 if not self.import_in_place and not self.options.dry_run: | 364 if not self.import_in_place and not self.options.dry_run: |
| 355 os.makedirs(os.path.dirname(new_filepath)) | 365 os.makedirs(os.path.dirname(new_filepath)) |
| 356 | 366 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 _log.info('Imported %d reftests', total_imported_reftests) | 406 _log.info('Imported %d reftests', total_imported_reftests) |
| 397 _log.info('Imported %d JS tests', total_imported_jstests) | 407 _log.info('Imported %d JS tests', total_imported_jstests) |
| 398 _log.info('Imported %d pixel/manual tests', total_imported_tests - total
_imported_jstests - total_imported_reftests) | 408 _log.info('Imported %d pixel/manual tests', total_imported_tests - total
_imported_jstests - total_imported_reftests) |
| 399 _log.info('') | 409 _log.info('') |
| 400 | 410 |
| 401 if total_prefixed_properties: | 411 if total_prefixed_properties: |
| 402 _log.info('Properties needing prefixes (by count):') | 412 _log.info('Properties needing prefixes (by count):') |
| 403 for prefixed_property in sorted(total_prefixed_properties, key=lambd
a p: total_prefixed_properties[p]): | 413 for prefixed_property in sorted(total_prefixed_properties, key=lambd
a p: total_prefixed_properties[p]): |
| 404 _log.info(' %s: %s', prefixed_property, total_prefixed_properti
es[prefixed_property]) | 414 _log.info(' %s: %s', prefixed_property, total_prefixed_properti
es[prefixed_property]) |
| 405 | 415 |
| 416 def path_too_long(self, source_path): |
| 417 """Checks whether a source path is too long to import. |
| 418 |
| 419 Args: |
| 420 Absolute path of file to be imported. |
| 421 """ |
| 422 path_from_repo_base = os.path.relpath(source_path, self.top_of_repo) |
| 423 return len(path_from_repo_base) > MAX_PATH_LENGTH |
| 424 |
| 406 def setup_destination_directory(self): | 425 def setup_destination_directory(self): |
| 407 """ Creates a destination directory that mirrors that of the source dire
ctory """ | 426 """ Creates a destination directory that mirrors that of the source dire
ctory """ |
| 408 | 427 |
| 409 new_subpath = self.dir_to_import[len(self.top_of_repo):] | 428 new_subpath = self.dir_to_import[len(self.top_of_repo):] |
| 410 | 429 |
| 411 destination_directory = os.path.join(self.destination_directory, new_sub
path) | 430 destination_directory = os.path.join(self.destination_directory, new_sub
path) |
| 412 | 431 |
| 413 if not os.path.exists(destination_directory): | 432 if not os.path.exists(destination_directory): |
| 414 os.makedirs(destination_directory) | 433 os.makedirs(destination_directory) |
| 415 | 434 |
| 416 _log.info('Tests will be imported into: %s', destination_directory) | 435 _log.info('Tests will be imported into: %s', destination_directory) |
| OLD | NEW |