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