check-webkit-style does not understand (Prefix)Foo(Custom|Gtk|CG|Mac).cpp including...
authorlevin@chromium.org <levin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Dec 2009 01:26:54 +0000 (01:26 +0000)
committerlevin@chromium.org <levin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Dec 2009 01:26:54 +0000 (01:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=32033

Reviewed by Eric Seidel.

* Scripts/modules/cpp_style.py: Changed check for a possible primary header to use find
                                instead of startswith.
* Scripts/modules/cpp_style_unittest.py: Added a unit test for the new behavior.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@51570 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKitTools/ChangeLog
WebKitTools/Scripts/modules/cpp_style.py
WebKitTools/Scripts/modules/cpp_style_unittest.py

index 255c8a2..a163b7c 100644 (file)
@@ -1,3 +1,14 @@
+2009-12-01  David Levin  <levin@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        check-webkit-style does not understand (Prefix)Foo(Custom|Gtk|CG|Mac).cpp including Foo.h
+        https://bugs.webkit.org/show_bug.cgi?id=32033
+
+        * Scripts/modules/cpp_style.py: Changed check for a possible primary header to use find
+                                        instead of startswith.
+        * Scripts/modules/cpp_style_unittest.py: Added a unit test for the new behavior.
+
 2009-12-01  Nikolas Zimmermann  <nzimmermann@rim.com>
 
         Not reviewed. Qt build almost fixed, DumpRenderTree should compile now as well.
index 3207dba..990fcfe 100644 (file)
@@ -2309,7 +2309,7 @@ def _classify_include(filename, include, is_system, include_state):
     include_base = FileInfo(include).base_name()
 
     # If we haven't encountered a primary header, then be lenient in checking.
-    if not include_state.visited_primary_section() and target_base.startswith(include_base):
+    if not include_state.visited_primary_section() and target_base.find(include_base) != -1:
         return _PRIMARY_HEADER
     # If we already encountered a primary header, perform a strict comparison.
     # In case the two filename bases are the same then the above lenient check
index aa87588..7f5403f 100644 (file)
@@ -2307,6 +2307,10 @@ class OrderOfIncludesTest(CppStyleTestBase):
                          classify_include('fooCustom.cpp',
                                           'foo.h',
                                           False, include_state))
+        self.assertEqual(cpp_style._PRIMARY_HEADER,
+                         classify_include('PrefixFooCustom.cpp',
+                                          'Foo.h',
+                                          False, include_state))
         # Tricky example where both includes might be classified as primary.
         self.assert_language_rules_check('ScrollbarThemeWince.cpp',
                                          '#include "config.h"\n'