| 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 functools | 10 import functools |
| (...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 'mychange', | 808 'mychange', |
| 809 '\n'.join(description_lines), | 809 '\n'.join(description_lines), |
| 810 self.fake_root_dir, | 810 self.fake_root_dir, |
| 811 files, | 811 files, |
| 812 0, | 812 0, |
| 813 0, | 813 0, |
| 814 None) | 814 None) |
| 815 output = presubmit.DoPresubmitChecks( | 815 output = presubmit.DoPresubmitChecks( |
| 816 change, False, True, None, input_buf, DEFAULT_SCRIPT, False, None) | 816 change, False, True, None, input_buf, DEFAULT_SCRIPT, False, None) |
| 817 self.failIf(output.should_continue()) | 817 self.failIf(output.should_continue()) |
| 818 text = ('Running presubmit upload checks ...\n' | 818 text = ( |
| 819 'Warning, no PRESUBMIT.py found.\n' | 819 'Running presubmit upload checks ...\n' |
| 820 'Running default presubmit script.\n' | 820 'Warning, no PRESUBMIT.py found.\n' |
| 821 '\n' | 821 'Running default presubmit script.\n' |
| 822 '** Presubmit ERRORS **\n!!\n\n' | 822 '\n' |
| 823 'Was the presubmit check useful? Please send feedback & hate mail ' | 823 '** Presubmit ERRORS **\n!!\n\n' |
| 824 'to maruel@chromium.org!\n') | 824 'Was the presubmit check useful? If not, run "git cl presubmit -v"\n' |
| 825 'to figure out the PRESUBMIT.py which were run, then run git blame\n' |
| 826 'on the file to figure out who to ask for help.\n') |
| 825 self.assertEquals(output.getvalue(), text) | 827 self.assertEquals(output.getvalue(), text) |
| 826 | 828 |
| 827 def testDirectoryHandling(self): | 829 def testDirectoryHandling(self): |
| 828 files = [ | 830 files = [ |
| 829 ['A', 'isdir'], | 831 ['A', 'isdir'], |
| 830 ['A', presubmit.os.path.join('isdir', 'blat.cc')], | 832 ['A', presubmit.os.path.join('isdir', 'blat.cc')], |
| 831 ] | 833 ] |
| 832 isdir = presubmit.os.path.join(self.fake_root_dir, 'isdir') | 834 isdir = presubmit.os.path.join(self.fake_root_dir, 'isdir') |
| 833 blat = presubmit.os.path.join(isdir, 'blat.cc') | 835 blat = presubmit.os.path.join(isdir, 'blat.cc') |
| 834 presubmit.os.path.exists(isdir).AndReturn(True) | 836 presubmit.os.path.exists(isdir).AndReturn(True) |
| (...skipping 1905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2740 owners_check=False) | 2742 owners_check=False) |
| 2741 self.assertEqual(1, len(results)) | 2743 self.assertEqual(1, len(results)) |
| 2742 self.assertEqual( | 2744 self.assertEqual( |
| 2743 'Found line ending with white spaces in:', results[0]._message) | 2745 'Found line ending with white spaces in:', results[0]._message) |
| 2744 self.checkstdout('') | 2746 self.checkstdout('') |
| 2745 | 2747 |
| 2746 | 2748 |
| 2747 if __name__ == '__main__': | 2749 if __name__ == '__main__': |
| 2748 import unittest | 2750 import unittest |
| 2749 unittest.main() | 2751 unittest.main() |
| OLD | NEW |