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

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

Issue 2632083003: Fix pylint warnings in test_importer.py. (Closed)
Patch Set: Created 3 years, 11 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 | no next file » | 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 'By default, they will be overwritten.')) 123 'By default, they will be overwritten.'))
124 parser.add_option('-a', '--all', action='store_true', default=False, 124 parser.add_option('-a', '--all', action='store_true', default=False,
125 help=('Import all tests including reftests, JS tests, and manual/pixel tests. ' 125 help=('Import all tests including reftests, JS tests, and manual/pixel tests. '
126 'By default, only reftests and JS tests are imported .')) 126 'By default, only reftests and JS tests are imported .'))
127 parser.add_option('-d', '--dest-dir', dest='destination', default='w3c', 127 parser.add_option('-d', '--dest-dir', dest='destination', default='w3c',
128 help=('Import into a specified directory relative to the L ayoutTests root. ' 128 help=('Import into a specified directory relative to the L ayoutTests root. '
129 'By default, files are imported under LayoutTests/w3 c.')) 129 'By default, files are imported under LayoutTests/w3 c.'))
130 parser.add_option('--ignore-expectations', action='store_true', default=Fals e, 130 parser.add_option('--ignore-expectations', action='store_true', default=Fals e,
131 help='Ignore the W3CImportExpectations file and import eve rything.') 131 help='Ignore the W3CImportExpectations file and import eve rything.')
132 parser.add_option('--dry-run', action='store_true', default=False, 132 parser.add_option('--dry-run', action='store_true', default=False,
133 help='Dryrun only (don\'t actually write any results).') 133 help='Dry run only (don\'t actually write any results).')
134 134
135 options, args = parser.parse_args() 135 options, args = parser.parse_args()
136 if len(args) != 1: 136 if len(args) != 1:
137 parser.error('Incorrect number of arguments; source repo path is require d.') 137 parser.error('Incorrect number of arguments; source repo path is require d.')
138 return options, args 138 return options, args
139 139
140 140
141 class TestImporter(object): 141 class TestImporter(object):
142 142
143 def __init__(self, host, source_repo_path, options): 143 def __init__(self, host, source_repo_path, options):
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 178
179 for root, dirs, files in self.filesystem.walk(self.source_repo_path): 179 for root, dirs, files in self.filesystem.walk(self.source_repo_path):
180 cur_dir = root.replace(self.dir_above_repo + '/', '') + '/' 180 cur_dir = root.replace(self.dir_above_repo + '/', '') + '/'
181 _log.info(' scanning ' + cur_dir + '...') 181 _log.info(' scanning ' + cur_dir + '...')
182 total_tests = 0 182 total_tests = 0
183 reftests = 0 183 reftests = 0
184 jstests = 0 184 jstests = 0
185 185
186 # Files in 'tools' are not for browser testing, so we skip them. 186 # Files in 'tools' are not for browser testing, so we skip them.
187 # See: http://testthewebforward.org/docs/test-format-guidelines.html #tools 187 # See: http://testthewebforward.org/docs/test-format-guidelines.html #tools
188 DIRS_TO_SKIP = ('.git', 'test-plan', 'tools') 188 dirs_to_skip = ('.git', 'test-plan', 'tools')
189 189
190 # We copy all files in 'support', including HTML without metadata. 190 # We copy all files in 'support', including HTML without metadata.
191 # See: http://testthewebforward.org/docs/test-format-guidelines.html #support-files 191 # See: http://testthewebforward.org/docs/test-format-guidelines.html #support-files
192 DIRS_TO_INCLUDE = ('resources', 'support') 192 dirs_to_include = ('resources', 'support')
193 193
194 if dirs: 194 if dirs:
195 for d in DIRS_TO_SKIP: 195 for name in dirs_to_skip:
196 if d in dirs: 196 if name in dirs:
197 dirs.remove(d) 197 dirs.remove(name)
198 198
199 for path in paths_to_skip: 199 for path in paths_to_skip:
200 path_base = path.replace(self.options.destination + '/', '') 200 path_base = path.replace(self.options.destination + '/', '')
201 path_base = path_base.replace(cur_dir, '') 201 path_base = path_base.replace(cur_dir, '')
202 path_full = self.filesystem.join(root, path_base) 202 path_full = self.filesystem.join(root, path_base)
203 if path_base in dirs: 203 if path_base in dirs:
204 dirs.remove(path_base) 204 dirs.remove(path_base)
205 if not self.options.dry_run and self.import_in_place: 205 if not self.options.dry_run and self.import_in_place:
206 _log.info(" pruning %s", path_base) 206 _log.info(" pruning %s", path_base)
207 self.filesystem.rmtree(path_full) 207 self.filesystem.rmtree(path_full)
(...skipping 25 matching lines...) Expand all
233 233
234 fullpath = self.filesystem.join(root, filename) 234 fullpath = self.filesystem.join(root, filename)
235 235
236 mimetype = mimetypes.guess_type(fullpath) 236 mimetype = mimetypes.guess_type(fullpath)
237 if ('html' not in str(mimetype[0]) and 237 if ('html' not in str(mimetype[0]) and
238 'application/xhtml+xml' not in str(mimetype[0]) and 238 'application/xhtml+xml' not in str(mimetype[0]) and
239 'application/xml' not in str(mimetype[0])): 239 'application/xml' not in str(mimetype[0])):
240 copy_list.append({'src': fullpath, 'dest': filename}) 240 copy_list.append({'src': fullpath, 'dest': filename})
241 continue 241 continue
242 242
243 if self.filesystem.basename(root) in DIRS_TO_INCLUDE: 243 if self.filesystem.basename(root) in dirs_to_include:
244 copy_list.append({'src': fullpath, 'dest': filename}) 244 copy_list.append({'src': fullpath, 'dest': filename})
245 continue 245 continue
246 246
247 test_parser = TestParser(fullpath, self.host) 247 test_parser = TestParser(fullpath, self.host)
248 test_info = test_parser.analyze_test() 248 test_info = test_parser.analyze_test()
249 if test_info is None: 249 if test_info is None:
250 copy_list.append({'src': fullpath, 'dest': filename}) 250 copy_list.append({'src': fullpath, 'dest': filename})
251 continue 251 continue
252 252
253 if self.path_too_long(path_full): 253 if self.path_too_long(path_full):
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 """Checks whether a source path is too long to import. 443 """Checks whether a source path is too long to import.
444 444
445 Args: 445 Args:
446 Absolute path of file to be imported. 446 Absolute path of file to be imported.
447 447
448 Returns: 448 Returns:
449 True if the path is too long to import, False if it's OK. 449 True if the path is too long to import, False if it's OK.
450 """ 450 """
451 path_from_repo_base = os.path.relpath(source_path, self.source_repo_path ) 451 path_from_repo_base = os.path.relpath(source_path, self.source_repo_path )
452 return len(path_from_repo_base) > MAX_PATH_LENGTH 452 return len(path_from_repo_base) > MAX_PATH_LENGTH
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698