Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Unified Diff: PRESUBMIT_test.py

Issue 11441035: PRESUBMIT #include check enhancements. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review (maruel) Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« PRESUBMIT.py ('K') | « PRESUBMIT.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT_test.py
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py
index 183ec6e54c839f71ad98827228ce195faa71819e..bcacad9004fa6286a6539461e3443639630e2c0a 100755
--- a/PRESUBMIT_test.py
+++ b/PRESUBMIT_test.py
@@ -99,7 +99,7 @@ class IncludeOrderTest(unittest.TestCase):
'#include "a/header.h"']
mock_file = MockFile('some/path/foo.cc', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
- mock_input_api, mock_file, True, range(1, len(contents) + 1))
+ mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(0, len(warnings))
def testSpecialFirstInclude2(self):
@@ -108,7 +108,7 @@ class IncludeOrderTest(unittest.TestCase):
'#include "a/header.h"']
mock_file = MockFile('some/path/foo.cc', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
- mock_input_api, mock_file, True, range(1, len(contents) + 1))
+ mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(0, len(warnings))
def testSpecialFirstInclude3(self):
@@ -117,7 +117,7 @@ class IncludeOrderTest(unittest.TestCase):
'#include "a/header.h"']
mock_file = MockFile('some/path/foo_platform.cc', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
- mock_input_api, mock_file, True, range(1, len(contents) + 1))
+ mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(0, len(warnings))
def testSpecialFirstInclude4(self):
@@ -126,10 +126,19 @@ class IncludeOrderTest(unittest.TestCase):
'#include "a/header.h"']
mock_file = MockFile('some/path/foo_platform.cc', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
- mock_input_api, mock_file, True, range(1, len(contents) + 1))
+ mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(1, len(warnings))
self.assertTrue('2' in warnings[0])
+ def testSpecialFirstInclude5(self):
+ mock_input_api = MockInputApi()
+ contents = ['#include "some/other/path/foo.h"',
+ '#include "a/header.h"']
+ mock_file = MockFile('some/path/foo-suffix.h', contents)
+ warnings = PRESUBMIT._CheckIncludeOrderInFile(
+ mock_input_api, mock_file, range(1, len(contents) + 1))
+ self.assertEqual(0, len(warnings))
+
def testOrderAlreadyWrong(self):
scope = [(1, '#include "b.h"'),
(2, '#include "a.h"'),
@@ -162,6 +171,10 @@ class IncludeOrderTest(unittest.TestCase):
def testIfElifElseEndif(self):
mock_input_api = MockInputApi()
contents = ['#include "e.h"',
+ '#define foo',
+ '#include "f.h"',
+ '#undef foo',
+ '#include "e.h"',
'#if foo',
'#include "d.h"',
'#elif bar',
@@ -172,7 +185,7 @@ class IncludeOrderTest(unittest.TestCase):
'#include "a.h"']
mock_file = MockFile('', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
- mock_input_api, mock_file, True, range(1, len(contents) + 1))
+ mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(0, len(warnings))
def testSysIncludes(self):
@@ -182,7 +195,7 @@ class IncludeOrderTest(unittest.TestCase):
'#include <sys/a.h>']
mock_file = MockFile('', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
- mock_input_api, mock_file, True, range(1, len(contents) + 1))
+ mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(0, len(warnings))
« PRESUBMIT.py ('K') | « PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698