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

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: Add back reason, change debug to info 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.
qyearsley 2017/01/28 20:27:29 I think that in an earlier change, I started to wr
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 fullpath = self.filesystem.join(root, filename) 161 fullpath = self.filesystem.join(root, filename)
153 162
154 mimetype = mimetypes.guess_type(fullpath) 163 mimetype = mimetypes.guess_type(fullpath)
155 if ('html' not in str(mimetype[0]) and 164 if ('html' not in str(mimetype[0]) and
156 'application/xhtml+xml' not in str(mimetype[0]) and 165 'application/xhtml+xml' not in str(mimetype[0]) and
157 'application/xml' not in str(mimetype[0])): 166 'application/xml' not in str(mimetype[0])):
158 copy_list.append({'src': fullpath, 'dest': filename}) 167 copy_list.append({'src': fullpath, 'dest': filename})
159 continue 168 continue
160 169
161 if self.filesystem.basename(root) in dirs_to_include: 170 if self.filesystem.basename(root) in dirs_to_include:
162 copy_list.append({'src': fullpath, 'dest': filename}) 171 copy_list.append({'src': fullpath, 'dest': filename})
163 continue 172 continue
164 173
165 test_parser = TestParser(fullpath, self.host) 174 test_parser = TestParser(fullpath, self.host)
166 test_info = test_parser.analyze_test() 175 test_info = test_parser.analyze_test()
167 if test_info is None: 176 if test_info is None:
168 copy_list.append({'src': fullpath, 'dest': filename}) 177 copy_list.append({'src': fullpath, 'dest': filename})
169 continue 178 continue
170 179
171 if self.path_too_long(path_full):
172 _log.warning('%s skipped due to long path. '
173 'Max length from repo base %d chars; see http:/ /crbug.com/609871.',
174 path_full, MAX_PATH_LENGTH)
175 continue
176
177 if 'reference' in test_info.keys(): 180 if 'reference' in test_info.keys():
178 test_basename = self.filesystem.basename(test_info['test']) 181 test_basename = self.filesystem.basename(test_info['test'])
179 # Add the ref file, following WebKit style. 182 # Add the ref file, following WebKit style.
180 # FIXME: Ideally we'd support reading the metadata 183 # FIXME: Ideally we'd support reading the metadata
181 # directly rather than relying on a naming convention. 184 # directly rather than relying on a naming convention.
182 # Using a naming convention creates duplicate copies of the 185 # Using a naming convention creates duplicate copies of the
183 # reference files (http://crrev.com/268729). 186 # reference files (http://crrev.com/268729).
184 ref_file = self.filesystem.splitext(test_basename)[0] + '-ex pected' 187 ref_file = self.filesystem.splitext(test_basename)[0] + '-ex pected'
185 # Make sure to use the extension from the *reference*, not 188 # Make sure to use the extension from the *reference*, not
186 # from the test, because at least flexbox tests use XHTML 189 # from the test, because at least flexbox tests use XHTML
187 # references but HTML tests. 190 # references but HTML tests.
188 ref_file += self.filesystem.splitext(test_info['reference']) [1] 191 ref_file += self.filesystem.splitext(test_info['reference']) [1]
189 192
190 if not self.filesystem.exists(test_info['reference']): 193 if not self.filesystem.exists(test_info['reference']):
191 _log.warning('%s skipped because ref file %s was not fou nd.', 194 _log.warning('Skipping: %s', path_full)
192 path_full, ref_file) 195 _log.warning(' Reason: Ref file "%s" was not found.', r ef_file)
193 continue 196 continue
194 197
195 if self.path_too_long(path_full.replace(filename, ref_file)) : 198 if self.path_too_long(path_full.replace(filename, ref_file)) :
196 _log.warning('%s skipped because path of ref file %s wou ld be too long. ' 199 _log.warning('Skipping: %s', path_full)
197 'Max length from repo base %d chars; see ht tp://crbug.com/609871.', 200 _log.warning(' Reason: Ref file path length would be to o long: %s.', ref_file)
198 path_full, ref_file, MAX_PATH_LENGTH) 201 _log.warning(' Max length %d; see http://crbug.com/6098 71.', MAX_PATH_LENGTH)
199 continue 202 continue
200 203
201 reftests += 1 204 reftests += 1
202 total_tests += 1 205 total_tests += 1
203 copy_list.append({'src': test_info['reference'], 'dest': ref _file, 206 copy_list.append({'src': test_info['reference'], 'dest': ref _file,
204 'reference_support_info': test_info['refer ence_support_info']}) 207 'reference_support_info': test_info['refer ence_support_info']})
205 copy_list.append({'src': test_info['test'], 'dest': filename }) 208 copy_list.append({'src': test_info['test'], 'dest': filename })
206 209
207 elif 'jstest' in test_info.keys(): 210 elif 'jstest' in test_info.keys():
208 jstests += 1 211 jstests += 1
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 """Checks whether a source path is too long to import. 350 """Checks whether a source path is too long to import.
348 351
349 Args: 352 Args:
350 Absolute path of file to be imported. 353 Absolute path of file to be imported.
351 354
352 Returns: 355 Returns:
353 True if the path is too long to import, False if it's OK. 356 True if the path is too long to import, False if it's OK.
354 """ 357 """
355 path_from_repo_base = os.path.relpath(source_path, self.source_repo_path ) 358 path_from_repo_base = os.path.relpath(source_path, self.source_repo_path )
356 return len(path_from_repo_base) > MAX_PATH_LENGTH 359 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