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

Side by Side Diff: PRESUBMIT_test.py

Issue 11418128: PRESUBMIT #include check enhancement: <sys/..> includes can be in any order. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import os 6 import os
7 import re 7 import re
8 import unittest 8 import unittest
9 9
10 import PRESUBMIT 10 import PRESUBMIT
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 '#include "c.h"', 168 '#include "c.h"',
169 '#else', 169 '#else',
170 '#include "b.h"', 170 '#include "b.h"',
171 '#endif', 171 '#endif',
172 '#include "a.h"'] 172 '#include "a.h"']
173 mock_file = MockFile('', contents) 173 mock_file = MockFile('', contents)
174 warnings = PRESUBMIT._CheckIncludeOrderInFile( 174 warnings = PRESUBMIT._CheckIncludeOrderInFile(
175 mock_input_api, mock_file, True, range(1, len(contents) + 1)) 175 mock_input_api, mock_file, True, range(1, len(contents) + 1))
176 self.assertEqual(0, len(warnings)) 176 self.assertEqual(0, len(warnings))
177 177
178 def testSysIncludes(self):
179 # #include <sys/...>'s can appear in any order.
180 mock_input_api = MockInputApi()
181 contents = ['#include <sys/b.h>',
182 '#include <sys/a.h>']
183 mock_file = MockFile('', contents)
184 warnings = PRESUBMIT._CheckIncludeOrderInFile(
185 mock_input_api, mock_file, True, range(1, len(contents) + 1))
186 self.assertEqual(0, len(warnings))
187
178 188
179 class VersionControlerConflictsTest(unittest.TestCase): 189 class VersionControlerConflictsTest(unittest.TestCase):
180 def testTypicalConflict(self): 190 def testTypicalConflict(self):
181 lines = ['<<<<<<< HEAD', 191 lines = ['<<<<<<< HEAD',
182 ' base::ScopedTempDir temp_dir_;', 192 ' base::ScopedTempDir temp_dir_;',
183 '=======', 193 '=======',
184 ' ScopedTempDir temp_dir_;', 194 ' ScopedTempDir temp_dir_;',
185 '>>>>>>> master'] 195 '>>>>>>> master']
186 errors = PRESUBMIT._CheckForVersionControlConflictsInFile( 196 errors = PRESUBMIT._CheckForVersionControlConflictsInFile(
187 MockInputApi(), MockFile('some/path/foo_platform.cc', lines)) 197 MockInputApi(), MockFile('some/path/foo_platform.cc', lines))
188 self.assertEqual(3, len(errors)) 198 self.assertEqual(3, len(errors))
189 self.assertTrue('1' in errors[0]) 199 self.assertTrue('1' in errors[0])
190 self.assertTrue('3' in errors[1]) 200 self.assertTrue('3' in errors[1])
191 self.assertTrue('5' in errors[2]) 201 self.assertTrue('5' in errors[2])
192 202
193 203
194 if __name__ == '__main__': 204 if __name__ == '__main__':
195 unittest.main() 205 unittest.main()
OLDNEW
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698