| 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 """Unit tests for presubmit_support.py and presubmit_canned_checks.py.""" | 6 """Unit tests for presubmit_support.py and presubmit_canned_checks.py.""" |
| 7 | 7 |
| 8 # pylint: disable=E1101,E1103 | 8 # pylint: disable=E1101,E1103 |
| 9 | 9 |
| 10 import StringIO | 10 import StringIO |
| (...skipping 2511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2522 input_api.environ = self.mox.CreateMock(os.environ) | 2522 input_api.environ = self.mox.CreateMock(os.environ) |
| 2523 input_api.environ.copy().AndReturn({}) | 2523 input_api.environ.copy().AndReturn({}) |
| 2524 input_api.AffectedSourceFiles(mox.IgnoreArg()).AndReturn(True) | 2524 input_api.AffectedSourceFiles(mox.IgnoreArg()).AndReturn(True) |
| 2525 input_api.PresubmitLocalPath().AndReturn('/foo') | 2525 input_api.PresubmitLocalPath().AndReturn('/foo') |
| 2526 input_api.PresubmitLocalPath().AndReturn('/foo') | 2526 input_api.PresubmitLocalPath().AndReturn('/foo') |
| 2527 input_api.os_walk('/foo').AndReturn([('/foo', [], ['file1.py'])]) | 2527 input_api.os_walk('/foo').AndReturn([('/foo', [], ['file1.py'])]) |
| 2528 pylint = os.path.join(_ROOT, 'third_party', 'pylint.py') | 2528 pylint = os.path.join(_ROOT, 'third_party', 'pylint.py') |
| 2529 pylintrc = os.path.join(_ROOT, 'pylintrc') | 2529 pylintrc = os.path.join(_ROOT, 'pylintrc') |
| 2530 | 2530 |
| 2531 CommHelper(input_api, | 2531 CommHelper(input_api, |
| 2532 ['pyyyyython', pylint, '--args-on-stdin', '--disable=cyclic-import', | 2532 ['pyyyyython', pylint, '--args-on-stdin'], |
| 2533 '--jobs=2'], | 2533 env=mox.IgnoreArg(), stdin= |
| 2534 env=mox.IgnoreArg(), stdin='file1.py\n--rcfile=%s' % pylintrc) | 2534 '--rcfile=%s\n--disable=cyclic-import\n--jobs=2\nfile1.py' |
| 2535 % pylintrc) |
| 2535 CommHelper(input_api, | 2536 CommHelper(input_api, |
| 2536 ['pyyyyython', pylint, '--args-on-stdin', '--disable=all', | 2537 ['pyyyyython', pylint, '--args-on-stdin'], |
| 2537 '--enable=cyclic-import'], | 2538 env=mox.IgnoreArg(), stdin= |
| 2538 env=mox.IgnoreArg(), stdin='file1.py\n--rcfile=%s' % pylintrc) | 2539 '--rcfile=%s\n--disable=all\n--enable=cyclic-import\nfile1.py' |
| 2540 % pylintrc) |
| 2539 self.mox.ReplayAll() | 2541 self.mox.ReplayAll() |
| 2540 | 2542 |
| 2541 results = presubmit_canned_checks.RunPylint( | 2543 results = presubmit_canned_checks.RunPylint( |
| 2542 input_api, presubmit.OutputApi) | 2544 input_api, presubmit.OutputApi) |
| 2543 self.assertEquals([], results) | 2545 self.assertEquals([], results) |
| 2544 self.checkstdout('') | 2546 self.checkstdout('') |
| 2545 | 2547 |
| 2546 def testCheckBuildbotPendingBuildsBad(self): | 2548 def testCheckBuildbotPendingBuildsBad(self): |
| 2547 input_api = self.MockInputApi(None, True) | 2549 input_api = self.MockInputApi(None, True) |
| 2548 connection = self.mox.CreateMockAnything() | 2550 connection = self.mox.CreateMockAnything() |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2899 owners_check=False) | 2901 owners_check=False) |
| 2900 self.assertEqual(1, len(results)) | 2902 self.assertEqual(1, len(results)) |
| 2901 self.assertEqual( | 2903 self.assertEqual( |
| 2902 'Found line ending with white spaces in:', results[0]._message) | 2904 'Found line ending with white spaces in:', results[0]._message) |
| 2903 self.checkstdout('') | 2905 self.checkstdout('') |
| 2904 | 2906 |
| 2905 | 2907 |
| 2906 if __name__ == '__main__': | 2908 if __name__ == '__main__': |
| 2907 import unittest | 2909 import unittest |
| 2908 unittest.main() | 2910 unittest.main() |
| OLD | NEW |