OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 is too confused. | 8 # pylint is too confused. |
9 # pylint: disable=E1101,E1103,R0201,W0212,W0403 | 9 # pylint: disable=E1101,E1103,R0201,W0212,W0403 |
10 | 10 |
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 'a/FOO.java', | 1013 'a/FOO.java', |
1014 ], | 1014 ], |
1015 ), | 1015 ), |
1016 ( | 1016 ( |
1017 [ | 1017 [ |
1018 # To be tested. | 1018 # To be tested. |
1019 f('a/.git'), | 1019 f('a/.git'), |
1020 f('b.c/.git'), | 1020 f('b.c/.git'), |
1021 f('a/.git/bleh.py'), | 1021 f('a/.git/bleh.py'), |
1022 f('.git/bleh.py'), | 1022 f('.git/bleh.py'), |
| 1023 f('bleh.diff'), |
| 1024 f('foo/bleh.patch'), |
1023 ], | 1025 ], |
1024 [ | 1026 [ |
1025 # Expected. | 1027 # Expected. |
1026 ], | 1028 ], |
1027 ), | 1029 ), |
1028 ] | 1030 ] |
1029 input_api = presubmit.InputApi( | 1031 input_api = presubmit.InputApi( |
1030 self.fake_change, './PRESUBMIT.py', False, None, False) | 1032 self.fake_change, './PRESUBMIT.py', False, None, False) |
1031 self.mox.ReplayAll() | 1033 self.mox.ReplayAll() |
1032 | 1034 |
1033 self.assertEqual(len(input_api.DEFAULT_WHITE_LIST), 21) | 1035 self.assertEqual(len(input_api.DEFAULT_WHITE_LIST), 21) |
1034 self.assertEqual(len(input_api.DEFAULT_BLACK_LIST), 9) | 1036 self.assertEqual(len(input_api.DEFAULT_BLACK_LIST), 11) |
1035 for item in files: | 1037 for item in files: |
1036 results = filter(input_api.FilterSourceFile, item[0]) | 1038 results = filter(input_api.FilterSourceFile, item[0]) |
1037 for i in range(len(results)): | 1039 for i in range(len(results)): |
1038 self.assertEquals(results[i].LocalPath(), | 1040 self.assertEquals(results[i].LocalPath(), |
1039 presubmit.normpath(item[1][i])) | 1041 presubmit.normpath(item[1][i])) |
1040 # Same number of expected results. | 1042 # Same number of expected results. |
1041 self.assertEquals(sorted([f.LocalPath().replace(presubmit.os.sep, '/') | 1043 self.assertEquals(sorted([f.LocalPath().replace(presubmit.os.sep, '/') |
1042 for f in results]), | 1044 for f in results]), |
1043 sorted(item[1])) | 1045 sorted(item[1])) |
1044 | 1046 |
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2226 owners_check=True) | 2228 owners_check=True) |
2227 self.assertEqual(1, len(results)) | 2229 self.assertEqual(1, len(results)) |
2228 self.assertEqual( | 2230 self.assertEqual( |
2229 'Found line ending with white spaces in:', results[0]._message) | 2231 'Found line ending with white spaces in:', results[0]._message) |
2230 self.checkstdout('') | 2232 self.checkstdout('') |
2231 | 2233 |
2232 | 2234 |
2233 if __name__ == '__main__': | 2235 if __name__ == '__main__': |
2234 import unittest | 2236 import unittest |
2235 unittest.main() | 2237 unittest.main() |
OLD | NEW |