| 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 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 """Logic for converting and copying files from a W3C repo. | 28 """Logic for converting and copying files from a W3C repo. |
| 29 | 29 |
| 30 This module is responsible for modifying and copying a subset of the tests from | 30 This module is responsible for modifying and copying a subset of the tests from |
| 31 a local W3C repository source directory into a destination directory. | 31 a local W3C repository source directory into a destination directory. |
| 32 """ | 32 """ |
| 33 | 33 |
| 34 import logging | 34 import logging |
| 35 import mimetypes | 35 import mimetypes |
| 36 | 36 |
| 37 from webkitpy.common.webkit_finder import WebKitFinder | 37 from webkitpy.common.path_finder import PathFinder |
| 38 from webkitpy.layout_tests.models.test_expectations import TestExpectationParser | 38 from webkitpy.layout_tests.models.test_expectations import TestExpectationParser |
| 39 | 39 |
| 40 _log = logging.getLogger(__name__) | 40 _log = logging.getLogger(__name__) |
| 41 | 41 |
| 42 | 42 |
| 43 class TestCopier(object): | 43 class TestCopier(object): |
| 44 | 44 |
| 45 def __init__(self, host, source_repo_path, dest_dir_name='external'): | 45 def __init__(self, host, source_repo_path, dest_dir_name='external'): |
| 46 """Initializes variables to prepare for copying and converting files. | 46 """Initializes variables to prepare for copying and converting files. |
| 47 | 47 |
| 48 Args: | 48 Args: |
| 49 host: An instance of Host. | 49 host: An instance of Host. |
| 50 source_repo_path: Path to the local checkout of web-platform-tests. | 50 source_repo_path: Path to the local checkout of web-platform-tests. |
| 51 dest_dir_name: The name of the directory under the layout tests | 51 dest_dir_name: The name of the directory under the layout tests |
| 52 directory where imported tests should be copied to. | 52 directory where imported tests should be copied to. |
| 53 TODO(qyearsley): This can be made into a constant. | 53 TODO(qyearsley): This can be made into a constant. |
| 54 """ | 54 """ |
| 55 self.host = host | 55 self.host = host |
| 56 | 56 |
| 57 assert self.host.filesystem.exists(source_repo_path) | 57 assert self.host.filesystem.exists(source_repo_path) |
| 58 self.source_repo_path = source_repo_path | 58 self.source_repo_path = source_repo_path |
| 59 self.dest_dir_name = dest_dir_name | 59 self.dest_dir_name = dest_dir_name |
| 60 | 60 |
| 61 self.filesystem = self.host.filesystem | 61 self.filesystem = self.host.filesystem |
| 62 self.webkit_finder = WebKitFinder(self.filesystem) | 62 self.path_finder = PathFinder(self.filesystem) |
| 63 self.layout_tests_dir = self.webkit_finder.layout_tests_dir() | 63 self.layout_tests_dir = self.path_finder.layout_tests_dir() |
| 64 self.destination_directory = self.filesystem.normpath( | 64 self.destination_directory = self.filesystem.normpath( |
| 65 self.filesystem.join( | 65 self.filesystem.join( |
| 66 self.layout_tests_dir, | 66 self.layout_tests_dir, |
| 67 dest_dir_name, | 67 dest_dir_name, |
| 68 self.filesystem.basename(self.source_repo_path))) | 68 self.filesystem.basename(self.source_repo_path))) |
| 69 self.import_in_place = (self.source_repo_path == self.destination_direct
ory) | 69 self.import_in_place = (self.source_repo_path == self.destination_direct
ory) |
| 70 self.dir_above_repo = self.filesystem.dirname(self.source_repo_path) | 70 self.dir_above_repo = self.filesystem.dirname(self.source_repo_path) |
| 71 | 71 |
| 72 self.import_list = [] | 72 self.import_list = [] |
| 73 | 73 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 134 |
| 135 copy_list.append({'src': path_full, 'dest': filename}) | 135 copy_list.append({'src': path_full, 'dest': filename}) |
| 136 | 136 |
| 137 if copy_list: | 137 if copy_list: |
| 138 # Only add this directory to the list if there's something to im
port | 138 # Only add this directory to the list if there's something to im
port |
| 139 self.import_list.append({'dirname': root, 'copy_list': copy_list
}) | 139 self.import_list.append({'dirname': root, 'copy_list': copy_list
}) |
| 140 | 140 |
| 141 def find_paths_to_skip(self): | 141 def find_paths_to_skip(self): |
| 142 paths_to_skip = set() | 142 paths_to_skip = set() |
| 143 port = self.host.port_factory.get() | 143 port = self.host.port_factory.get() |
| 144 w3c_import_expectations_path = self.webkit_finder.path_from_layout_tests
('W3CImportExpectations') | 144 w3c_import_expectations_path = self.path_finder.path_from_layout_tests('
W3CImportExpectations') |
| 145 w3c_import_expectations = self.filesystem.read_text_file(w3c_import_expe
ctations_path) | 145 w3c_import_expectations = self.filesystem.read_text_file(w3c_import_expe
ctations_path) |
| 146 parser = TestExpectationParser(port, all_tests=(), is_lint_mode=False) | 146 parser = TestExpectationParser(port, all_tests=(), is_lint_mode=False) |
| 147 expectation_lines = parser.parse(w3c_import_expectations_path, w3c_impor
t_expectations) | 147 expectation_lines = parser.parse(w3c_import_expectations_path, w3c_impor
t_expectations) |
| 148 for line in expectation_lines: | 148 for line in expectation_lines: |
| 149 if 'SKIP' in line.expectations: | 149 if 'SKIP' in line.expectations: |
| 150 if line.specifiers: | 150 if line.specifiers: |
| 151 _log.warning('W3CImportExpectations:%s should not have any s
pecifiers', line.line_numbers) | 151 _log.warning('W3CImportExpectations:%s should not have any s
pecifiers', line.line_numbers) |
| 152 continue | 152 continue |
| 153 paths_to_skip.add(line.name) | 153 paths_to_skip.add(line.name) |
| 154 return paths_to_skip | 154 return paths_to_skip |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 relpath = self.filesystem.relpath(dest_path, self.layout_tests_dir) | 209 relpath = self.filesystem.relpath(dest_path, self.layout_tests_dir) |
| 210 # FIXME: Maybe doing a file diff is in order here for existing files? | 210 # FIXME: Maybe doing a file diff is in order here for existing files? |
| 211 # In other words, there's no sense in overwriting identical files, but | 211 # In other words, there's no sense in overwriting identical files, but |
| 212 # there's no harm in copying the identical thing. | 212 # there's no harm in copying the identical thing. |
| 213 _log.debug(' copying %s', relpath) | 213 _log.debug(' copying %s', relpath) |
| 214 | 214 |
| 215 if not self.import_in_place: | 215 if not self.import_in_place: |
| 216 self.filesystem.copyfile(source_path, dest_path) | 216 self.filesystem.copyfile(source_path, dest_path) |
| 217 if self.filesystem.read_binary_file(source_path)[:2] == '#!': | 217 if self.filesystem.read_binary_file(source_path)[:2] == '#!': |
| 218 self.filesystem.make_executable(dest_path) | 218 self.filesystem.make_executable(dest_path) |
| OLD | NEW |