| 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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 288 |
| 289 contents = ['#include "ipc/some_macros.h"', | 289 contents = ['#include "ipc/some_macros.h"', |
| 290 '#include "b.h"' | 290 '#include "b.h"' |
| 291 '#include "a.h"'] | 291 '#include "a.h"'] |
| 292 mock_file = MockFile('', contents) | 292 mock_file = MockFile('', contents) |
| 293 warnings = PRESUBMIT._CheckIncludeOrderInFile( | 293 warnings = PRESUBMIT._CheckIncludeOrderInFile( |
| 294 mock_input_api, mock_file, range(1, len(contents) + 1)) | 294 mock_input_api, mock_file, range(1, len(contents) + 1)) |
| 295 self.assertEqual(0, len(warnings)) | 295 self.assertEqual(0, len(warnings)) |
| 296 | 296 |
| 297 | 297 |
| 298 class VersionControlerConflictsTest(unittest.TestCase): | 298 class VersionControlConflictsTest(unittest.TestCase): |
| 299 def testTypicalConflict(self): | 299 def testTypicalConflict(self): |
| 300 lines = ['<<<<<<< HEAD', | 300 lines = ['<<<<<<< HEAD', |
| 301 ' base::ScopedTempDir temp_dir_;', | 301 ' base::ScopedTempDir temp_dir_;', |
| 302 '=======', | 302 '=======', |
| 303 ' ScopedTempDir temp_dir_;', | 303 ' ScopedTempDir temp_dir_;', |
| 304 '>>>>>>> master'] | 304 '>>>>>>> master'] |
| 305 errors = PRESUBMIT._CheckForVersionControlConflictsInFile( | 305 errors = PRESUBMIT._CheckForVersionControlConflictsInFile( |
| 306 MockInputApi(), MockFile('some/path/foo_platform.cc', lines)) | 306 MockInputApi(), MockFile('some/path/foo_platform.cc', lines)) |
| 307 self.assertEqual(3, len(errors)) | 307 self.assertEqual(3, len(errors)) |
| 308 self.assertTrue('1' in errors[0]) | 308 self.assertTrue('1' in errors[0]) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 | 349 |
| 350 def testOnlyOwnersFiles(self): | 350 def testOnlyOwnersFiles(self): |
| 351 mock_change = MockChange([ | 351 mock_change = MockChange([ |
| 352 'some/path/OWNERS', | 352 'some/path/OWNERS', |
| 353 'A\Windows\Path\OWNERS', | 353 'A\Windows\Path\OWNERS', |
| 354 ]) | 354 ]) |
| 355 results = PRESUBMIT.GetPreferredTrySlaves(None, mock_change) | 355 results = PRESUBMIT.GetPreferredTrySlaves(None, mock_change) |
| 356 self.assertEqual(0, len(results)) | 356 self.assertEqual(0, len(results)) |
| 357 | 357 |
| 358 | 358 |
| 359 class InvalidOSMacroNamesTest(unittest.TestCase): |
| 360 def testInvalidOSMacroNames(self): |
| 361 lines = ['#if defined(OS_WINDOWS)', |
| 362 '#elif defined(OS_WINDOW)', |
| 363 '#if defined(OS_MACOSX) || defined(OS_CHROME)', |
| 364 '#if defined(OS_MAC)', |
| 365 '#elif defined(OS_MACOS)', |
| 366 '#if defined(OS_MAXOSX)'] |
| 367 errors = PRESUBMIT._CheckForInvalidOSMacrosInFile( |
| 368 MockInputApi(), MockFile('some/path/foo_platform.cc', lines)) |
| 369 self.assertEqual(len(lines), len(errors)) |
| 370 self.assertTrue('1' in errors[0] and 'OS_WINDOWS' in errors[0]) |
| 371 |
| 372 def testValidOSMacroNames(self): |
| 373 lines = ['#if defined(%s)' % m for m in PRESUBMIT._VALID_OS_MACROS] |
| 374 errors = PRESUBMIT._CheckForInvalidOSMacrosInFile( |
| 375 MockInputApi(), MockFile('some/path/foo_platform.cc', lines)) |
| 376 self.assertEqual(0, len(errors)) |
| 377 |
| 378 |
| 359 if __name__ == '__main__': | 379 if __name__ == '__main__': |
| 360 unittest.main() | 380 unittest.main() |
| OLD | NEW |