Commit 70be8d44 authored by eric@webkit.org's avatar eric@webkit.org

2010-01-28 Chris Jerdonek <cjerdonek@webkit.org>

        Reviewed by Shinichiro Hamaji.

        In check-webkit-style, eliminated the dependency of
        processors/cpp_unittest.py on checker.py.

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

        * Scripts/webkitpy/style/checker.py:
          - Addressed FIXME by removing STYLE_CATEGORIES data.
          - Added style_categories().

        * Scripts/webkitpy/style/checker_unittest.py:
          - Minor changes.

        * Scripts/webkitpy/style/processors/cpp.py:
          - Added categories attribute to CppProcessor class (data
            was originally checker.STYLE_CATEGORIES).

        * Scripts/webkitpy/style/processors/cpp_unittest.py:
          - Addressed FIXME by eliminating "import" from checker.py.

git-svn-id: svn://svn.chromium.org/blink/trunk@53990 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 9716f7b5
2010-01-28 Chris Jerdonek <cjerdonek@webkit.org>
Reviewed by Shinichiro Hamaji.
In check-webkit-style, eliminated the dependency of
processors/cpp_unittest.py on checker.py.
https://bugs.webkit.org/show_bug.cgi?id=34205
* Scripts/webkitpy/style/checker.py:
- Addressed FIXME by removing STYLE_CATEGORIES data.
- Added style_categories().
* Scripts/webkitpy/style/checker_unittest.py:
- Minor changes.
* Scripts/webkitpy/style/processors/cpp.py:
- Added categories attribute to CppProcessor class (data
was originally checker.STYLE_CATEGORIES).
* Scripts/webkitpy/style/processors/cpp_unittest.py:
- Addressed FIXME by eliminating "import" from checker.py.
2010-01-28 Anton Muhin <antonm@chromium.org>
Reviewed by Shinichiro Hamaji.
......
......@@ -80,83 +80,6 @@ WEBKIT_DEFAULT_FILTER_RULES = [
]
# FIXME: The STYLE_CATEGORIES show up in both file types cpp_style.py
# and text_style.py. Break this list into possibly overlapping
# sub-lists, and store each sub-list in the corresponding .py
# file. The file style.py can obtain the master list by taking
# the union. This will allow the unit tests for each file type
# to check that all of their respective style categories are
# represented -- without having to reference style.py or be
# aware of the existence of other file types.
#
# We categorize each style rule we print. Here are the categories.
# We want an explicit list so we can display a full list to the user.
# If you add a new error message with a new category, add it to the list
# here! cpp_style_unittest.py should tell you if you forget to do this.
STYLE_CATEGORIES = [
'build/class',
'build/deprecated',
'build/endif_comment',
'build/forward_decl',
'build/header_guard',
'build/include',
'build/include_order',
'build/include_what_you_use',
'build/namespaces',
'build/printf_format',
'build/storage_class',
'build/using_std',
'legal/copyright',
'readability/braces',
'readability/casting',
'readability/check',
'readability/comparison_to_zero',
'readability/constructors',
'readability/control_flow',
'readability/fn_size',
'readability/function',
'readability/multiline_comment',
'readability/multiline_string',
'readability/naming',
'readability/null',
'readability/streams',
'readability/todo',
'readability/utf8',
'runtime/arrays',
'runtime/casting',
'runtime/explicit',
'runtime/init',
'runtime/int',
'runtime/invalid_increment',
'runtime/max_min_macros',
'runtime/memset',
'runtime/printf',
'runtime/printf_format',
'runtime/references',
'runtime/rtti',
'runtime/sizeof',
'runtime/string',
'runtime/threadsafe_fn',
'runtime/virtual',
'whitespace/blank_line',
'whitespace/braces',
'whitespace/comma',
'whitespace/comments',
'whitespace/declaration',
'whitespace/end_of_line',
'whitespace/ending_newline',
'whitespace/indent',
'whitespace/labels',
'whitespace/line_length',
'whitespace/newline',
'whitespace/operators',
'whitespace/parens',
'whitespace/semicolon',
'whitespace/tab',
'whitespace/todo',
]
# Some files should be skipped when checking style. For example,
# WebKit maintains some files in Mozilla style on purpose to ease
# future merges.
......@@ -181,6 +104,12 @@ SKIPPED_FILES_WITHOUT_WARNING = [
]
def style_categories():
"""Return the set of all categories used by check-webkit-style."""
# If other processors had categories, we would take their union here.
return CppProcessor.categories
def webkit_argument_defaults():
"""Return the DefaultArguments instance for use by check-webkit-style."""
return ArgumentDefaults(WEBKIT_DEFAULT_OUTPUT_FORMAT,
......@@ -526,7 +455,8 @@ class ArgumentParser(object):
def _exit_with_categories(self):
"""Exit and print the style categories and default filter rules."""
self.doc_print('\nAll categories:\n')
for category in sorted(STYLE_CATEGORIES):
categories = style_categories()
for category in sorted(categories):
self.doc_print(' ' + category + '\n')
self.doc_print('\nDefault filter rules**:\n')
......
......@@ -183,13 +183,14 @@ class WebKitArgumentDefaultsTest(unittest.TestCase):
def test_filter_rules(self):
defaults = self.defaults()
already_seen = []
all_categories = style.style_categories()
for rule in defaults.filter_rules:
# Check no leading or trailing white space.
self.assertEquals(rule, rule.strip())
# All categories are on by default, so defaults should
# begin with -.
self.assertTrue(rule.startswith('-'))
self.assertTrue(rule[1:] in style.STYLE_CATEGORIES)
self.assertTrue(rule[1:] in all_categories)
# Check no rule occurs twice.
self.assertFalse(rule in already_seen)
already_seen.append(rule)
......
......@@ -2902,6 +2902,75 @@ class CppProcessor(object):
"""Processes C++ lines for checking style."""
# This list is used to--
#
# (1) generate an explicit list of all possible categories,
# (2) unit test that all checked categories have valid names, and
# (3) unit test that all categories are getting unit tested.
#
categories = set([
'build/class',
'build/deprecated',
'build/endif_comment',
'build/forward_decl',
'build/header_guard',
'build/include',
'build/include_order',
'build/include_what_you_use',
'build/namespaces',
'build/printf_format',
'build/storage_class',
'build/using_std',
'legal/copyright',
'readability/braces',
'readability/casting',
'readability/check',
'readability/comparison_to_zero',
'readability/constructors',
'readability/control_flow',
'readability/fn_size',
'readability/function',
'readability/multiline_comment',
'readability/multiline_string',
'readability/naming',
'readability/null',
'readability/streams',
'readability/todo',
'readability/utf8',
'runtime/arrays',
'runtime/casting',
'runtime/explicit',
'runtime/init',
'runtime/int',
'runtime/invalid_increment',
'runtime/max_min_macros',
'runtime/memset',
'runtime/printf',
'runtime/printf_format',
'runtime/references',
'runtime/rtti',
'runtime/sizeof',
'runtime/string',
'runtime/threadsafe_fn',
'runtime/virtual',
'whitespace/blank_line',
'whitespace/braces',
'whitespace/comma',
'whitespace/comments',
'whitespace/declaration',
'whitespace/end_of_line',
'whitespace/ending_newline',
'whitespace/indent',
'whitespace/labels',
'whitespace/line_length',
'whitespace/newline',
'whitespace/operators',
'whitespace/parens',
'whitespace/semicolon',
'whitespace/tab',
'whitespace/todo',
])
def __init__(self, file_path, file_extension, handle_style_error, verbosity):
"""Create a CppProcessor instance.
......
......@@ -44,17 +44,12 @@ import unittest
import cpp as cpp_style
from cpp import CppProcessor
# FIXME: Remove the need to import anything from checker. See the
# FIXME notes near the STYLE_CATEGORIES definition for a
# suggestion on how to best do this.
from .. checker import STYLE_CATEGORIES
# This class works as an error collector and replaces cpp_style.Error
# function for the unit tests. We also verify each category we see
# is in STYLE_CATEGORIES, to help keep that list up to date.
class ErrorCollector:
_all_style_categories = STYLE_CATEGORIES
# This a list including all categories seen in any unit test.
_all_style_categories = CppProcessor.categories
# This is a list including all categories seen in any unit test.
_seen_style_categories = {}
def __init__(self, assert_fn):
......
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