Changeset 107124 in webkit


Ignore:
Timestamp:
Feb 8, 2012 1:02:53 PM (12 years ago)
Author:
dpranke@chromium.org
Message:

check-webkit-style failing with "Path does not exist."
https://bugs.webkit.org/show_bug.cgi?id=77873

Reviewed by Ojan Vafai.

This change fixes the way the style checker determines which
Port class to use for a given test_expectations.txt path; the
previous version used a heuristic that didn't really work in the
first place.

  • Scripts/webkitpy/style/checkers/test_expectations.py:

(TestExpectationsChecker._determine_port_from_expectations_path):
(TestExpectationsChecker.init):

  • Scripts/webkitpy/style/checkers/test_expectations_unittest.py:

(TestExpectationsTestCase._expect_port_for_expectations_path):
(TestExpectationsTestCase.test_determine_port_from_expectations_path):

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r107113 r107124  
     12012-02-08  Dirk Pranke  <dpranke@chromium.org>
     2
     3        check-webkit-style failing with "Path does not exist."
     4        https://bugs.webkit.org/show_bug.cgi?id=77873
     5
     6        Reviewed by Ojan Vafai.
     7
     8        This change fixes the way the style checker determines which
     9        Port class to use for a given test_expectations.txt path; the
     10        previous version used a heuristic that didn't really work in the
     11        first place.
     12
     13        * Scripts/webkitpy/style/checkers/test_expectations.py:
     14        (TestExpectationsChecker._determine_port_from_expectations_path):
     15        (TestExpectationsChecker.__init__):
     16        * Scripts/webkitpy/style/checkers/test_expectations_unittest.py:
     17        (TestExpectationsTestCase._expect_port_for_expectations_path):
     18        (TestExpectationsTestCase.test_determine_port_from_expectations_path):
     19
    1202012-02-08  Fehér Zsolt  <feherzs@inf.u-szeged.hu>
    221
  • trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations.py

    r106591 r107124  
    4848    categories = set(['test/expectations'])
    4949
    50     def _determine_port_from_exepectations_path(self, host, expectations_path):
    51         try:
    52             port_name = expectations_path.split(host.filesystem.sep)[-2]
    53             if not port_name:
    54                 return None
    55 
    56             # Pass a configuration to avoid calling default_configuration() when initializing the port (takes 0.5 seconds on a Mac Pro!).
    57             return host.port_factory.get(port_name, options=DummyOptions(configuration="Release"))
    58         except Exception, e:
    59             _log.warn("Exception while getting port for path %s" % expectations_path)
    60             return None
     50    def _determine_port_from_expectations_path(self, host, expectations_path):
     51        # Pass a configuration to avoid calling default_configuration() when initializing the port (takes 0.5 seconds on a Mac Pro!).
     52        options = DummyOptions(configuration='Release')
     53        for port_name in host.port_factory.all_port_names():
     54            port = host.port_factory.get(port_name, options=options)
     55            if port.path_to_test_expectations_file().replace(port.path_from_webkit_base() + host.filesystem.sep, '') == expectations_path:
     56                return port
     57        return None
    6158
    6259    def __init__(self, file_path, handle_style_error, host=None):
     
    7168        host._initialize_scm()
    7269
    73         # Determining the port of this expectations.
    74         self._port_obj = self._determine_port_from_exepectations_path(host, file_path)
    75         # Using 'test' port when we couldn't determine the port for this
    76         # expectations.
    77         if not self._port_obj:
    78             _log.warn("Could not determine the port for %s. "
    79                       "Using 'test' port, but platform-specific expectations "
    80                       "will fail the check." % self._file_path)
    81             self._port_obj = host.port_factory.get('test')
     70        self._port_obj = self._determine_port_from_expectations_path(host, file_path)
     71
    8272        # Suppress error messages of test_expectations module since they will be reported later.
    8373        log = logging.getLogger("webkitpy.layout_tests.layout_package.test_expectations")
     
    113103        overrides = self._port_obj.test_expectations_overrides()
    114104        expectations = '\n'.join(lines)
    115         self.check_test_expectations(expectations_str=expectations,
    116                                      tests=None,
    117                                      overrides=overrides)
     105        if self._port_obj:
     106            self.check_test_expectations(expectations_str=expectations,
     107                                         tests=None,
     108                                         overrides=overrides)
     109        else:
     110            self._handle_style_error(1, 'test/expectations', 5,
     111                                     'No port uses path %s for test_expectations' % self._file_path)
    118112        # Warn tabs in lines as well
    119113        self.check_tabs(lines)
  • trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations_unittest.py

    r105948 r107124  
    6464        self._test_file = 'passes/text.html'
    6565
    66     def _expect_port_for_expectations_path(self, expected_port_or_port_class, expectations_path):
     66    def _expect_port_for_expectations_path(self, expected_port_implementation, expectations_path):
    6767        host = MockHost()
    6868        checker = TestExpectationsChecker(expectations_path, ErrorCollector(), host=host)
    69         port = checker._determine_port_from_exepectations_path(host, expectations_path)
     69        port = checker._determine_port_from_expectations_path(host, expectations_path)
    7070        if port:
    71             self.assertEquals(port.__class__.__name__, expected_port_or_port_class)
     71            self.assertTrue(port.name().startswith(expected_port_implementation))
    7272        else:
    73             self.assertEquals(port, expected_port_or_port_class)
     73            self.assertEquals(None, expected_port_implementation)
    7474
    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")
     75    def test_determine_port_from_expectations_path(self):
     76        self._expect_port_for_expectations_path(None, '/')
     77        self._expect_port_for_expectations_path(None, 'LayoutTests/chromium-mac/test_expectations.txt')
     78        self._expect_port_for_expectations_path('chromium', 'LayoutTests/platform/chromium/test_expectations.txt')
     79        self._expect_port_for_expectations_path(None, '/mock-checkout/LayoutTests/platform/win/test_expectations.txt')
     80        self._expect_port_for_expectations_path('win', 'LayoutTests/platform/win/test_expectations.txt')
    7881
    7982    def assert_lines_lint(self, lines, should_pass, expected_output=None):
    8083        self._error_collector.reset_errors()
     84
     85        host = MockHost()
    8186        checker = TestExpectationsChecker('test/test_expectations.txt',
    82                                           self._error_collector, host=MockHost())
     87                                          self._error_collector, host=host)
     88
     89        # We should have failed to find a valid port object for that path.
     90        self.assertEquals(checker._port_obj, None)
     91
     92        # Now use a test port so we can check the lines.
     93        checker._port_obj = host.port_factory.get('test-mac-leopard')
    8394        checker.check_test_expectations(expectations_str='\n'.join(lines),
    8495                                        tests=[self._test_file],
Note: See TracChangeset for help on using the changeset viewer.