Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 <geryxyz@inf.u-szeged.hu> 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):

Canonical link: https://commits.webkit.org/143123@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@159872 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
geryxyz authored and webkit-commit-queue committed Nov 29, 2013
1 parent cda38ec commit 33bd89f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
14 changes: 14 additions & 0 deletions Tools/ChangeLog
@@ -1,3 +1,17 @@
2013-11-29 Gergo Balogh <geryxyz@inf.u-szeged.hu>

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 <jberta@inf.u-szeged.hu>

test-webkit-scripts should show the failing tests and use an appropriate exit code
Expand Down
12 changes: 8 additions & 4 deletions Tools/Scripts/webkitpy/style/checkers/cpp.py
Expand Up @@ -2818,12 +2818,16 @@ def check_include_line(filename, file_extension, clean_lines, line_number, inclu
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.
Expand Down
16 changes: 16 additions & 0 deletions Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
Expand Up @@ -2644,6 +2644,22 @@ def test_check_line_break_after_own_header(self):
'#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'
Expand Down

0 comments on commit 33bd89f

Please sign in to comment.