⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 100231 in webkit


Ignore:
Timestamp:
Nov 14, 2011, 6:33:51 PM (15 years ago)
Author:
eric@webkit.org
Message:

check-webkit-style broken by r99773: "Could not determine the port"
https://bugs.webkit.org/show_bug.cgi?id=72275

Reviewed by Adam Barth.

The TestExpectationsChecker was using a generic try/except block
which caught all exceptions, so we didn't notice that failing
to pass a Host to PortFactory was causing an exception in port instantiation.
I've factored out the "lookup the port" logic into a separate function
which I've now unittested. This should fix the bug and prevent
others like it from occuring the the future.

  • Scripts/webkitpy/style/checkers/test_expectations.py:
  • Scripts/webkitpy/style/checkers/test_expectations_unittest.py:
Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r100226 r100231  
     12011-11-14  Eric Seidel  <eric@webkit.org>
     2
     3        check-webkit-style broken by r99773: "Could not determine the port"
     4        https://bugs.webkit.org/show_bug.cgi?id=72275
     5
     6        Reviewed by Adam Barth.
     7
     8        The TestExpectationsChecker was using a generic try/except block
     9        which caught all exceptions, so we didn't notice that failing
     10        to pass a Host to PortFactory was causing an exception in port instantiation.
     11        I've factored out the "lookup the port" logic into a separate function
     12        which I've now unittested.  This should fix the bug and prevent
     13        others like it from occuring the the future.
     14
     15        * Scripts/webkitpy/style/checkers/test_expectations.py:
     16        * Scripts/webkitpy/style/checkers/test_expectations_unittest.py:
     17
    1182011-11-14  Julien Chaffraix  <jchaffraix@webkit.org>
    219
  • trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations.py

    r99271 r100231  
    3535
    3636from common import TabChecker
    37 from webkitpy.layout_tests.port.factory import PortFactory
     37from webkitpy.common.host import Host
    3838from webkitpy.layout_tests.models import test_expectations
    3939
     
    5353    categories = set(['test/expectations'])
    5454
     55    def _determine_port_from_exepectations_path(self, host, expectations_path):
     56        try:
     57            # I believe what this is trying to do is "when the port name is chromium,
     58            # get the chromium-port for this platform".  Unclear why that's needed??
     59            port_name = expectations_path.split(host.filesystem.sep)[-2]
     60            if port_name == "chromium":
     61                return host.port_factory.get(options=ChromiumOptions())
     62            # Passing port_name=None to the factory would just return the current port, which isn't what we want, I don't think.
     63            if not port_name:
     64                return None
     65            return host.port_factory.get(port_name)
     66        except Exception, e:
     67            _log.warn("Exception while getting port for path %s" % expectations_path)
     68            return None
     69
    5570    def __init__(self, file_path, handle_style_error):
    5671        self._file_path = file_path
     
    6075        self._output_regex = re.compile('Line:(?P<line>\d+)\s*(?P<message>.+)')
    6176
    62         # FIXME: This should get the PortFactory from a Host object!
    63         port_factory = PortFactory()
     77        # FIXME: A host should be passed to the constructor instead!
     78        host = Host()
     79        host._initialize_scm()
    6480
    6581        # Determining the port of this expectations.
    66         try:
    67             port_name = self._file_path.split(os.sep)[-2]
    68             if port_name == "chromium":
    69                 self._port_obj = port_factory.get(options=ChromiumOptions())
    70             else:
    71                 self._port_obj = port_factory.get(port_name)
    72         except:
    73             # Using 'test' port when we couldn't determine the port for this
    74             # expectations.
     82        self._port_obj = self._determine_port_from_exepectations_path(host, file_path)
     83        # Using 'test' port when we couldn't determine the port for this
     84        # expectations.
     85        if not self._port_obj:
    7586            _log.warn("Could not determine the port for %s. "
    7687                      "Using 'test' port, but platform-specific expectations "
    7788                      "will fail the check." % self._file_path)
    78             self._port_obj = port_factory.get('test')
    79         # Suppress error messages of test_expectations module since they will be
    80         # reported later.
     89            self._port_obj = host.port_factory.get('test')
     90        # Suppress error messages of test_expectations module since they will be reported later.
    8191        log = logging.getLogger("webkitpy.layout_tests.layout_package.test_expectations")
    8292        log.setLevel(logging.CRITICAL)
  • trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations_unittest.py

    r99233 r100231  
    3333
    3434from test_expectations import TestExpectationsChecker
    35 from webkitpy.layout_tests import port
     35from webkitpy.common.host_mock import MockHost
    3636
    3737
     
    6464        self._test_file = 'passes/text.html'
    6565
    66     def process_expectations(self, expectations, overrides=None):
    67         self._checker = TestExpectationsChecker()
     66    def _expect_port_for_expectations_path(self, expected_port_or_port_class, expectations_path):
     67        host = MockHost()
     68        checker = TestExpectationsChecker(expectations_path, ErrorCollector())
     69        port = checker._determine_port_from_exepectations_path(host, expectations_path)
     70        if port:
     71            self.assertEquals(port.__class__.__name__, expected_port_or_port_class)
     72        else:
     73            self.assertEquals(port, expected_port_or_port_class)
     74
     75    def test_determine_port_from_exepectations_path(self):
     76        self._expect_port_for_expectations_path(None, "/")
     77        self._expect_port_for_expectations_path("ChromiumMacPort", "/mock-checkout/LayoutTests/chromium-mac/test_expectations.txt")
    6878
    6979    def assert_lines_lint(self, lines, expected):
Note: See TracChangeset for help on using the changeset viewer.