Commit 6ba629a1 authored by cjerdonek@webkit.org's avatar cjerdonek@webkit.org

Suppressed check-webkit-style's underscore check in Qt's autotests.

Also made the path-specific filter check case-insensitive.

Reviewed by Shinichiro Hamaji.

https://bugs.webkit.org/show_bug.cgi?id=34574

* Scripts/webkitpy/style/checker.py:
  - Added a list element to _PATH_RULES_SPECIFIER for
    directories that should be excluded from the
    "readability/naming" category (the category that relates to
    underscores in identifiers, for example).

* Scripts/webkitpy/style/checker_unittest.py:
  - Added an "end-to-end" test for "WebKit/qt/tests/".

* Scripts/webkitpy/style/filter.py:
  - Altered FilterConfiguration's should_check() method to
    check for path substring matches case-insensitively.

* Scripts/webkitpy/style/filter_unittest.py:
  - Added a test to check case-insensitive path substring matching.

* Scripts/webkitpy/style/processors/cpp.py:
  - Removed the hard-coded "WebKit/gtk/webkit/" path reference
    since this is now taken care of by the _PATH_RULES_SPECIFIER
    configuration variable.

* Scripts/webkitpy/style/processors/cpp_unittest.py:
  - Removed the unit test for the GTK directory since this
    is now taken care of by the checker._PATH_RULES_SPECIFIER
    end-to-end tests.

git-svn-id: svn://svn.chromium.org/blink/trunk@54482 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 8337d392
2010-02-05 Chris Jerdonek <cjerdonek@webkit.org>
Reviewed by Shinichiro Hamaji.
Suppressed check-webkit-style's underscore check in Qt's autotests.
Also made the path-specific filter check case-insensitive.
https://bugs.webkit.org/show_bug.cgi?id=34574
* Scripts/webkitpy/style/checker.py:
- Added a list element to _PATH_RULES_SPECIFIER for
directories that should be excluded from the
"readability/naming" category (the category that relates to
underscores in identifiers, for example).
* Scripts/webkitpy/style/checker_unittest.py:
- Added an "end-to-end" test for "WebKit/qt/tests/".
* Scripts/webkitpy/style/filter.py:
- Altered FilterConfiguration's should_check() method to
check for path substring matches case-insensitively.
* Scripts/webkitpy/style/filter_unittest.py:
- Added a test to check case-insensitive path substring matching.
* Scripts/webkitpy/style/processors/cpp.py:
- Removed the hard-coded "WebKit/gtk/webkit/" path reference
since this is now taken care of by the _PATH_RULES_SPECIFIER
configuration variable.
* Scripts/webkitpy/style/processors/cpp_unittest.py:
- Removed the unit test for the GTK directory since this
is now taken care of by the checker._PATH_RULES_SPECIFIER
end-to-end tests.
2010-02-08 Leith Bade <leith@leithalweapon.geek.nz>
Reviewed by Darin Adler.
......
......@@ -86,10 +86,18 @@ WEBKIT_DEFAULT_FILTER_RULES = [
]
# FIXME: Change the second value of each tuple from a tuple to a list,
# and alter the filter code so it accepts lists instead. (The
# filter code will need to convert incoming values from a list
# to a tuple prior to caching). This will make this
# configuration setting a bit simpler since tuples have an
# unusual syntax case.
#
# The path-specific filter rules.
#
# Only the first substring match is used. See the FilterConfiguration
# documentation in filter.py for more information on this list.
# This list is order sensitive. Only the first path substring match
# is used. See the FilterConfiguration documentation in filter.py
# for more information on this list.
_PATH_RULES_SPECIFIER = [
# Files in these directories are consumers of the WebKit
# API and therefore do not follow the same header including
......@@ -98,6 +106,15 @@ _PATH_RULES_SPECIFIER = [
"WebKit/qt/QGVLauncher/"],
("-build/include",
"-readability/streams")),
([# The GTK+ APIs use GTK+ naming style, which includes
# lower-cased, underscore-separated values.
"WebKit/gtk/webkit/",
# There is no clean way to avoid "xxx_data" methods inside
# Qt's autotests since they are called automatically by the
# QtTest module.
"WebKit/qt/tests/",
"JavaScriptCore/qt/tests"],
("-readability/naming",)),
# These are test file patterns.
(["_test.cpp",
"_unittest.cpp",
......
......@@ -185,6 +185,8 @@ class GlobalVariablesTest(unittest.TestCase):
"WebKitTools/WebKitAPITest/"))
self.assertFalse(config.should_check("build/include",
"WebKitTools/WebKitAPITest/"))
self.assertFalse(config.should_check("readability/naming",
"WebKit/qt/tests/qwebelement/tst_qwebelement.cpp"))
def test_max_reports_per_category(self):
"""Check that MAX_REPORTS_PER_CATEGORY is valid."""
......
......@@ -162,6 +162,8 @@ class FilterConfiguration(object):
self._base_rules = base_rules
self._path_specific = path_specific
self._path_specific_lower = None
"""The backing store for self._get_path_specific_lower()."""
# FIXME: Make user rules internal after the FilterConfiguration
# attribute is removed from ProcessorOptions (since at
......@@ -196,9 +198,21 @@ class FilterConfiguration(object):
# Python does not automatically deduce this from __eq__().
return not self.__eq__(other)
# We use the prefix "_get" since the name "_path_specific_lower"
# is already taken up by the data attribute backing store.
def _get_path_specific_lower(self):
"""Return a copy of self._path_specific with the paths lower-cased."""
if self._path_specific_lower is None:
self._path_specific_lower = []
for (sub_paths, path_rules) in self._path_specific:
sub_paths = map(str.lower, sub_paths)
self._path_specific_lower.append((sub_paths, path_rules))
return self._path_specific_lower
def _path_rules_from_path(self, path):
"""Determine the path-specific rules to use, and return as a tuple."""
for (sub_paths, path_rules) in self._path_specific:
path = path.lower()
for (sub_paths, path_rules) in self._get_path_specific_lower():
for sub_path in sub_paths:
if path.find(sub_path) > -1:
return path_rules
......@@ -237,9 +251,9 @@ class FilterConfiguration(object):
rules -- in that order. As we will describe below, later rules
in the list take precedence. The path-specific rules are the
rules corresponding to the first element of the "path_specific"
parameter that contains a string matching some substring of
the path. If there is no such element, there are no path-
specific rules for that path.
parameter that contains a string case-insensitively matching
some substring of the path. If there is no such element,
there are no path-specific rules for that path.
Given a list of filter rules, the logic for determining whether
a category should be checked is as follows. By default all
......
......@@ -230,6 +230,19 @@ class FilterConfigurationTest(unittest.TestCase):
# Test that first match takes precedence.
self.assertFalse(config.should_check("c", "path2/path1"))
def test_path_with_different_case(self):
"""Test a path that differs only in case."""
base_rules = ["-"]
path_specific = [(["Foo/"], ("+whitespace",))]
user_rules = []
config = self._config(base_rules, path_specific, user_rules)
self.assertFalse(config.should_check("whitespace", "Fooo/bar.txt"))
self.assertTrue(config.should_check("whitespace", "Foo/bar.txt"))
# Test different case.
self.assertTrue(config.should_check("whitespace", "FOO/bar.txt"))
def test_user_rules(self):
"""Test effect of user_rules on should_check()."""
base_rules = ["-"]
......
......@@ -2481,7 +2481,6 @@ def check_identifier_name_in_declaration(filename, line_number, line, error):
if modified_identifier.find('_') >= 0:
# Various exceptions to the rule: JavaScript op codes functions, const_iterator.
if (not (filename.find('JavaScriptCore') >= 0 and modified_identifier.find('_op_') >= 0)
and not filename.find('WebKit/gtk/webkit/') >= 0
and not modified_identifier.startswith('tst_')
and not modified_identifier.startswith('webkit_dom_object_')
and not modified_identifier.startswith('qt_')
......
......@@ -3589,9 +3589,6 @@ class WebKitStyleTest(CppStyleTestBase):
self.assert_lint('void webkit_dom_object_init();', '')
self.assert_lint('void webkit_dom_object_class_init();', '')
# The GTK+ APIs use GTK+ naming style, which includes lower-cased, _-separated values.
self.assert_lint('void this_is_a_gtk_style_name(int var1, int var2)', '', 'WebKit/gtk/webkit/foo.cpp')
# There is an exception for some unit tests that begin with "tst_".
self.assert_lint('void tst_QWebFrame::arrayObjectEnumerable(int var1, int var2)', '')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment