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 logging | 10 import logging |
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 self.assertEqual(rhs_lines[13][0].LocalPath(), | 1022 self.assertEqual(rhs_lines[13][0].LocalPath(), |
1023 presubmit.normpath(files[4][1])) | 1023 presubmit.normpath(files[4][1])) |
1024 | 1024 |
1025 def testDefaultWhiteListBlackListFilters(self): | 1025 def testDefaultWhiteListBlackListFilters(self): |
1026 def f(x): | 1026 def f(x): |
1027 return presubmit.AffectedFile(x, 'M', self.fake_root_dir) | 1027 return presubmit.AffectedFile(x, 'M', self.fake_root_dir) |
1028 files = [ | 1028 files = [ |
1029 ( | 1029 ( |
1030 [ | 1030 [ |
1031 # To be tested. | 1031 # To be tested. |
| 1032 f('testing_support/google_appengine/b'), |
| 1033 f('testing_support/not_google_appengine/foo.cc'), |
| 1034 ], |
| 1035 [ |
| 1036 # Expected. |
| 1037 'testing_support/not_google_appengine/foo.cc', |
| 1038 ], |
| 1039 ), |
| 1040 ( |
| 1041 [ |
| 1042 # To be tested. |
1032 f('a/experimental/b'), | 1043 f('a/experimental/b'), |
1033 f('experimental/b'), | 1044 f('experimental/b'), |
1034 f('a/experimental'), | 1045 f('a/experimental'), |
1035 f('a/experimental.cc'), | 1046 f('a/experimental.cc'), |
1036 f('a/experimental.S'), | 1047 f('a/experimental.S'), |
1037 ], | 1048 ], |
1038 [ | 1049 [ |
1039 # Expected. | 1050 # Expected. |
1040 'a/experimental.cc', | 1051 'a/experimental.cc', |
1041 'a/experimental.S', | 1052 'a/experimental.S', |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1082 [ | 1093 [ |
1083 # Expected. | 1094 # Expected. |
1084 ], | 1095 ], |
1085 ), | 1096 ), |
1086 ] | 1097 ] |
1087 input_api = presubmit.InputApi( | 1098 input_api = presubmit.InputApi( |
1088 self.fake_change, './PRESUBMIT.py', False, None, False) | 1099 self.fake_change, './PRESUBMIT.py', False, None, False) |
1089 self.mox.ReplayAll() | 1100 self.mox.ReplayAll() |
1090 | 1101 |
1091 self.assertEqual(len(input_api.DEFAULT_WHITE_LIST), 22) | 1102 self.assertEqual(len(input_api.DEFAULT_WHITE_LIST), 22) |
1092 self.assertEqual(len(input_api.DEFAULT_BLACK_LIST), 11) | 1103 self.assertEqual(len(input_api.DEFAULT_BLACK_LIST), 12) |
1093 for item in files: | 1104 for item in files: |
1094 results = filter(input_api.FilterSourceFile, item[0]) | 1105 results = filter(input_api.FilterSourceFile, item[0]) |
1095 for i in range(len(results)): | 1106 for i in range(len(results)): |
1096 self.assertEquals(results[i].LocalPath(), | 1107 self.assertEquals(results[i].LocalPath(), |
1097 presubmit.normpath(item[1][i])) | 1108 presubmit.normpath(item[1][i])) |
1098 # Same number of expected results. | 1109 # Same number of expected results. |
1099 self.assertEquals(sorted([f.LocalPath().replace(presubmit.os.sep, '/') | 1110 self.assertEquals(sorted([f.LocalPath().replace(presubmit.os.sep, '/') |
1100 for f in results]), | 1111 for f in results]), |
1101 sorted(item[1])) | 1112 sorted(item[1])) |
1102 | 1113 |
(...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2468 owners_check=False) | 2479 owners_check=False) |
2469 self.assertEqual(1, len(results)) | 2480 self.assertEqual(1, len(results)) |
2470 self.assertEqual( | 2481 self.assertEqual( |
2471 'Found line ending with white spaces in:', results[0]._message) | 2482 'Found line ending with white spaces in:', results[0]._message) |
2472 self.checkstdout('') | 2483 self.checkstdout('') |
2473 | 2484 |
2474 | 2485 |
2475 if __name__ == '__main__': | 2486 if __name__ == '__main__': |
2476 import unittest | 2487 import unittest |
2477 unittest.main() | 2488 unittest.main() |
OLD | NEW |