Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Side by Side Diff: PRESUBMIT_test.py

Issue 2568473002: Presubmit: Skip third_party for fwd decl warning (Closed)
Patch Set: Rebase + escape backslashes properly Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « PRESUBMIT.py ('k') | PRESUBMIT_test_mocks.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import re 6 import re
7 import subprocess 7 import subprocess
8 import unittest 8 import unittest
9 9
10 import PRESUBMIT 10 import PRESUBMIT
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 MockFile('content/file.cc', 1108 MockFile('content/file.cc',
1109 ['char* host = "https://www.aol.com"; // google.com']) 1109 ['char* host = "https://www.aol.com"; // google.com'])
1110 ] 1110 ]
1111 1111
1112 warnings = PRESUBMIT._CheckHardcodedGoogleHostsInLowerLayers( 1112 warnings = PRESUBMIT._CheckHardcodedGoogleHostsInLowerLayers(
1113 input_api, MockOutputApi()) 1113 input_api, MockOutputApi())
1114 self.assertEqual(0, len(warnings)) 1114 self.assertEqual(0, len(warnings))
1115 1115
1116 1116
1117 class ForwardDeclarationTest(unittest.TestCase): 1117 class ForwardDeclarationTest(unittest.TestCase):
1118 def testCheckHeadersOnly(self): 1118 def testCheckHeadersOnlyOutsideThirdParty(self):
1119 mock_input_api = MockInputApi() 1119 mock_input_api = MockInputApi()
1120 mock_input_api.files = [ 1120 mock_input_api.files = [
1121 MockAffectedFile('somewhere/file.cc', [ 1121 MockAffectedFile('somewhere/file.cc', [
1122 'class DummyClass;' 1122 'class DummyClass;'
1123 ]),
1124 MockAffectedFile('third_party/header.h', [
1125 'class DummyClass;'
1123 ]) 1126 ])
1124 ] 1127 ]
1125 warnings = PRESUBMIT._CheckUselessForwardDeclarations(mock_input_api, 1128 warnings = PRESUBMIT._CheckUselessForwardDeclarations(mock_input_api,
1126 MockOutputApi()) 1129 MockOutputApi())
1127 self.assertEqual(0, len(warnings)) 1130 self.assertEqual(0, len(warnings))
1128 1131
1129 def testNoNestedDeclaration(self): 1132 def testNoNestedDeclaration(self):
1130 mock_input_api = MockInputApi() 1133 mock_input_api = MockInputApi()
1131 mock_input_api.files = [ 1134 mock_input_api.files = [
1132 MockAffectedFile('somewhere/header.h', [ 1135 MockAffectedFile('somewhere/header.h', [
1133 'class SomeClass {' 1136 'class SomeClass {',
1134 ' protected:' 1137 ' protected:',
1135 ' class NotAMatch;' 1138 ' class NotAMatch;',
1136 '};' 1139 '};'
1137 ]) 1140 ])
1138 ] 1141 ]
1139 warnings = PRESUBMIT._CheckUselessForwardDeclarations(mock_input_api, 1142 warnings = PRESUBMIT._CheckUselessForwardDeclarations(mock_input_api,
1140 MockOutputApi()) 1143 MockOutputApi())
1141 self.assertEqual(0, len(warnings)) 1144 self.assertEqual(0, len(warnings))
1142 1145
1143 def testSubStrings(self): 1146 def testSubStrings(self):
1144 mock_input_api = MockInputApi() 1147 mock_input_api = MockInputApi()
1145 mock_input_api.files = [ 1148 mock_input_api.files = [
1146 MockAffectedFile('somewhere/header.h', [ 1149 MockAffectedFile('somewhere/header.h', [
1147 'class NotUsefulClass;', 1150 'class NotUsefulClass;',
1148 'struct SomeStruct;', 1151 'struct SomeStruct;',
1149 'UsefulClass *p1;', 1152 'UsefulClass *p1;',
1150 'SomeStructPtr *p2;' 1153 'SomeStructPtr *p2;'
1151 ]) 1154 ])
1152 ] 1155 ]
1153 warnings = PRESUBMIT._CheckUselessForwardDeclarations(mock_input_api, 1156 warnings = PRESUBMIT._CheckUselessForwardDeclarations(mock_input_api,
1154 MockOutputApi()) 1157 MockOutputApi())
1155 self.assertEqual(2, len(warnings)) 1158 self.assertEqual(2, len(warnings))
1156 1159
1157 def testUselessForwardDeclaration(self): 1160 def testUselessForwardDeclaration(self):
1158 mock_input_api = MockInputApi() 1161 mock_input_api = MockInputApi()
1159 mock_input_api.files = [ 1162 mock_input_api.files = [
1160 MockAffectedFile('somewhere/header.h', [ 1163 MockAffectedFile('somewhere/header.h', [
1161 'class DummyClass;', 1164 'class DummyClass;',
1162 'struct DummyStruct;', 1165 'struct DummyStruct;',
1163 'class UsefulClass;', 1166 'class UsefulClass;',
1164 'std::unique_ptr<UsefulClass> p;' 1167 'std::unique_ptr<UsefulClass> p;'
1165 ]), 1168 ])
1166 ] 1169 ]
1167 warnings = PRESUBMIT._CheckUselessForwardDeclarations(mock_input_api, 1170 warnings = PRESUBMIT._CheckUselessForwardDeclarations(mock_input_api,
1168 MockOutputApi()) 1171 MockOutputApi())
1169 self.assertEqual(2, len(warnings)) 1172 self.assertEqual(2, len(warnings))
1170 1173
1174 def testBlinkHeaders(self):
1175 mock_input_api = MockInputApi()
1176 mock_input_api.files = [
1177 MockAffectedFile('third_party/WebKit/header.h', [
1178 'class DummyClass;',
1179 'struct DummyStruct;',
1180 ]),
1181 MockAffectedFile('third_party\\WebKit\\header.h', [
1182 'class DummyClass;',
1183 'struct DummyStruct;',
1184 ])
1185 ]
1186 warnings = PRESUBMIT._CheckUselessForwardDeclarations(mock_input_api,
1187 MockOutputApi())
1188 self.assertEqual(4, len(warnings))
1189
1171 1190
1172 if __name__ == '__main__': 1191 if __name__ == '__main__':
1173 unittest.main() 1192 unittest.main()
OLDNEW
« no previous file with comments | « PRESUBMIT.py ('k') | PRESUBMIT_test_mocks.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698