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

Side by Side Diff: PRESUBMIT_test.py

Issue 2900253003: [Reland] Add presubmit rule banning relative header includes (Closed)
Patch Set: Remove redundant test classes Created 3 years, 7 months 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') | no next file » | 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 os.path 6 import os.path
7 import re 7 import re
8 import subprocess 8 import subprocess
9 import unittest 9 import unittest
10 10
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 1316
1317 def testArrowsAllowedInChromeCode(self): 1317 def testArrowsAllowedInChromeCode(self):
1318 mock_input_api = MockInputApi() 1318 mock_input_api = MockInputApi()
1319 mock_input_api.files = [ 1319 mock_input_api.files = [
1320 MockAffectedFile('chrome/browser/resources/blah.js', 'arrow => OK here'), 1320 MockAffectedFile('chrome/browser/resources/blah.js', 'arrow => OK here'),
1321 ] 1321 ]
1322 warnings = PRESUBMIT._CheckForRiskyJsFeatures( 1322 warnings = PRESUBMIT._CheckForRiskyJsFeatures(
1323 mock_input_api, MockOutputApi()) 1323 mock_input_api, MockOutputApi())
1324 self.assertEqual(0, len(warnings)) 1324 self.assertEqual(0, len(warnings))
1325 1325
1326 class RelativeIncludesTest(unittest.TestCase):
1327 def testThirdPartyNotWebKitIgnored(self):
1328 mock_input_api = MockInputApi()
1329 mock_input_api.files = [
1330 MockAffectedFile('third_party/test.cpp', '#include "../header.h"'),
1331 MockAffectedFile('third_party/test/test.cpp', '#include "../header.h"'),
1332 ]
1333
1334 mock_output_api = MockOutputApi()
1335
1336 errors = PRESUBMIT._CheckForRelativeIncludes(
1337 mock_input_api, mock_output_api)
1338 self.assertEqual(0, len(errors))
1339
1340 def testNonCppFileIgnored(self):
1341 mock_input_api = MockInputApi()
1342 mock_input_api.files = [
1343 MockAffectedFile('test.py', '#include "../header.h"'),
1344 ]
1345
1346 mock_output_api = MockOutputApi()
1347
1348 errors = PRESUBMIT._CheckForRelativeIncludes(
1349 mock_input_api, mock_output_api)
1350 self.assertEqual(0, len(errors))
1351
1352 def testInnocuousChangesAllowed(self):
1353 mock_input_api = MockInputApi()
1354 mock_input_api.files = [
1355 MockAffectedFile('test.cpp', '#include "header.h"'),
1356 MockAffectedFile('test2.cpp', '../'),
1357 ]
1358
1359 mock_output_api = MockOutputApi()
1360
1361 errors = PRESUBMIT._CheckForRelativeIncludes(
1362 mock_input_api, mock_output_api)
1363 self.assertEqual(0, len(errors))
1364
1365 def testRelativeIncludeNonWebKitProducesError(self):
1366 mock_input_api = MockInputApi()
1367 mock_input_api.files = [
1368 MockAffectedFile('test.cpp', ['#include "../header.h"']),
1369 ]
1370
1371 mock_output_api = MockOutputApi()
1372
1373 errors = PRESUBMIT._CheckForRelativeIncludes(
1374 mock_input_api, mock_output_api)
1375 self.assertEqual(1, len(errors))
1376
1377 def testRelativeIncludeWebKitProducesError(self):
1378 mock_input_api = MockInputApi()
1379 mock_input_api.files = [
1380 MockAffectedFile('third_party/WebKit/test.cpp',
1381 ['#include "../header.h']),
1382 ]
1383
1384 mock_output_api = MockOutputApi()
1385
1386 errors = PRESUBMIT._CheckForRelativeIncludes(
1387 mock_input_api, mock_output_api)
1388 self.assertEqual(1, len(errors))
1326 1389
1327 if __name__ == '__main__': 1390 if __name__ == '__main__':
1328 unittest.main() 1391 unittest.main()
OLDNEW
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698