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

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

Issue 2497673003: W3C test importer: skip ref test if ref file not found. (Closed)
Patch Set: Created 4 years, 1 month 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_importer_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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 if self.path_too_long(path_full): 248 if self.path_too_long(path_full):
249 _log.warning('%s skipped due to long path. ' 249 _log.warning('%s skipped due to long path. '
250 'Max length from repo base %d chars; see http:/ /crbug.com/609871.', 250 'Max length from repo base %d chars; see http:/ /crbug.com/609871.',
251 path_full, MAX_PATH_LENGTH) 251 path_full, MAX_PATH_LENGTH)
252 continue 252 continue
253 253
254 if 'reference' in test_info.keys(): 254 if 'reference' in test_info.keys():
255 test_basename = self.filesystem.basename(test_info['test']) 255 test_basename = self.filesystem.basename(test_info['test'])
256 # Add the ref file, following WebKit style. 256 # Add the ref file, following WebKit style.
257 # FIXME: Ideally we'd support reading the metadata 257 # FIXME: Ideally we'd support reading the metadata
258 # directly rather than relying on a naming convention. 258 # directly rather than relying on a naming convention.
259 # Using a naming convention creates duplicate copies of the 259 # Using a naming convention creates duplicate copies of the
260 # reference files. 260 # reference files (http://crrev.com/268729).
261 ref_file = self.filesystem.splitext(test_basename)[0] + '-ex pected' 261 ref_file = self.filesystem.splitext(test_basename)[0] + '-ex pected'
262 # Make sure to use the extension from the *reference*, not 262 # Make sure to use the extension from the *reference*, not
263 # from the test, because at least flexbox tests use XHTML 263 # from the test, because at least flexbox tests use XHTML
264 # references but HTML tests. 264 # references but HTML tests.
265 ref_file += self.filesystem.splitext(test_info['reference']) [1] 265 ref_file += self.filesystem.splitext(test_info['reference']) [1]
266 266
267 if not self.filesystem.exists(test_info['reference']):
268 _log.warning('%s skipped because ref file %s was not fou nd.',
269 path_full, ref_file)
270 continue
qyearsley 2016/11/12 00:16:33 This part is the actual main change for this CL.
271
267 if self.path_too_long(path_full.replace(filename, ref_file)) : 272 if self.path_too_long(path_full.replace(filename, ref_file)) :
268 _log.warning('%s skipped because path of ref file %s wou ld be too long. ' 273 _log.warning('%s skipped because path of ref file %s wou ld be too long. '
269 'Max length from repo base %d chars; see ht tp://crbug.com/609871.', 274 'Max length from repo base %d chars; see ht tp://crbug.com/609871.',
270 path_full, ref_file, MAX_PATH_LENGTH) 275 path_full, ref_file, MAX_PATH_LENGTH)
271 continue 276 continue
272 277
273 reftests += 1 278 reftests += 1
274 total_tests += 1 279 total_tests += 1
275 copy_list.append({'src': test_info['reference'], 'dest': ref _file, 280 copy_list.append({'src': test_info['reference'], 'dest': ref _file,
276 'reference_support_info': test_info['refer ence_support_info']}) 281 'reference_support_info': test_info['refer ence_support_info']})
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 for file_to_copy in dir_to_copy['copy_list']: 343 for file_to_copy in dir_to_copy['copy_list']:
339 # FIXME: Split this block into a separate function. 344 # FIXME: Split this block into a separate function.
340 orig_filepath = self.filesystem.normpath(file_to_copy['src']) 345 orig_filepath = self.filesystem.normpath(file_to_copy['src'])
341 346
342 if self.filesystem.isdir(orig_filepath): 347 if self.filesystem.isdir(orig_filepath):
343 # FIXME: Figure out what is triggering this and what to do a bout it. 348 # FIXME: Figure out what is triggering this and what to do a bout it.
344 _log.error('%s refers to a directory', orig_filepath) 349 _log.error('%s refers to a directory', orig_filepath)
345 continue 350 continue
346 351
347 if not self.filesystem.exists(orig_filepath): 352 if not self.filesystem.exists(orig_filepath):
348 _log.warning('%s not found. Possible error in the test.', or ig_filepath) 353 _log.error('%s not found. Possible error in the test.', orig _filepath)
qyearsley 2016/11/12 00:16:33 In theory I think we might not hit this condition
349 continue 354 continue
350 355
351 new_filepath = self.filesystem.join(new_path, file_to_copy['dest ']) 356 new_filepath = self.filesystem.join(new_path, file_to_copy['dest '])
352 if 'reference_support_info' in file_to_copy.keys() and file_to_c opy['reference_support_info'] != {}: 357 if 'reference_support_info' in file_to_copy.keys() and file_to_c opy['reference_support_info'] != {}:
353 reference_support_info = file_to_copy['reference_support_inf o'] 358 reference_support_info = file_to_copy['reference_support_inf o']
354 else: 359 else:
355 reference_support_info = None 360 reference_support_info = None
356 361
357 if not self.filesystem.exists(self.filesystem.dirname(new_filepa th)): 362 if not self.filesystem.exists(self.filesystem.dirname(new_filepa th)):
358 if not self.import_in_place and not self.options.dry_run: 363 if not self.import_in_place and not self.options.dry_run:
359 self.filesystem.maybe_make_directory(self.filesystem.dir name(new_filepath)) 364 self.filesystem.maybe_make_directory(self.filesystem.dir name(new_filepath))
360 365
361 relpath = self.filesystem.relpath(new_filepath, self.layout_test s_dir) 366 relpath = self.filesystem.relpath(new_filepath, self.layout_test s_dir)
362 if not self.options.overwrite and self.filesystem.exists(new_fil epath): 367 if not self.options.overwrite and self.filesystem.exists(new_fil epath):
363 _log.info(' skipping %s', relpath) 368 _log.info(' skipping %s', relpath)
364 else: 369 else:
365 # FIXME: Maybe doing a file diff is in order here for existi ng files? 370 # FIXME: Maybe doing a file diff is in order here for existi ng files?
366 # In other words, there's no sense in overwriting identical files, but 371 # In other words, there's no sense in overwriting identical files, but
367 # there's no harm in copying the identical thing. 372 # there's no harm in copying the identical thing.
368 _log.info(' %s', relpath) 373 _log.info(' %s', relpath)
369 374
370 # Only HTML, XML, or CSS should be converted. 375 # Only HTML, XML, or CSS should be converted.
371 # FIXME: Eventually, so should JS when support is added for this type of conversion. 376 # FIXME: Eventually, so should JS when support is added for this type of conversion.
372 mimetype = mimetypes.guess_type(orig_filepath) 377 mimetype = mimetypes.guess_type(orig_filepath)
373 if 'is_jstest' not in file_to_copy and ( 378 if 'is_jstest' not in file_to_copy and (
374 'html' in str(mimetype[0]) or 'xml' in str(mimetype[0]) or 'css' in str(mimetype[0])): 379 'html' in str(mimetype[0]) or 'xml' in str(mimetype[0]) or 'css' in str(mimetype[0])):
375 converted_file = convert_for_webkit(new_path, filename=orig_ filepath, 380 converted_file = convert_for_webkit(
376 reference_support_info=r eference_support_info) 381 new_path, filename=orig_filepath,
382 reference_support_info=reference_support_info,
383 host=self.host)
qyearsley 2016/11/12 00:16:33 This change makes it so that the MockFileSystem is
377 384
378 if not converted_file: 385 if not converted_file:
379 if not self.import_in_place and not self.options.dry_run : 386 if not self.import_in_place and not self.options.dry_run :
380 self.filesystem.copyfile(orig_filepath, new_filepath ) # The file was unmodified. 387 self.filesystem.copyfile(orig_filepath, new_filepath ) # The file was unmodified.
381 else: 388 else:
382 for prefixed_property in converted_file[0]: 389 for prefixed_property in converted_file[0]:
383 total_prefixed_properties.setdefault(prefixed_proper ty, 0) 390 total_prefixed_properties.setdefault(prefixed_proper ty, 0)
384 total_prefixed_properties[prefixed_property] += 1 391 total_prefixed_properties[prefixed_property] += 1
385 392
386 prefixed_properties.extend(set(converted_file[0]) - set( prefixed_properties)) 393 prefixed_properties.extend(set(converted_file[0]) - set( prefixed_properties))
387 if not self.options.dry_run: 394 if not self.options.dry_run:
388 outfile = open(new_filepath, 'wb') 395 self.filesystem.write_text_file(new_filepath, conver ted_file[1])
qyearsley 2016/11/12 00:16:33 This change makes it so that the MockFileSystem is
389 outfile.write(converted_file[1].encode('utf-8'))
390 outfile.close()
391 else: 396 else:
392 if not self.import_in_place and not self.options.dry_run: 397 if not self.import_in_place and not self.options.dry_run:
393 self.filesystem.copyfile(orig_filepath, new_filepath) 398 self.filesystem.copyfile(orig_filepath, new_filepath)
394 if self.filesystem.read_binary_file(orig_filepath)[:2] = = '#!': 399 if self.filesystem.read_binary_file(orig_filepath)[:2] = = '#!':
395 self.filesystem.make_executable(new_filepath) 400 self.filesystem.make_executable(new_filepath)
396 401
397 copied_files.append(new_filepath.replace(self._webkit_root, '')) 402 copied_files.append(new_filepath.replace(self._webkit_root, ''))
398 403
399 _log.info('') 404 _log.info('')
400 _log.info('Import complete') 405 _log.info('Import complete')
(...skipping 13 matching lines...) Expand all
414 """Checks whether a source path is too long to import. 419 """Checks whether a source path is too long to import.
415 420
416 Args: 421 Args:
417 Absolute path of file to be imported. 422 Absolute path of file to be imported.
418 423
419 Returns: 424 Returns:
420 True if the path is too long to import, False if it's OK. 425 True if the path is too long to import, False if it's OK.
421 """ 426 """
422 path_from_repo_base = os.path.relpath(source_path, self.source_repo_path ) 427 path_from_repo_base = os.path.relpath(source_path, self.source_repo_path )
423 return len(path_from_repo_base) > MAX_PATH_LENGTH 428 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_importer_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698