Changeset 91311 in webkit
- Timestamp:
- Jul 19, 2011 3:44:56 PM (13 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r91304 r91311 1 2011-07-19 Dimitri Glazkov <dglazkov@chromium.org> 2 3 Store line number on TestExpectationLine. 4 https://bugs.webkit.org/show_bug.cgi?id=64800 5 6 Reviewed by Adam Barth. 7 8 * Scripts/webkitpy/layout_tests/models/test_expectations.py: Refactored to store line number on TestExpectationLine instances. 9 1 10 2011-07-19 Ojan Vafai <ojan@chromium.org> 2 11 -
trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py
r91214 r91311 269 269 270 270 @classmethod 271 def tokenize(cls, expectation_string ):271 def tokenize(cls, expectation_string, line_number=None): 272 272 """Tokenizes a line from test_expectations.txt and returns an unparsed TestExpectationLine instance. 273 273 … … 280 280 """ 281 281 expectation_line = TestExpectationLine() 282 expectation_line.line_number = line_number 282 283 comment_index = expectation_string.find("//") 283 284 if comment_index == -1: … … 311 312 """Returns a list of TestExpectationLines, one for each line in expectations_string.""" 312 313 expectation_lines = [] 314 line_number = 0 313 315 for line in expectations_string.split("\n"): 314 expectation_lines.append(cls.tokenize(line)) 316 line_number += 1 317 expectation_lines.append(cls.tokenize(line, line_number)) 315 318 return expectation_lines 316 319 … … 327 330 def __init__(self): 328 331 """Initializes a blank-line equivalent of an expectation.""" 332 self.line_number = None 329 333 self.name = None 330 334 self.path = None … … 366 370 self._test_to_modifiers = {} 367 371 368 # Maps a test to a tuple of line number andTestExpectationLine instance.372 # Maps a test to a TestExpectationLine instance. 369 373 self._test_to_expectation_line = {} 370 374 … … 420 424 return self._test_to_expectations[test] 421 425 422 def add_expectation_line(self, lineno,expectation_line, overrides_allowed):426 def add_expectation_line(self, expectation_line, overrides_allowed): 423 427 """Returns a list of errors, encountered while matching modifiers.""" 424 428 … … 427 431 428 432 for test in expectation_line.matching_tests: 429 if self._already_seen_better_match(test, expectation_line, lineno,overrides_allowed):433 if self._already_seen_better_match(test, expectation_line, overrides_allowed): 430 434 continue 431 435 432 436 self._clear_expectations_for_test(test, expectation_line) 433 self._test_to_expectation_line[test] = (expectation_line, lineno)437 self._test_to_expectation_line[test] = expectation_line 434 438 self._add_test(test, expectation_line, overrides_allowed) 435 439 … … 484 488 self._remove_from_sets(test, self._result_type_to_tests) 485 489 486 self._test_to_expectation_line[test] = (expectation_line, 0)490 self._test_to_expectation_line[test] = expectation_line 487 491 488 492 def _remove_from_sets(self, test, dict): … … 496 500 set_of_tests.remove(test) 497 501 498 def _already_seen_better_match(self, test, expectation_line, lineno,overrides_allowed):502 def _already_seen_better_match(self, test, expectation_line, overrides_allowed): 499 503 """Returns whether we've seen a better match already in the file. 500 504 … … 507 511 return False 508 512 509 prev_expectation_line , prev_lineno= self._test_to_expectation_line[test]513 prev_expectation_line = self._test_to_expectation_line[test] 510 514 511 515 if len(prev_expectation_line.path) > len(expectation_line.path): … … 545 549 546 550 if prev_expectation_line.specificity < expectation_line.specificity: 547 expectation_line.errors.append('More specific entry on line %d overrides line %d' % ( lineno, prev_lineno))551 expectation_line.errors.append('More specific entry on line %d overrides line %d' % (expectation_line.line_number, prev_expectation_line.line_number)) 548 552 # FIXME: return False if we want more specific to win. 549 553 return True 550 554 551 expectation_line.errors.append('More specific entry on line %d overrides line %d' % (prev_ lineno, lineno))555 expectation_line.errors.append('More specific entry on line %d overrides line %d' % (prev_expectation_line.line_number, expectation_line.line_number)) 552 556 return True 553 557 … … 746 750 errors = [] 747 751 warnings = [] 748 lineno = 0749 752 for expectation in self._expectations: 750 lineno += 1751 753 for error in expectation.errors: 752 errors.append("Line:%s %s %s" % ( lineno, error, expectation.name if expectation.expectations else expectation.comment))754 errors.append("Line:%s %s %s" % (expectation.line_number, error, expectation.name if expectation.expectations else expectation.comment)) 753 755 for warning in expectation.warnings: 754 warnings.append("Line:%s %s %s" % ( lineno, warning, expectation.name if expectation.expectations else expectation.comment))756 warnings.append("Line:%s %s %s" % (expectation.line_number, warning, expectation.name if expectation.expectations else expectation.comment)) 755 757 756 758 if len(errors) or len(warnings): … … 773 775 for test in self._full_test_list: 774 776 if not self._model.has_test(test): 775 self._model.add_expectation_line( 0,TestExpectationLine.create_passing_expectation(test), overrides_allowed=False)777 self._model.add_expectation_line(TestExpectationLine.create_passing_expectation(test), overrides_allowed=False) 776 778 777 779 def get_expectations_json_for_all_platforms(self): … … 797 799 798 800 def _add_expectations(self, expectation_list, overrides_allowed): 799 lineno = 0800 801 for expectation_line in expectation_list: 801 lineno += 1802 802 if not expectation_line.expectations: 803 803 continue … … 808 808 809 809 self._parser.parse(expectation_line) 810 self._model.add_expectation_line( lineno,expectation_line, overrides_allowed)810 self._model.add_expectation_line(expectation_line, overrides_allowed) 811 811 812 812
Note: See TracChangeset
for help on using the changeset viewer.