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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT_test.py
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py
index 3fff4a2f2525b338a7e03926f78b7219401dc452..394efb7ba818ae0de4b54de90bae85260ab48412 100755
--- a/PRESUBMIT_test.py
+++ b/PRESUBMIT_test.py
@@ -1323,6 +1323,69 @@ class RiskyJsTest(unittest.TestCase):
mock_input_api, MockOutputApi())
self.assertEqual(0, len(warnings))
+class RelativeIncludesTest(unittest.TestCase):
+ def testThirdPartyNotWebKitIgnored(self):
+ mock_input_api = MockInputApi()
+ mock_input_api.files = [
+ MockAffectedFile('third_party/test.cpp', '#include "../header.h"'),
+ MockAffectedFile('third_party/test/test.cpp', '#include "../header.h"'),
+ ]
+
+ mock_output_api = MockOutputApi()
+
+ errors = PRESUBMIT._CheckForRelativeIncludes(
+ mock_input_api, mock_output_api)
+ self.assertEqual(0, len(errors))
+
+ def testNonCppFileIgnored(self):
+ mock_input_api = MockInputApi()
+ mock_input_api.files = [
+ MockAffectedFile('test.py', '#include "../header.h"'),
+ ]
+
+ mock_output_api = MockOutputApi()
+
+ errors = PRESUBMIT._CheckForRelativeIncludes(
+ mock_input_api, mock_output_api)
+ self.assertEqual(0, len(errors))
+
+ def testInnocuousChangesAllowed(self):
+ mock_input_api = MockInputApi()
+ mock_input_api.files = [
+ MockAffectedFile('test.cpp', '#include "header.h"'),
+ MockAffectedFile('test2.cpp', '../'),
+ ]
+
+ mock_output_api = MockOutputApi()
+
+ errors = PRESUBMIT._CheckForRelativeIncludes(
+ mock_input_api, mock_output_api)
+ self.assertEqual(0, len(errors))
+
+ def testRelativeIncludeNonWebKitProducesError(self):
+ mock_input_api = MockInputApi()
+ mock_input_api.files = [
+ MockAffectedFile('test.cpp', ['#include "../header.h"']),
+ ]
+
+ mock_output_api = MockOutputApi()
+
+ errors = PRESUBMIT._CheckForRelativeIncludes(
+ mock_input_api, mock_output_api)
+ self.assertEqual(1, len(errors))
+
+ def testRelativeIncludeWebKitProducesError(self):
+ mock_input_api = MockInputApi()
+ mock_input_api.files = [
+ MockAffectedFile('third_party/WebKit/test.cpp',
+ ['#include "../header.h']),
+ ]
+
+ mock_output_api = MockOutputApi()
+
+ errors = PRESUBMIT._CheckForRelativeIncludes(
+ mock_input_api, mock_output_api)
+ self.assertEqual(1, len(errors))
if __name__ == '__main__':
unittest.main()
« 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