Title: [159872] trunk/Tools
Revision
159872
Author
[email protected]
Date
2013-11-29 06:32:53 -0800 (Fri, 29 Nov 2013)

Log Message

check-webkit-style should check for extraneous newline between config.h and primary header.
https://bugs.webkit.org/show_bug.cgi?id=124821

Patch by Gergo Balogh <[email protected]> on 2013-11-29
Reviewed by Csaba Osztrogonác.

* Scripts/webkitpy/style/checkers/cpp.py:
(check_include_line):
* Scripts/webkitpy/style/checkers/cpp_unittest.py:
(OrderOfIncludesTest.test_check_line_break_after_own_header):
(OrderOfIncludesTest):
(OrderOfIncludesTest.test_check_line_break_before_own_header):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (159871 => 159872)


--- trunk/Tools/ChangeLog	2013-11-29 14:16:18 UTC (rev 159871)
+++ trunk/Tools/ChangeLog	2013-11-29 14:32:53 UTC (rev 159872)
@@ -1,3 +1,17 @@
+2013-11-29  Gergo Balogh  <[email protected]>
+
+        check-webkit-style should check for extraneous newline between config.h and primary header.
+        https://bugs.webkit.org/show_bug.cgi?id=124821
+
+        Reviewed by Csaba Osztrogonác.
+
+        * Scripts/webkitpy/style/checkers/cpp.py:
+        (check_include_line):
+        * Scripts/webkitpy/style/checkers/cpp_unittest.py:
+        (OrderOfIncludesTest.test_check_line_break_after_own_header):
+        (OrderOfIncludesTest):
+        (OrderOfIncludesTest.test_check_line_break_before_own_header):
+
 2013-11-29  Jozsef Berta  <[email protected]>
 
         test-webkit-scripts should show the failing tests and use an appropriate exit code

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


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2013-11-29 14:16:18 UTC (rev 159871)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2013-11-29 14:32:53 UTC (rev 159872)
@@ -2818,12 +2818,16 @@
                                                            file_extension == "h",
                                                            primary_header_exists)
 
-    # Check to make sure we have a blank line after primary header.
+    # Check to make sure we have a blank line after and none before primary header.
     if not error_message and header_type == _PRIMARY_HEADER:
-         next_line = clean_lines.raw_lines[line_number + 1]
-         if not is_blank_line(next_line):
+        next_line = clean_lines.raw_lines[line_number + 1]
+        previous_line = clean_lines.raw_lines[line_number - 1]
+        if not is_blank_line(next_line):
             error(line_number, 'build/include_order', 4,
-                  'You should add a blank line after implementation file\'s own header.')
+                'You should add a blank line after implementation file\'s own header.')
+        if is_blank_line(previous_line):
+            error(line_number, 'build/include_order', 4,
+                'You should not add a blank line before implementation file\'s own header.')
 
     # Check to make sure all headers besides config.h and the primary header are
     # alphabetically sorted.

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


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2013-11-29 14:16:18 UTC (rev 159871)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2013-11-29 14:32:53 UTC (rev 159872)
@@ -2644,6 +2644,22 @@
                                          '#include "bar.h"\n',
                                          '')
 
+    def test_check_line_break_before_own_header(self):
+        self.assert_language_rules_check('foo.cpp',
+                                         '#include "config.h"\n'
+                                         '\n'
+                                         '#include "foo.h"\n'
+                                         '\n'
+                                         '#include "bar.h"\n',
+                                         'You should not add a blank line before implementation file\'s own header.  [build/include_order] [4]')
+
+        self.assert_language_rules_check('foo.cpp',
+                                         '#include "config.h"\n'
+                                         '#include "foo.h"\n'
+                                         '\n'
+                                         '#include "bar.h"\n',
+                                         '')
+
     def test_check_preprocessor_in_include_section(self):
         self.assert_language_rules_check('foo.cpp',
                                          '#include "config.h"\n'
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to