OLD | NEW |
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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 mock_file_other = MockFile('something.py', contents) | 273 mock_file_other = MockFile('something.py', contents) |
274 mock_input_api.files = [mock_file_cc, mock_file_h, mock_file_other] | 274 mock_input_api.files = [mock_file_cc, mock_file_h, mock_file_other] |
275 warnings = PRESUBMIT._CheckIncludeOrder(mock_input_api, mock_output_api) | 275 warnings = PRESUBMIT._CheckIncludeOrder(mock_input_api, mock_output_api) |
276 self.assertEqual(1, len(warnings)) | 276 self.assertEqual(1, len(warnings)) |
277 self.assertEqual(2, len(warnings[0].items)) | 277 self.assertEqual(2, len(warnings[0].items)) |
278 self.assertEqual('promptOrNotify', warnings[0].type) | 278 self.assertEqual('promptOrNotify', warnings[0].type) |
279 | 279 |
280 def testUncheckableIncludes(self): | 280 def testUncheckableIncludes(self): |
281 mock_input_api = MockInputApi() | 281 mock_input_api = MockInputApi() |
282 contents = ['#include <windows.h>', | 282 contents = ['#include <windows.h>', |
283 '#include "b.h"' | 283 '#include "b.h"', |
284 '#include "a.h"'] | 284 '#include "a.h"'] |
285 mock_file = MockFile('', contents) | 285 mock_file = MockFile('', contents) |
286 warnings = PRESUBMIT._CheckIncludeOrderInFile( | 286 warnings = PRESUBMIT._CheckIncludeOrderInFile( |
287 mock_input_api, mock_file, range(1, len(contents) + 1)) | 287 mock_input_api, mock_file, range(1, len(contents) + 1)) |
288 self.assertEqual(0, len(warnings)) | 288 self.assertEqual(1, len(warnings)) |
289 | 289 |
290 contents = ['#include "gpu/command_buffer/gles_autogen.h"', | 290 contents = ['#include "gpu/command_buffer/gles_autogen.h"', |
291 '#include "b.h"' | 291 '#include "b.h"', |
292 '#include "a.h"'] | 292 '#include "a.h"'] |
293 mock_file = MockFile('', contents) | 293 mock_file = MockFile('', contents) |
294 warnings = PRESUBMIT._CheckIncludeOrderInFile( | 294 warnings = PRESUBMIT._CheckIncludeOrderInFile( |
295 mock_input_api, mock_file, range(1, len(contents) + 1)) | 295 mock_input_api, mock_file, range(1, len(contents) + 1)) |
296 self.assertEqual(0, len(warnings)) | 296 self.assertEqual(1, len(warnings)) |
297 | 297 |
298 contents = ['#include "gl_mock_autogen.h"', | 298 contents = ['#include "gl_mock_autogen.h"', |
299 '#include "b.h"' | 299 '#include "b.h"', |
300 '#include "a.h"'] | 300 '#include "a.h"'] |
301 mock_file = MockFile('', contents) | 301 mock_file = MockFile('', contents) |
302 warnings = PRESUBMIT._CheckIncludeOrderInFile( | 302 warnings = PRESUBMIT._CheckIncludeOrderInFile( |
303 mock_input_api, mock_file, range(1, len(contents) + 1)) | 303 mock_input_api, mock_file, range(1, len(contents) + 1)) |
304 self.assertEqual(0, len(warnings)) | 304 self.assertEqual(1, len(warnings)) |
305 | 305 |
306 contents = ['#include "ipc/some_macros.h"', | 306 contents = ['#include "ipc/some_macros.h"', |
307 '#include "b.h"' | 307 '#include "b.h"', |
308 '#include "a.h"'] | 308 '#include "a.h"'] |
309 mock_file = MockFile('', contents) | 309 mock_file = MockFile('', contents) |
310 warnings = PRESUBMIT._CheckIncludeOrderInFile( | 310 warnings = PRESUBMIT._CheckIncludeOrderInFile( |
311 mock_input_api, mock_file, range(1, len(contents) + 1)) | 311 mock_input_api, mock_file, range(1, len(contents) + 1)) |
312 self.assertEqual(0, len(warnings)) | 312 self.assertEqual(1, len(warnings)) |
313 | 313 |
314 | 314 |
315 class VersionControlConflictsTest(unittest.TestCase): | 315 class VersionControlConflictsTest(unittest.TestCase): |
316 def testTypicalConflict(self): | 316 def testTypicalConflict(self): |
317 lines = ['<<<<<<< HEAD', | 317 lines = ['<<<<<<< HEAD', |
318 ' base::ScopedTempDir temp_dir_;', | 318 ' base::ScopedTempDir temp_dir_;', |
319 '=======', | 319 '=======', |
320 ' ScopedTempDir temp_dir_;', | 320 ' ScopedTempDir temp_dir_;', |
321 '>>>>>>> master'] | 321 '>>>>>>> master'] |
322 errors = PRESUBMIT._CheckForVersionControlConflictsInFile( | 322 errors = PRESUBMIT._CheckForVersionControlConflictsInFile( |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 'policy/DEPS', | 425 'policy/DEPS', |
426 'sandbox/DEPS', | 426 'sandbox/DEPS', |
427 'tools/memory_watcher/DEPS', | 427 'tools/memory_watcher/DEPS', |
428 'third_party/lss/DEPS', | 428 'third_party/lss/DEPS', |
429 ]) | 429 ]) |
430 self.assertEqual(expected, files_to_check); | 430 self.assertEqual(expected, files_to_check); |
431 | 431 |
432 | 432 |
433 if __name__ == '__main__': | 433 if __name__ == '__main__': |
434 unittest.main() | 434 unittest.main() |
OLD | NEW |