Title: [119794] trunk/Tools
Revision
119794
Author
kin...@chromium.org
Date
2012-06-07 21:24:01 -0700 (Thu, 07 Jun 2012)

Log Message

check-webkit-style needs to be taught about <public/Foo.h>
https://bugs.webkit.org/show_bug.cgi?id=88524

Reviewed by David Levin.

* Scripts/webkitpy/style/checkers/cpp.py:
(_classify_include):
* Scripts/webkitpy/style/checkers/cpp_unittest.py:
(OrderOfIncludesTest.test_public_primary_header):
(OrderOfIncludesTest.test_classify_include):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (119793 => 119794)


--- trunk/Tools/ChangeLog	2012-06-08 04:15:28 UTC (rev 119793)
+++ trunk/Tools/ChangeLog	2012-06-08 04:24:01 UTC (rev 119794)
@@ -1,3 +1,16 @@
+2012-06-07  Kinuko Yasuda  <kin...@chromium.org>
+
+        check-webkit-style needs to be taught about <public/Foo.h>
+        https://bugs.webkit.org/show_bug.cgi?id=88524
+
+        Reviewed by David Levin.
+
+        * Scripts/webkitpy/style/checkers/cpp.py:
+        (_classify_include):
+        * Scripts/webkitpy/style/checkers/cpp_unittest.py:
+        (OrderOfIncludesTest.test_public_primary_header):
+        (OrderOfIncludesTest.test_classify_include):
+
 2012-06-07  Joshua Lock  <joshua.l...@intel.com>
 
         [EFL][DRT] Normalize file:///tmp/LayoutTests in LayoutTestController::pathToLocalResource()

Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py (119793 => 119794)


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2012-06-08 04:15:28 UTC (rev 119793)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2012-06-08 04:24:01 UTC (rev 119794)
@@ -2632,7 +2632,7 @@
     """
 
     # If it is a system header we know it is classified as _OTHER_HEADER.
-    if is_system:
+    if is_system and not include.startswith('public/'):
         return _OTHER_HEADER
 
     # If the include is named config.h then this is WebCore/config.h.

Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py (119793 => 119794)


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2012-06-08 04:15:28 UTC (rev 119793)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2012-06-08 04:24:01 UTC (rev 119794)
@@ -2696,7 +2696,31 @@
 
         os.path.isfile = self.os_path_isfile_orig
 
+    def test_public_primary_header(self):
+        # System header is not considered a primary header.
+        self.assert_language_rules_check('foo.cpp',
+                                         '#include "config.h"\n'
+                                         '#include <other/foo.h>\n'
+                                         '\n'
+                                         '#include "a.h"\n',
+                                         'Alphabetical sorting problem.  [build/include_order] [4]')
 
+        # ...except that it starts with public/.
+        self.assert_language_rules_check('foo.cpp',
+                                         '#include "config.h"\n'
+                                         '#include <public/foo.h>\n'
+                                         '\n'
+                                         '#include "a.h"\n',
+                                         '')
+
+        # Even if it starts with public/ its base part must match with the source file name.
+        self.assert_language_rules_check('foo.cpp',
+                                         '#include "config.h"\n'
+                                         '#include <public/foop.h>\n'
+                                         '\n'
+                                         '#include "a.h"\n',
+                                         'Alphabetical sorting problem.  [build/include_order] [4]')
+
     def test_check_wtf_includes(self):
         self.assert_language_rules_check('foo.cpp',
                                          '#include "config.h"\n'
@@ -2751,6 +2775,19 @@
                          classify_include('foo.cpp',
                                           'moc_foo.cpp',
                                           False, include_state))
+        # <public/foo.h> must be considered as primary even if is_system is True.
+        self.assertEqual(cpp_style._PRIMARY_HEADER,
+                         classify_include('foo/foo.cpp',
+                                          'public/foo.h',
+                                          True, include_state))
+        self.assertEqual(cpp_style._OTHER_HEADER,
+                         classify_include('foo.cpp',
+                                          'foo.h',
+                                          True, include_state))
+        self.assertEqual(cpp_style._OTHER_HEADER,
+                         classify_include('foo.cpp',
+                                          'public/foop.h',
+                                          True, include_state))
         # Qt private APIs use _p.h suffix.
         self.assertEqual(cpp_style._PRIMARY_HEADER,
                          classify_include('foo.cpp',
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to