| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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.webkit_finder = WebKitFinder(self.filesystem) |
| 63 self._webkit_root = self.webkit_finder.webkit_base() | |
| 64 self.layout_tests_dir = self.webkit_finder.layout_tests_dir() | 63 self.layout_tests_dir = self.webkit_finder.layout_tests_dir() |
| 65 self.destination_directory = self.filesystem.normpath( | 64 self.destination_directory = self.filesystem.normpath( |
| 66 self.filesystem.join( | 65 self.filesystem.join( |
| 67 self.layout_tests_dir, | 66 self.layout_tests_dir, |
| 68 dest_dir_name, | 67 dest_dir_name, |
| 69 self.filesystem.basename(self.source_repo_path))) | 68 self.filesystem.basename(self.source_repo_path))) |
| 70 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) |
| 71 self.dir_above_repo = self.filesystem.dirname(self.source_repo_path) | 70 self.dir_above_repo = self.filesystem.dirname(self.source_repo_path) |
| 72 | 71 |
| 73 self.import_list = [] | 72 self.import_list = [] |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 continue | 160 continue |
| 162 | 161 |
| 163 orig_path = dir_to_copy['dirname'] | 162 orig_path = dir_to_copy['dirname'] |
| 164 | 163 |
| 165 relative_dir = self.filesystem.relpath(orig_path, self.source_repo_p
ath) | 164 relative_dir = self.filesystem.relpath(orig_path, self.source_repo_p
ath) |
| 166 dest_dir = self.filesystem.join(self.destination_directory, relative
_dir) | 165 dest_dir = self.filesystem.join(self.destination_directory, relative
_dir) |
| 167 | 166 |
| 168 if not self.filesystem.exists(dest_dir): | 167 if not self.filesystem.exists(dest_dir): |
| 169 self.filesystem.maybe_make_directory(dest_dir) | 168 self.filesystem.maybe_make_directory(dest_dir) |
| 170 | 169 |
| 171 copied_files = [] | |
| 172 | |
| 173 for file_to_copy in dir_to_copy['copy_list']: | 170 for file_to_copy in dir_to_copy['copy_list']: |
| 174 copied_file = self.copy_file(file_to_copy, dest_dir) | 171 self.copy_file(file_to_copy, dest_dir) |
| 175 if copied_file: | |
| 176 copied_files.append(copied_file) | |
| 177 | 172 |
| 178 _log.info('') | 173 _log.info('') |
| 179 _log.info('Import complete') | 174 _log.info('Import complete') |
| 180 _log.info('') | 175 _log.info('') |
| 181 | 176 |
| 182 if self._prefixed_properties: | 177 if self._prefixed_properties: |
| 183 _log.info('Properties needing prefixes (by count):') | 178 _log.info('Properties needing prefixes (by count):') |
| 184 for prefixed_property in sorted(self._prefixed_properties, key=lambd
a p: self._prefixed_properties[p]): | 179 for prefixed_property in sorted(self._prefixed_properties, key=lambd
a p: self._prefixed_properties[p]): |
| 185 _log.info(' %s: %s', prefixed_property, self._prefixed_properti
es[prefixed_property]) | 180 _log.info(' %s: %s', prefixed_property, self._prefixed_properti
es[prefixed_property]) |
| 186 | 181 |
| 187 def copy_file(self, file_to_copy, dest_dir): | 182 def copy_file(self, file_to_copy, dest_dir): |
| 188 """Converts and copies a file, if it should be copied. | 183 """Converts and copies a file, if it should be copied. |
| 189 | 184 |
| 190 Args: | 185 Args: |
| 191 file_to_copy: A dict in a file copy list constructed by | 186 file_to_copy: A dict in a file copy list constructed by |
| 192 find_importable_tests, which represents one file to copy, includ
ing | 187 find_importable_tests, which represents one file to copy, includ
ing |
| 193 the keys: | 188 the keys: |
| 194 "src": Absolute path to the source location of the file. | 189 "src": Absolute path to the source location of the file. |
| 195 "destination": File name of the destination file. | 190 "destination": File name of the destination file. |
| 196 And possibly also the keys "reference_support_info" or "is_jstes
t". | 191 And possibly also the keys "reference_support_info" or "is_jstes
t". |
| 197 dest_dir: Path to the directory where the file should be copied. | 192 dest_dir: Path to the directory where the file should be copied. |
| 198 | |
| 199 Returns: | |
| 200 The path to the new file, relative to the Blink root (//third_party/
WebKit). | |
| 201 """ | 193 """ |
| 202 source_path = self.filesystem.normpath(file_to_copy['src']) | 194 source_path = self.filesystem.normpath(file_to_copy['src']) |
| 203 dest_path = self.filesystem.join(dest_dir, file_to_copy['dest']) | 195 dest_path = self.filesystem.join(dest_dir, file_to_copy['dest']) |
| 204 | 196 |
| 205 if self.filesystem.isdir(source_path): | 197 if self.filesystem.isdir(source_path): |
| 206 _log.error('%s refers to a directory', source_path) | 198 _log.error('%s refers to a directory', source_path) |
| 207 return None | 199 return |
| 208 | 200 |
| 209 if not self.filesystem.exists(source_path): | 201 if not self.filesystem.exists(source_path): |
| 210 _log.error('%s not found. Possible error in the test.', source_path) | 202 _log.error('%s not found. Possible error in the test.', source_path) |
| 211 return None | 203 return |
| 212 | 204 |
| 213 if not self.filesystem.exists(self.filesystem.dirname(dest_path)): | 205 if not self.filesystem.exists(self.filesystem.dirname(dest_path)): |
| 214 if not self.import_in_place: | 206 if not self.import_in_place: |
| 215 self.filesystem.maybe_make_directory(self.filesystem.dirname(des
t_path)) | 207 self.filesystem.maybe_make_directory(self.filesystem.dirname(des
t_path)) |
| 216 | 208 |
| 217 relpath = self.filesystem.relpath(dest_path, self.layout_tests_dir) | 209 relpath = self.filesystem.relpath(dest_path, self.layout_tests_dir) |
| 218 # 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? |
| 219 # 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 |
| 220 # there's no harm in copying the identical thing. | 212 # there's no harm in copying the identical thing. |
| 221 _log.debug(' copying %s', relpath) | 213 _log.debug(' copying %s', relpath) |
| 222 | 214 |
| 223 if not self.import_in_place: | 215 if not self.import_in_place: |
| 224 self.filesystem.copyfile(source_path, dest_path) | 216 self.filesystem.copyfile(source_path, dest_path) |
| 225 if self.filesystem.read_binary_file(source_path)[:2] == '#!': | 217 if self.filesystem.read_binary_file(source_path)[:2] == '#!': |
| 226 self.filesystem.make_executable(dest_path) | 218 self.filesystem.make_executable(dest_path) |
| 227 | |
| 228 return dest_path.replace(self._webkit_root, '') | |
| OLD | NEW |