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

Side by Side Diff: PRESUBMIT_test.py

Issue 11607019: PRESUBMIT #include check: exclude known cases which need a non-standard order. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« PRESUBMIT.py ('K') | « 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 mock_input_api.is_committing = True 245 mock_input_api.is_committing = True
246 mock_output_api = MockOutputApi() 246 mock_output_api = MockOutputApi()
247 contents = ['#include <b.h>', 247 contents = ['#include <b.h>',
248 '#include <a.h>'] 248 '#include <a.h>']
249 mock_input_api.files = [MockFile('something.cc', contents)] 249 mock_input_api.files = [MockFile('something.cc', contents)]
250 warnings = PRESUBMIT._CheckIncludeOrder(mock_input_api, mock_output_api) 250 warnings = PRESUBMIT._CheckIncludeOrder(mock_input_api, mock_output_api)
251 self.assertEqual(1, len(warnings)) 251 self.assertEqual(1, len(warnings))
252 self.assertEqual(1, len(warnings[0].items)) 252 self.assertEqual(1, len(warnings[0].items))
253 self.assertEqual('notify', warnings[0].type) 253 self.assertEqual('notify', warnings[0].type)
254 254
255 def testUncheckableIncludes(self):
256 mock_input_api = MockInputApi()
257 contents = ['#include <windows.h>',
258 '#include "b.h"'
259 '#include "a.h"']
260 mock_file = MockFile('', contents)
261 warnings = PRESUBMIT._CheckIncludeOrderInFile(
262 mock_input_api, mock_file, range(1, len(contents) + 1))
263 self.assertEqual(0, len(warnings))
264
265 contents = ['#include "gpu/command_buffer/gles_autogen.h"',
266 '#include "b.h"'
267 '#include "a.h"']
268 mock_file = MockFile('', contents)
269 warnings = PRESUBMIT._CheckIncludeOrderInFile(
270 mock_input_api, mock_file, range(1, len(contents) + 1))
271 self.assertEqual(0, len(warnings))
272
273 contents = ['#include "gl_mock_autogen.h"',
274 '#include "b.h"'
275 '#include "a.h"']
276 mock_file = MockFile('', contents)
277 warnings = PRESUBMIT._CheckIncludeOrderInFile(
278 mock_input_api, mock_file, range(1, len(contents) + 1))
279 self.assertEqual(0, len(warnings))
280
281 contents = ['#include "ipc/some_macros.h"',
282 '#include "b.h"'
283 '#include "a.h"']
284 mock_file = MockFile('', contents)
285 warnings = PRESUBMIT._CheckIncludeOrderInFile(
286 mock_input_api, mock_file, range(1, len(contents) + 1))
287 self.assertEqual(0, len(warnings))
288
255 289
256 class VersionControlerConflictsTest(unittest.TestCase): 290 class VersionControlerConflictsTest(unittest.TestCase):
257 def testTypicalConflict(self): 291 def testTypicalConflict(self):
258 lines = ['<<<<<<< HEAD', 292 lines = ['<<<<<<< HEAD',
259 ' base::ScopedTempDir temp_dir_;', 293 ' base::ScopedTempDir temp_dir_;',
260 '=======', 294 '=======',
261 ' ScopedTempDir temp_dir_;', 295 ' ScopedTempDir temp_dir_;',
262 '>>>>>>> master'] 296 '>>>>>>> master']
263 errors = PRESUBMIT._CheckForVersionControlConflictsInFile( 297 errors = PRESUBMIT._CheckForVersionControlConflictsInFile(
264 MockInputApi(), MockFile('some/path/foo_platform.cc', lines)) 298 MockInputApi(), MockFile('some/path/foo_platform.cc', lines))
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 mock_input_api.files = [ 335 mock_input_api.files = [
302 MockFile('other/path/qux.h', ''), 336 MockFile('other/path/qux.h', ''),
303 MockFile('other/path/qux.cc', ''), 337 MockFile('other/path/qux.cc', ''),
304 ] 338 ]
305 results = PRESUBMIT._CheckPatchFiles(mock_input_api, MockOutputApi()) 339 results = PRESUBMIT._CheckPatchFiles(mock_input_api, MockOutputApi())
306 self.assertEqual(0, len(results)) 340 self.assertEqual(0, len(results))
307 341
308 342
309 if __name__ == '__main__': 343 if __name__ == '__main__':
310 unittest.main() 344 unittest.main()
OLDNEW
« PRESUBMIT.py ('K') | « PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698