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