Commit 4436c9e4 authored by b.kelemen@samsung.com's avatar b.kelemen@samsung.com

Include order check should work better for files containing uncheckable includes

Currently as soon as we see an uncheckable include (like ipc/*macros.h or
windows.h) we stop checking the file. Instead we should just skip that line
and continue checking.

Review URL: https://codereview.chromium.org/105633012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243427 0039d316-1c4b-4281-b951-d872f2087c98
parent ac91eda4
......@@ -667,7 +667,7 @@ def _CheckIncludeOrderInFile(input_api, f, changed_linenums):
for line in contents[line_num:]:
line_num += 1
if uncheckable_includes_pattern.match(line):
return []
continue
if if_pattern.match(line):
scopes.append(current_scope)
current_scope = []
......
......@@ -280,36 +280,36 @@ class IncludeOrderTest(unittest.TestCase):
def testUncheckableIncludes(self):
mock_input_api = MockInputApi()
contents = ['#include <windows.h>',
'#include "b.h"'
'#include "b.h"',
'#include "a.h"']
mock_file = MockFile('', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(0, len(warnings))
self.assertEqual(1, len(warnings))
contents = ['#include "gpu/command_buffer/gles_autogen.h"',
'#include "b.h"'
'#include "b.h"',
'#include "a.h"']
mock_file = MockFile('', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(0, len(warnings))
self.assertEqual(1, len(warnings))
contents = ['#include "gl_mock_autogen.h"',
'#include "b.h"'
'#include "b.h"',
'#include "a.h"']
mock_file = MockFile('', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(0, len(warnings))
self.assertEqual(1, len(warnings))
contents = ['#include "ipc/some_macros.h"',
'#include "b.h"'
'#include "b.h"',
'#include "a.h"']
mock_file = MockFile('', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(0, len(warnings))
self.assertEqual(1, len(warnings))
class VersionControlConflictsTest(unittest.TestCase):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment