Changeset 91124 in webkit
- Timestamp:
- Jul 15, 2011 3:49:25 PM (13 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r91123 r91124 1 2011-07-15 Dimitri Glazkov <dglazkov@chromium.org> 2 3 Refactor TestExpectationModel to use TestExpectationLine as data item. 4 https://bugs.webkit.org/show_bug.cgi?id=64635 5 6 This is a bit largish in scope. Does the following things: 7 8 1) Adds "path" member to TestExpectationLine to hold normalized path to test, computed at parsing, 9 and changes code that used Port.normalize_test_name to rely on TestExpectationLine.path. As a result, TestExpectationModel no longer 10 needs to have any port knowledge. 11 12 2) Adds "create_passing_expectation" class method to TestExpectationLine to generate a pristine passing expectation out of a test name, 13 and changes TestExpectations._process_tests_without_expectations to use it, thus eliminating the need for a special API entry point. 14 Now all expectations are added to the model in the same way! 15 16 3) Changes TestExpectationModel's main test index to store a tuple consisting of line number and TestExpectationLine instance. 17 18 Reviewed by Adam Barth. 19 20 * Scripts/webkitpy/layout_tests/models/test_expectations.py: Refactored code. 21 1 22 2011-07-15 Adam Roben <aroben@apple.com> 2 23 -
trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py
r91106 r91124 193 193 return 194 194 195 if not self._full_test_list: 196 expectation_line.matching_tests = [expectation_line.name] 197 else: 198 expectation_line.matching_tests = self._collect_matching_tests(expectation_line.name) 195 expectation_line.path = self._port.normalize_test_name(expectation_line.name) 196 self._collect_matching_tests(expectation_line) 199 197 200 198 expectation_line.parsed_modifiers = [modifier for modifier in expectation_line.modifiers if modifier in TestExpectations.MODIFIERS] … … 243 241 return False 244 242 245 def _collect_matching_tests(self, test_list_path):243 def _collect_matching_tests(self, expectation_line): 246 244 """Convert the test specification to an absolute, normalized 247 245 path and make sure directories end with the OS path separator.""" … … 252 250 # files and nodes being categories. 253 251 254 if self._port.test_isdir(test_list_path): 252 if not self._full_test_list: 253 expectation_line.matching_tests = [expectation_line.path] 254 return 255 256 if self._port.test_isdir(expectation_line.path): 255 257 # this is a test category, return all the tests of the category. 256 test_list_path = self._port.normalize_test_name(test_list_path) 257 258 return [test for test in self._full_test_list if test.startswith(test_list_path)] 258 expectation_line.matching_tests = [test for test in self._full_test_list if test.startswith(expectation_line.path)] 259 return 259 260 260 261 # this is a test file, do a quick check if it's in the 261 262 # full test suite. 262 result = [] 263 if test_list_path in self._full_test_list: 264 result = [test_list_path, ] 265 return result 263 if expectation_line.path in self._full_test_list: 264 expectation_line.matching_tests.append(expectation_line.path) 266 265 267 266 @classmethod … … 325 324 """Initializes a blank-line equivalent of an expectation.""" 326 325 self.name = None 326 self.path = None 327 327 self.modifiers = [] 328 328 self.parsed_modifiers = [] … … 341 341 return self.is_malformed() or len(self.warnings) > 0 342 342 343 # FIXME: Refactor to use TestExpectationLine as data item. 343 @classmethod 344 def create_passing_expectation(cls, test): 345 expectation_line = TestExpectationLine() 346 expectation_line.name = test 347 expectation_line.path = test 348 expectation_line.parsed_expectations = set([PASS]) 349 expectation_line.matching_tests = [test] 350 return expectation_line 351 352 344 353 # FIXME: Refactor API to be a proper CRUD. 345 354 class TestExpectationsModel: 346 355 """Represents relational store of all expectations and provides CRUD semantics to manage it.""" 347 356 348 def __init__(self, port): 349 self._port = port 350 357 def __init__(self): 351 358 # Maps a test to its list of expectations. 352 359 self._test_to_expectations = {} … … 355 362 self._test_to_modifiers = {} 356 363 357 # Maps a test to the base path that it was listed with in the list and 358 # the number of matches that base path had. 359 self._test_list_paths = {} 364 # Maps a test to a tuple of line number and TestExpectationLine instance. 365 self._test_to_expectation_line = {} 360 366 361 367 # List of tests that are in the overrides file (used for checking for … … 405 411 406 412 def has_test(self, test): 407 return test in self._test_ list_paths413 return test in self._test_to_expectation_line 408 414 409 415 def get_expectations(self, test): 410 416 return self._test_to_expectations[test] 411 417 412 def add_ tests(self, lineno, expectation_line, overrides_allowed):418 def add_expectation_line(self, lineno, expectation_line, overrides_allowed): 413 419 """Returns a list of errors, encountered while matching modifiers.""" 414 420 … … 420 426 continue 421 427 422 self._clear_expectations_for_test(test, expectation_line .name)423 self._test_ list_paths[test] = (self._port.normalize_test_name(expectation_line.name), expectation_line.num_matches, lineno)424 self. add_test(test, expectation_line, overrides_allowed)425 426 def add_test(self, test, expectation_line, overrides_allowed):428 self._clear_expectations_for_test(test, expectation_line) 429 self._test_to_expectation_line[test] = (expectation_line, lineno) 430 self._add_test(test, expectation_line, overrides_allowed) 431 432 def _add_test(self, test, expectation_line, overrides_allowed): 427 433 """Sets the expected state for a given test. 428 434 … … 462 468 self._overridding_tests.add(test) 463 469 464 def _clear_expectations_for_test(self, test, test_list_path):470 def _clear_expectations_for_test(self, test, expectation_line): 465 471 """Remove prexisting expectations for this test. 466 472 This happens if we are seeing a more precise path … … 474 480 self._remove_from_sets(test, self._result_type_to_tests) 475 481 476 self._test_ list_paths[test] = self._port.normalize_test_name(test_list_path)482 self._test_to_expectation_line[test] = (expectation_line, 0) 477 483 478 484 def _remove_from_sets(self, test, dict): … … 497 503 return False 498 504 499 prev_base_path, prev_num_matches, prev_lineno = self._test_list_paths[test] 500 base_path = self._port.normalize_test_name(expectation_line.name) 501 502 if len(prev_base_path) > len(base_path): 505 prev_expectation_line, prev_lineno = self._test_to_expectation_line[test] 506 507 if len(prev_expectation_line.path) > len(expectation_line.path): 503 508 # The previous path matched more of the test. 504 509 return True 505 510 506 if len(prev_ base_path) < len(base_path):511 if len(prev_expectation_line.path) < len(expectation_line.path): 507 512 # This path matches more of the test. 508 513 return False … … 531 536 # to be warnings and return False". 532 537 533 if prev_ num_matches == expectation_line.num_matches:538 if prev_expectation_line.num_matches == expectation_line.num_matches: 534 539 expectation_line.errors.append('Duplicate or ambiguous %s.' % expectation_source) 535 540 return True 536 541 537 if prev_ num_matches < expectation_line.num_matches:542 if prev_expectation_line.num_matches < expectation_line.num_matches: 538 543 expectation_line.errors.append('More specific entry on line %d overrides line %d' % (lineno, prev_lineno)) 539 544 # FIXME: return False if we want more specific to win. … … 648 653 self._test_config = test_config 649 654 self._is_lint_mode = is_lint_mode 650 self._model = TestExpectationsModel( port)655 self._model = TestExpectationsModel() 651 656 self._parser = TestExpectationParser(port, test_config, tests, is_lint_mode) 652 657 … … 761 766 762 767 def _process_tests_without_expectations(self): 763 expectation = TestExpectationLine()764 expectation.parsed_expectations = set([PASS])765 768 if self._full_test_list: 766 769 for test in self._full_test_list: 767 770 if not self._model.has_test(test): 768 self._model.add_ test(test, expectation, overrides_allowed=False)771 self._model.add_expectation_line(0, TestExpectationLine.create_passing_expectation(test), overrides_allowed=False) 769 772 770 773 def get_expectations_json_for_all_platforms(self): … … 791 794 def _add_expectations(self, expectation_list, overrides_allowed): 792 795 lineno = 0 793 for expectation in expectation_list:796 for expectation_line in expectation_list: 794 797 lineno += 1 795 expectations = expectation.expectations 796 797 if not expectation.expectations: 798 if not expectation_line.expectations: 798 799 continue 799 800 800 self._add_to_all_expectations(expectation .name,801 " ".join(expectation .modifiers).upper(),802 " ".join(expectation .expectations).upper())803 804 self._parser.parse(expectation )805 self._model.add_ tests(lineno, expectation, overrides_allowed)801 self._add_to_all_expectations(expectation_line.name, 802 " ".join(expectation_line.modifiers).upper(), 803 " ".join(expectation_line.expectations).upper()) 804 805 self._parser.parse(expectation_line) 806 self._model.add_expectation_line(lineno, expectation_line, overrides_allowed) 806 807 807 808
Note: See TracChangeset
for help on using the changeset viewer.