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

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

Issue 311673002: updated w3c import script to align with the new css test repo structure (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: updating test importer to reflect new csswg repo structure Created 6 years, 4 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 import sys 81 import sys
82 82
83 from webkitpy.common.host import Host 83 from webkitpy.common.host import Host
84 from webkitpy.common.webkit_finder import WebKitFinder 84 from webkitpy.common.webkit_finder import WebKitFinder
85 from webkitpy.common.system.executive import ScriptError 85 from webkitpy.common.system.executive import ScriptError
86 from webkitpy.layout_tests.models.test_expectations import TestExpectationParser 86 from webkitpy.layout_tests.models.test_expectations import TestExpectationParser
87 from webkitpy.w3c.test_parser import TestParser 87 from webkitpy.w3c.test_parser import TestParser
88 from webkitpy.w3c.test_converter import convert_for_webkit 88 from webkitpy.w3c.test_converter import convert_for_webkit
89 89
90 90
91 TEST_STATUS_UNKNOWN = 'unknown'
92 TEST_STATUS_APPROVED = 'approved'
93 TEST_STATUS_SUBMITTED = 'submitted'
94 VALID_TEST_STATUSES = [TEST_STATUS_APPROVED, TEST_STATUS_SUBMITTED]
95
96 CONTRIBUTOR_DIR_NAME = 'contributors'
97
98 CHANGESET_NOT_AVAILABLE = 'Not Available' 91 CHANGESET_NOT_AVAILABLE = 'Not Available'
99 92
100 93
101 _log = logging.getLogger(__name__) 94 _log = logging.getLogger(__name__)
102 95
103 96
104 def main(_argv, _stdout, _stderr): 97 def main(_argv, _stdout, _stderr):
105 options, args = parse_args() 98 options, args = parse_args()
106 dir_to_import = os.path.normpath(os.path.abspath(args[0])) 99 dir_to_import = os.path.normpath(os.path.abspath(args[0]))
107 if len(args) == 1: 100 if len(args) == 1:
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 161
169 self.filesystem = self.host.filesystem 162 self.filesystem = self.host.filesystem
170 self.webkit_finder = WebKitFinder(self.filesystem) 163 self.webkit_finder = WebKitFinder(self.filesystem)
171 self._webkit_root = self.webkit_finder.webkit_base() 164 self._webkit_root = self.webkit_finder.webkit_base()
172 self.layout_tests_dir = self.webkit_finder.path_from_webkit_base('Layout Tests') 165 self.layout_tests_dir = self.webkit_finder.path_from_webkit_base('Layout Tests')
173 self.destination_directory = self.filesystem.normpath(self.filesystem.jo in(self.layout_tests_dir, options.destination, 166 self.destination_directory = self.filesystem.normpath(self.filesystem.jo in(self.layout_tests_dir, options.destination,
174 self.filesystem.basename(self.top_of_repo))) 167 self.filesystem.basename(self.top_of_repo)))
175 self.import_in_place = (self.dir_to_import == self.destination_directory ) 168 self.import_in_place = (self.dir_to_import == self.destination_directory )
176 169
177 self.changeset = CHANGESET_NOT_AVAILABLE 170 self.changeset = CHANGESET_NOT_AVAILABLE
178 self.test_status = TEST_STATUS_UNKNOWN
179 171
180 self.import_list = [] 172 self.import_list = []
181 173
182 def do_import(self): 174 def do_import(self):
183 _log.info("Importing %s into %s", self.dir_to_import, self.destination_d irectory) 175 _log.info("Importing %s into %s", self.dir_to_import, self.destination_d irectory)
184 self.find_importable_tests(self.dir_to_import) 176 self.find_importable_tests(self.dir_to_import)
185 self.load_changeset() 177 self.load_changeset()
186 self.import_tests() 178 self.import_tests()
187 179
188 def load_changeset(self): 180 def load_changeset(self):
189 """Returns the current changeset from mercurial or "Not Available".""" 181 """Returns the current changeset from mercurial or "Not Available"."""
190 try: 182 try:
191 self.changeset = self.host.executive.run_command(['hg', 'tip']).spli t('changeset:')[1] 183 self.changeset = self.host.executive.run_command(['hg', 'tip']).spli t('changeset:')[1]
192 except (OSError, ScriptError): 184 except (OSError, ScriptError):
193 self.changeset = CHANGESET_NOT_AVAILABLE 185 self.changeset = CHANGESET_NOT_AVAILABLE
194 186
195 def find_importable_tests(self, directory): 187 def find_importable_tests(self, directory):
196 # FIXME: use filesystem 188 # FIXME: use filesystem
197 paths_to_skip = self.find_paths_to_skip() 189 paths_to_skip = self.find_paths_to_skip()
198 190
199 for root, dirs, files in os.walk(directory): 191 for root, dirs, files in os.walk(directory):
200 cur_dir = root.replace(self.layout_tests_dir + '/', '') + '/' 192 cur_dir = root.replace(self.layout_tests_dir + '/', '') + '/'
201 _log.info(' scanning ' + cur_dir + '...') 193 _log.info(' scanning ' + cur_dir + '...')
202 total_tests = 0 194 total_tests = 0
203 reftests = 0 195 reftests = 0
204 jstests = 0 196 jstests = 0
205 197
206 # "archive" and "data" dirs are internal csswg things that live in e very approved directory. 198 DIRS_TO_SKIP = ('.git', '.hg')
207 # FIXME: skip 'incoming' tests for now, but we should rework the 'te st_status' concept and
208 # support reading them as well.
209 DIRS_TO_SKIP = ('.git', '.hg', 'data', 'archive', 'incoming')
210 if dirs: 199 if dirs:
211 for d in DIRS_TO_SKIP: 200 for d in DIRS_TO_SKIP:
212 if d in dirs: 201 if d in dirs:
213 dirs.remove(d) 202 dirs.remove(d)
214 203
215 for path in paths_to_skip: 204 for path in paths_to_skip:
216 path_base = path.replace(cur_dir, '') 205 path_base = path.replace(cur_dir, '')
217 path_full = self.filesystem.join(root, path_base) 206 path_full = self.filesystem.join(root, path_base)
218 if path_base in dirs: 207 if path_base in dirs:
219 dirs.remove(path_base) 208 dirs.remove(path_base)
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 _log.info('IMPORTED %d TOTAL TESTS', total_imported_tests) 393 _log.info('IMPORTED %d TOTAL TESTS', total_imported_tests)
405 _log.info('Imported %d reftests', total_imported_reftests) 394 _log.info('Imported %d reftests', total_imported_reftests)
406 _log.info('Imported %d JS tests', total_imported_jstests) 395 _log.info('Imported %d JS tests', total_imported_jstests)
407 _log.info('Imported %d pixel/manual tests', total_imported_tests - total _imported_jstests - total_imported_reftests) 396 _log.info('Imported %d pixel/manual tests', total_imported_tests - total _imported_jstests - total_imported_reftests)
408 _log.info('') 397 _log.info('')
409 _log.info('Properties needing prefixes (by count):') 398 _log.info('Properties needing prefixes (by count):')
410 for prefixed_property in sorted(total_prefixed_properties, key=lambda p: total_prefixed_properties[p]): 399 for prefixed_property in sorted(total_prefixed_properties, key=lambda p: total_prefixed_properties[p]):
411 _log.info(' %s: %s', prefixed_property, total_prefixed_properties[p refixed_property]) 400 _log.info(' %s: %s', prefixed_property, total_prefixed_properties[p refixed_property])
412 401
413 def setup_destination_directory(self): 402 def setup_destination_directory(self):
414 """ Creates a destination directory that mirrors that of the source appr oved or submitted directory """ 403 """ Creates a destination directory that mirrors that of the source dire ctory """
415 404
416 self.update_test_status()
417
418 start = self.dir_to_import.find(self.test_status)
419 new_subpath = self.dir_to_import[len(self.top_of_repo):] 405 new_subpath = self.dir_to_import[len(self.top_of_repo):]
420 406
421 destination_directory = os.path.join(self.destination_directory, new_sub path) 407 destination_directory = os.path.join(self.destination_directory, new_sub path)
422 408
423 if not os.path.exists(destination_directory): 409 if not os.path.exists(destination_directory):
424 os.makedirs(destination_directory) 410 os.makedirs(destination_directory)
425 411
426 _log.info('Tests will be imported into: %s', destination_directory) 412 _log.info('Tests will be imported into: %s', destination_directory)
427 413
428 def update_test_status(self):
429 """ Sets the test status to either 'approved' or 'submitted' """
430
431 status = TEST_STATUS_UNKNOWN
432
433 directory_parts = self.dir_to_import.split(os.path.sep)
434 for test_status in VALID_TEST_STATUSES:
435 if test_status in directory_parts:
436 status = test_status
437
438 self.test_status = status
439
440 def remove_deleted_files(self, dir_to_import, new_file_list): 414 def remove_deleted_files(self, dir_to_import, new_file_list):
441 previous_file_list = [] 415 previous_file_list = []
442 416
443 import_log_file = os.path.join(dir_to_import, 'w3c-import.log') 417 import_log_file = os.path.join(dir_to_import, 'w3c-import.log')
444 if not os.path.exists(import_log_file): 418 if not os.path.exists(import_log_file):
445 return 419 return
446 420
447 import_log = open(import_log_file, 'r') 421 import_log = open(import_log_file, 'r')
448 contents = import_log.readlines() 422 contents = import_log.readlines()
449 423
(...skipping 14 matching lines...) Expand all
464 438
465 import_log = open(os.path.join(dir_to_import, 'w3c-import.log'), 'w') 439 import_log = open(os.path.join(dir_to_import, 'w3c-import.log'), 'w')
466 import_log.write('The tests in this directory were imported from the W3C repository.\n') 440 import_log.write('The tests in this directory were imported from the W3C repository.\n')
467 import_log.write('Do NOT modify these tests directly in Webkit. Instead, push changes to the W3C CSS repo:\n\n') 441 import_log.write('Do NOT modify these tests directly in Webkit. Instead, push changes to the W3C CSS repo:\n\n')
468 import_log.write('http://hg.csswg.org/test\n\n') 442 import_log.write('http://hg.csswg.org/test\n\n')
469 import_log.write('Then run the Tools/Scripts/import-w3c-tests in Webkit to reimport\n\n') 443 import_log.write('Then run the Tools/Scripts/import-w3c-tests in Webkit to reimport\n\n')
470 import_log.write('Do NOT modify or remove this file\n\n') 444 import_log.write('Do NOT modify or remove this file\n\n')
471 import_log.write('------------------------------------------------------ ------------------\n') 445 import_log.write('------------------------------------------------------ ------------------\n')
472 import_log.write('Last Import: ' + now.strftime('%Y-%m-%d %H:%M') + '\n' ) 446 import_log.write('Last Import: ' + now.strftime('%Y-%m-%d %H:%M') + '\n' )
473 import_log.write('W3C Mercurial changeset: ' + self.changeset + '\n') 447 import_log.write('W3C Mercurial changeset: ' + self.changeset + '\n')
474 import_log.write('Test status at time of import: ' + self.test_status + '\n')
475 import_log.write('------------------------------------------------------ ------------------\n') 448 import_log.write('------------------------------------------------------ ------------------\n')
476 import_log.write('Properties requiring vendor prefixes:\n') 449 import_log.write('Properties requiring vendor prefixes:\n')
477 if prop_list: 450 if prop_list:
478 for prop in prop_list: 451 for prop in prop_list:
479 import_log.write(prop + '\n') 452 import_log.write(prop + '\n')
480 else: 453 else:
481 import_log.write('None\n') 454 import_log.write('None\n')
482 import_log.write('------------------------------------------------------ ------------------\n') 455 import_log.write('------------------------------------------------------ ------------------\n')
483 import_log.write('List of files:\n') 456 import_log.write('List of files:\n')
484 for item in file_list: 457 for item in file_list:
485 import_log.write(item + '\n') 458 import_log.write(item + '\n')
486 459
487 import_log.close() 460 import_log.close()
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