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 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 [ | 938 [ |
939 # To be tested. | 939 # To be tested. |
940 f('a/experimental/b'), | 940 f('a/experimental/b'), |
941 f('experimental/b'), | 941 f('experimental/b'), |
942 f('a/experimental'), | 942 f('a/experimental'), |
943 f('a/experimental.cc'), | 943 f('a/experimental.cc'), |
944 f('a/experimental.S'), | 944 f('a/experimental.S'), |
945 ], | 945 ], |
946 [ | 946 [ |
947 # Expected. | 947 # Expected. |
948 'a/experimental', | |
949 'a/experimental.cc', | 948 'a/experimental.cc', |
950 'a/experimental.S', | 949 'a/experimental.S', |
951 ], | 950 ], |
952 ), | 951 ), |
953 ( | 952 ( |
954 [ | 953 [ |
955 # To be tested. | 954 # To be tested. |
956 f('a/third_party/b'), | 955 f('a/third_party/b'), |
957 f('third_party/b'), | 956 f('third_party/b'), |
958 f('a/third_party'), | 957 f('a/third_party'), |
959 f('a/third_party.cc'), | 958 f('a/third_party.cc'), |
960 ], | 959 ], |
961 [ | 960 [ |
962 # Expected. | 961 # Expected. |
963 'a/third_party', | |
964 'a/third_party.cc', | 962 'a/third_party.cc', |
965 ], | 963 ], |
966 ), | 964 ), |
967 ( | 965 ( |
968 [ | 966 [ |
969 # To be tested. | 967 # To be tested. |
970 f('a/LOL_FILE/b'), | 968 f('a/LOL_FILE/b'), |
971 f('b.c/LOL_FILE'), | 969 f('b.c/LOL_FILE'), |
972 f('a/PRESUBMIT.py'), | 970 f('a/PRESUBMIT.py'), |
| 971 f('a/FOO.json'), |
| 972 f('a/FOO.java'), |
973 ], | 973 ], |
974 [ | 974 [ |
975 # Expected. | 975 # Expected. |
976 'a/LOL_FILE/b', | |
977 'a/PRESUBMIT.py', | 976 'a/PRESUBMIT.py', |
| 977 'a/FOO.java', |
978 ], | 978 ], |
979 ), | 979 ), |
980 ( | 980 ( |
981 [ | 981 [ |
982 # To be tested. | 982 # To be tested. |
983 f('a/.git'), | 983 f('a/.git'), |
984 f('b.c/.git'), | 984 f('b.c/.git'), |
985 f('a/.git/bleh.py'), | 985 f('a/.git/bleh.py'), |
986 f('.git/bleh.py'), | 986 f('.git/bleh.py'), |
987 ], | 987 ], |
988 [ | 988 [ |
989 # Expected. | 989 # Expected. |
990 ], | 990 ], |
991 ), | 991 ), |
992 ] | 992 ] |
993 input_api = presubmit.InputApi( | 993 input_api = presubmit.InputApi( |
994 self.fake_change, './PRESUBMIT.py', False, | 994 self.fake_change, './PRESUBMIT.py', False, |
995 False, None, False) | 995 False, None, False) |
996 self.mox.ReplayAll() | 996 self.mox.ReplayAll() |
997 | 997 |
998 self.assertEqual(len(input_api.DEFAULT_WHITE_LIST), 22) | 998 self.assertEqual(len(input_api.DEFAULT_WHITE_LIST), 21) |
999 self.assertEqual(len(input_api.DEFAULT_BLACK_LIST), 9) | 999 self.assertEqual(len(input_api.DEFAULT_BLACK_LIST), 9) |
1000 for item in files: | 1000 for item in files: |
1001 results = filter(input_api.FilterSourceFile, item[0]) | 1001 results = filter(input_api.FilterSourceFile, item[0]) |
1002 for i in range(len(results)): | 1002 for i in range(len(results)): |
1003 self.assertEquals(results[i].LocalPath(), | 1003 self.assertEquals(results[i].LocalPath(), |
1004 presubmit.normpath(item[1][i])) | 1004 presubmit.normpath(item[1][i])) |
1005 # Same number of expected results. | 1005 # Same number of expected results. |
1006 self.assertEquals(sorted([f.LocalPath().replace(presubmit.os.sep, '/') | 1006 self.assertEquals(sorted([f.LocalPath().replace(presubmit.os.sep, '/') |
1007 for f in results]), | 1007 for f in results]), |
1008 sorted(item[1])) | 1008 sorted(item[1])) |
(...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2227 owners_check=True) | 2227 owners_check=True) |
2228 self.assertEqual(1, len(results)) | 2228 self.assertEqual(1, len(results)) |
2229 self.assertEqual( | 2229 self.assertEqual( |
2230 'Found line ending with white spaces in:', results[0]._message) | 2230 'Found line ending with white spaces in:', results[0]._message) |
2231 self.checkstdout('') | 2231 self.checkstdout('') |
2232 | 2232 |
2233 | 2233 |
2234 if __name__ == '__main__': | 2234 if __name__ == '__main__': |
2235 import unittest | 2235 import unittest |
2236 unittest.main() | 2236 unittest.main() |
OLD | NEW |