Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_copier.py

Issue 2651673017: W3C test importer: improve log messages printed when skipping. (Closed)
Patch Set: Rebased Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_copier_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 _log = logging.getLogger(__name__) 49 _log = logging.getLogger(__name__)
50 50
51 51
52 class TestCopier(object): 52 class TestCopier(object):
53 53
54 def __init__(self, host, source_repo_path, dest_dir_name='external'): 54 def __init__(self, host, source_repo_path, dest_dir_name='external'):
55 """Initializes variables to prepare for copying and converting files. 55 """Initializes variables to prepare for copying and converting files.
56 56
57 Args: 57 Args:
58 source_repo_path: Path to the local checkout of a WPT 58 host: An instance of Host.
59 source_repo_path: Path to the local checkout of a
60 web-platform-tests or csswg-test repository.
61 dest_dir_name: The name of the directory under the layout tests
62 directory where imported tests should be copied to.
63 TODO(qyearsley): This can be made into a constant.
59 """ 64 """
60 self.host = host 65 self.host = host
61 66
62 assert self.host.filesystem.exists(source_repo_path) 67 assert self.host.filesystem.exists(source_repo_path)
63 self.source_repo_path = source_repo_path 68 self.source_repo_path = source_repo_path
64 self.dest_dir_name = dest_dir_name 69 self.dest_dir_name = dest_dir_name
65 70
66 self.filesystem = self.host.filesystem 71 self.filesystem = self.host.filesystem
67 self.webkit_finder = WebKitFinder(self.filesystem) 72 self.webkit_finder = WebKitFinder(self.filesystem)
68 self._webkit_root = self.webkit_finder.webkit_base() 73 self._webkit_root = self.webkit_finder.webkit_base()
(...skipping 20 matching lines...) Expand all
89 def find_importable_tests(self): 94 def find_importable_tests(self):
90 """Walks through the source directory to find what tests should be impor ted. 95 """Walks through the source directory to find what tests should be impor ted.
91 96
92 This function sets self.import_list, which contains information about ho w many 97 This function sets self.import_list, which contains information about ho w many
93 tests are being imported, and their source and destination paths. 98 tests are being imported, and their source and destination paths.
94 """ 99 """
95 paths_to_skip = self.find_paths_to_skip() 100 paths_to_skip = self.find_paths_to_skip()
96 101
97 for root, dirs, files in self.filesystem.walk(self.source_repo_path): 102 for root, dirs, files in self.filesystem.walk(self.source_repo_path):
98 cur_dir = root.replace(self.dir_above_repo + '/', '') + '/' 103 cur_dir = root.replace(self.dir_above_repo + '/', '') + '/'
99 _log.debug(' scanning ' + cur_dir + '...') 104 _log.debug('Scanning %s...', cur_dir)
100 total_tests = 0 105 total_tests = 0
101 reftests = 0 106 reftests = 0
102 jstests = 0 107 jstests = 0
103 108
104 # Files in 'tools' are not for browser testing, so we skip them. 109 # Files in 'tools' are not for browser testing, so we skip them.
105 # See: http://testthewebforward.org/docs/test-format-guidelines.html #tools 110 # See: http://testthewebforward.org/docs/test-format-guidelines.html #tools
106 dirs_to_skip = ('.git', 'test-plan', 'tools') 111 dirs_to_skip = ('.git', 'test-plan', 'tools')
107 112
108 # We copy all files in 'support', including HTML without metadata. 113 # We copy all files in 'support', including HTML without metadata.
109 # See: http://testthewebforward.org/docs/test-format-guidelines.html #support-files 114 # See: http://testthewebforward.org/docs/test-format-guidelines.html #support-files
110 dirs_to_include = ('resources', 'support') 115 dirs_to_include = ('resources', 'support')
111 116
112 if dirs: 117 if dirs:
113 for name in dirs_to_skip: 118 for name in dirs_to_skip:
114 if name in dirs: 119 if name in dirs:
115 dirs.remove(name) 120 dirs.remove(name)
116 121
117 for path in paths_to_skip: 122 for path in paths_to_skip:
118 path_base = path.replace(self.dest_dir_name + '/', '') 123 path_base = path.replace(self.dest_dir_name + '/', '')
119 path_base = path_base.replace(cur_dir, '') 124 path_base = path_base.replace(cur_dir, '')
120 path_full = self.filesystem.join(root, path_base) 125 path_full = self.filesystem.join(root, path_base)
121 if path_base in dirs: 126 if path_base in dirs:
127 _log.info('Skipping: %s', path_full)
122 dirs.remove(path_base) 128 dirs.remove(path_base)
123 if self.import_in_place: 129 if self.import_in_place:
124 _log.debug(' pruning %s', path_base)
125 self.filesystem.rmtree(path_full) 130 self.filesystem.rmtree(path_full)
126 else:
127 _log.debug(' skipping %s', path_base)
128 131
129 copy_list = [] 132 copy_list = []
130 133
131 for filename in files: 134 for filename in files:
132 path_full = self.filesystem.join(root, filename) 135 path_full = self.filesystem.join(root, filename)
133 path_base = path_full.replace(self.source_repo_path + '/', '') 136 path_base = path_full.replace(self.source_repo_path + '/', '')
134 path_base = self.destination_directory.replace(self.layout_tests _dir + '/', '') + '/' + path_base 137 path_base = self.destination_directory.replace(self.layout_tests _dir + '/', '') + '/' + path_base
135 if path_base in paths_to_skip: 138 if path_base in paths_to_skip:
136 if self.import_in_place: 139 if self.import_in_place:
137 _log.debug(' pruning %s', path_base) 140 _log.debug('Pruning: %s', path_base)
138 self.filesystem.remove(path_full) 141 self.filesystem.remove(path_full)
139 continue 142 continue
140 else: 143 else:
141 continue 144 continue
142 # FIXME: This block should really be a separate function, but th e early-continues make that difficult. 145 # FIXME: This block should really be a separate function, but th e early-continues make that difficult.
143 146
144 if filename.startswith('.') or filename.endswith('.pl'): 147 if filename.startswith('.') or filename.endswith('.pl'):
145 # The w3cs repos may contain perl scripts, which we don't ca re about. 148 _log.info('Skipping: %s', path_full)
149 _log.info(' Reason: Hidden files and perl scripts are not n ecessary.')
146 continue 150 continue
147 if filename == 'OWNERS' or filename == 'reftest.list': 151 if filename == 'OWNERS' or filename == 'reftest.list':
148 # These files fail our presubmits.
149 # See http://crbug.com/584660 and http://crbug.com/582838. 152 # See http://crbug.com/584660 and http://crbug.com/582838.
153 _log.info('Skipping: %s', path_full)
154 _log.info(' Reason: This file may cause Chromium presubmit to fail.')
155 continue
156 if self.path_too_long(path_full):
157 _log.warning('Skipping: %s', path_full)
158 _log.warning(' Reason: Long path. Max length %d; see http:/ /crbug.com/609871.', MAX_PATH_LENGTH)
150 continue 159 continue
151 160
152 mimetype = mimetypes.guess_type(path_full) 161 mimetype = mimetypes.guess_type(path_full)
153 if ('html' not in str(mimetype[0]) and 162 if ('html' not in str(mimetype[0]) and
154 'application/xhtml+xml' not in str(mimetype[0]) and 163 'application/xhtml+xml' not in str(mimetype[0]) and
155 'application/xml' not in str(mimetype[0])): 164 'application/xml' not in str(mimetype[0])):
156 copy_list.append({'src': path_full, 'dest': filename}) 165 copy_list.append({'src': path_full, 'dest': filename})
157 continue 166 continue
158 167
159 if self.filesystem.basename(root) in dirs_to_include: 168 if self.filesystem.basename(root) in dirs_to_include:
160 copy_list.append({'src': path_full, 'dest': filename}) 169 copy_list.append({'src': path_full, 'dest': filename})
161 continue 170 continue
162 171
163 test_parser = TestParser(path_full, self.host) 172 test_parser = TestParser(path_full, self.host)
164 test_info = test_parser.analyze_test() 173 test_info = test_parser.analyze_test()
165 if test_info is None: 174 if test_info is None:
166 copy_list.append({'src': path_full, 'dest': filename}) 175 copy_list.append({'src': path_full, 'dest': filename})
167 continue 176 continue
168 177
169 if self.path_too_long(path_full):
170 _log.warning('%s skipped due to long path. '
171 'Max length from repo base %d chars; see http:/ /crbug.com/609871.',
172 path_full, MAX_PATH_LENGTH)
173 continue
174
175 if 'reference' in test_info.keys(): 178 if 'reference' in test_info.keys():
176 test_basename = self.filesystem.basename(test_info['test']) 179 test_basename = self.filesystem.basename(test_info['test'])
177 # Add the ref file, following WebKit style. 180 # Add the ref file, following WebKit style.
178 # FIXME: Ideally we'd support reading the metadata 181 # FIXME: Ideally we'd support reading the metadata
179 # directly rather than relying on a naming convention. 182 # directly rather than relying on a naming convention.
180 # Using a naming convention creates duplicate copies of the 183 # Using a naming convention creates duplicate copies of the
181 # reference files (http://crrev.com/268729). 184 # reference files (http://crrev.com/268729).
182 ref_file = self.filesystem.splitext(test_basename)[0] + '-ex pected' 185 ref_file = self.filesystem.splitext(test_basename)[0] + '-ex pected'
183 # Make sure to use the extension from the *reference*, not 186 # Make sure to use the extension from the *reference*, not
184 # from the test, because at least flexbox tests use XHTML 187 # from the test, because at least flexbox tests use XHTML
185 # references but HTML tests. 188 # references but HTML tests.
186 ref_file += self.filesystem.splitext(test_info['reference']) [1] 189 ref_file += self.filesystem.splitext(test_info['reference']) [1]
187 190
188 if not self.filesystem.exists(test_info['reference']): 191 if not self.filesystem.exists(test_info['reference']):
189 _log.warning('%s skipped because ref file %s was not fou nd.', 192 _log.warning('Skipping: %s', path_full)
190 path_full, ref_file) 193 _log.warning(' Reason: Ref file "%s" was not found.', r ef_file)
191 continue 194 continue
192 195
193 if self.path_too_long(path_full.replace(filename, ref_file)) : 196 if self.path_too_long(path_full.replace(filename, ref_file)) :
194 _log.warning('%s skipped because path of ref file %s wou ld be too long. ' 197 _log.warning('Skipping: %s', path_full)
195 'Max length from repo base %d chars; see ht tp://crbug.com/609871.', 198 _log.warning(' Reason: Ref file path length would be to o long: %s.', ref_file)
196 path_full, ref_file, MAX_PATH_LENGTH) 199 _log.warning(' Max length %d; see http://crbug.com/6098 71.', MAX_PATH_LENGTH)
197 continue 200 continue
198 201
199 reftests += 1 202 reftests += 1
200 total_tests += 1 203 total_tests += 1
201 copy_list.append({'src': test_info['reference'], 'dest': ref _file, 204 copy_list.append({'src': test_info['reference'], 'dest': ref _file,
202 'reference_support_info': test_info['refer ence_support_info']}) 205 'reference_support_info': test_info['refer ence_support_info']})
203 copy_list.append({'src': test_info['test'], 'dest': filename }) 206 copy_list.append({'src': test_info['test'], 'dest': filename })
204 207
205 elif 'jstest' in test_info.keys(): 208 elif 'jstest' in test_info.keys():
206 jstests += 1 209 jstests += 1
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 """Checks whether a source path is too long to import. 348 """Checks whether a source path is too long to import.
346 349
347 Args: 350 Args:
348 Absolute path of file to be imported. 351 Absolute path of file to be imported.
349 352
350 Returns: 353 Returns:
351 True if the path is too long to import, False if it's OK. 354 True if the path is too long to import, False if it's OK.
352 """ 355 """
353 path_from_repo_base = os.path.relpath(source_path, self.source_repo_path ) 356 path_from_repo_base = os.path.relpath(source_path, self.source_repo_path )
354 return len(path_from_repo_base) > MAX_PATH_LENGTH 357 return len(path_from_repo_base) > MAX_PATH_LENGTH
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_copier_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698