Ejemplo n.º 1
0
    def test_path_rules_specifier(self):
        for _, path_rules in PATH_RULES_SPECIFIER:
            validate_filter_rules(path_rules, self._all_categories())

        config = FilterConfiguration(path_specific=PATH_RULES_SPECIFIER)

        def assert_check(path, category):
            """Assert that the given category should be checked."""
            self.assertTrue(config.should_check(category, path))

        def assert_no_check(path, category):
            """Assert that the given category should not be checked."""
            message = ('Should not check category "%s" for path "%s".'
                       % (category, path))
            self.assertFalse(config.should_check(category, path), message)

        assert_check("random_path.cpp",
                    "build/include")
        assert_check("random_path.cpp",
                    "readability/naming")
        assert_no_check("Source/core/css/CSSParser-in.cpp",
                      "readability/naming")

        # Third-party Python code: webkitpy/thirdparty
        path = "Tools/Scripts/webkitpy/thirdparty/mock.py"
        assert_no_check(path, "build/include")
        assert_no_check(path, "pep8/E401")  # A random pep8 category.
        assert_check(path, "pep8/W191")
        assert_check(path, "pep8/W291")
        assert_check(path, "whitespace/carriage_return")
Ejemplo n.º 2
0
 def test_webkit_base_filter_rules(self):
     base_filter_rules = _BASE_FILTER_RULES
     already_seen = []
     validate_filter_rules(base_filter_rules, self._all_categories())
     # Also do some additional checks.
     for rule in base_filter_rules:
         # Check no leading or trailing white space.
         self.assertEqual(rule, rule.strip())
         # All categories are on by default, so defaults should
         # begin with -.
         self.assertTrue(rule.startswith('-'))
         # Check no rule occurs twice.
         self.assertNotIn(rule, already_seen)
         already_seen.append(rule)