Changeset 91311 in webkit


Ignore:
Timestamp:
Jul 19, 2011 3:44:56 PM (13 years ago)
Author:
Dimitri Glazkov
Message:

Store line number on TestExpectationLine.
https://bugs.webkit.org/show_bug.cgi?id=64800

Reviewed by Adam Barth.

  • Scripts/webkitpy/layout_tests/models/test_expectations.py: Refactored to store line number on TestExpectationLine instances.
Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r91304 r91311  
     12011-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
    1102011-07-19  Ojan Vafai  <ojan@chromium.org>
    211
  • trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py

    r91214 r91311  
    269269
    270270    @classmethod
    271     def tokenize(cls, expectation_string):
     271    def tokenize(cls, expectation_string, line_number=None):
    272272        """Tokenizes a line from test_expectations.txt and returns an unparsed TestExpectationLine instance.
    273273
     
    280280        """
    281281        expectation_line = TestExpectationLine()
     282        expectation_line.line_number = line_number
    282283        comment_index = expectation_string.find("//")
    283284        if comment_index == -1:
     
    311312        """Returns a list of TestExpectationLines, one for each line in expectations_string."""
    312313        expectation_lines = []
     314        line_number = 0
    313315        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))
    315318        return expectation_lines
    316319
     
    327330    def __init__(self):
    328331        """Initializes a blank-line equivalent of an expectation."""
     332        self.line_number = None
    329333        self.name = None
    330334        self.path = None
     
    366370        self._test_to_modifiers = {}
    367371
    368         # Maps a test to a tuple of line number and TestExpectationLine instance.
     372        # Maps a test to a TestExpectationLine instance.
    369373        self._test_to_expectation_line = {}
    370374
     
    420424        return self._test_to_expectations[test]
    421425
    422     def add_expectation_line(self, lineno, expectation_line, overrides_allowed):
     426    def add_expectation_line(self, expectation_line, overrides_allowed):
    423427        """Returns a list of errors, encountered while matching modifiers."""
    424428
     
    427431
    428432        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):
    430434                continue
    431435
    432436            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
    434438            self._add_test(test, expectation_line, overrides_allowed)
    435439
     
    484488            self._remove_from_sets(test, self._result_type_to_tests)
    485489
    486         self._test_to_expectation_line[test] = (expectation_line, 0)
     490        self._test_to_expectation_line[test] = expectation_line
    487491
    488492    def _remove_from_sets(self, test, dict):
     
    496500                set_of_tests.remove(test)
    497501
    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):
    499503        """Returns whether we've seen a better match already in the file.
    500504
     
    507511            return False
    508512
    509         prev_expectation_line, prev_lineno = self._test_to_expectation_line[test]
     513        prev_expectation_line = self._test_to_expectation_line[test]
    510514
    511515        if len(prev_expectation_line.path) > len(expectation_line.path):
     
    545549
    546550        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))
    548552            # FIXME: return False if we want more specific to win.
    549553            return True
    550554
    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))
    552556        return True
    553557
     
    746750        errors = []
    747751        warnings = []
    748         lineno = 0
    749752        for expectation in self._expectations:
    750             lineno += 1
    751753            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))
    753755            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))
    755757
    756758        if len(errors) or len(warnings):
     
    773775            for test in self._full_test_list:
    774776                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)
    776778
    777779    def get_expectations_json_for_all_platforms(self):
     
    797799
    798800    def _add_expectations(self, expectation_list, overrides_allowed):
    799         lineno = 0
    800801        for expectation_line in expectation_list:
    801             lineno += 1
    802802            if not expectation_line.expectations:
    803803                continue
     
    808808
    809809            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)
    811811
    812812
Note: See TracChangeset for help on using the changeset viewer.