Add possibility to skip check_includes presubmit check.
Bug: webrtc:9419
Change-Id: I0fd8fb37cd2d000f0e1f488bf98d39b5ee5e9305
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/157963
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29576}
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 99835cc..34f8230 100755
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -539,18 +539,21 @@
return result
-def CheckCheckIncludesIsNotUsed(gn_files, output_api):
+def CheckCheckIncludesIsNotUsed(gn_files, input_api, output_api):
result = []
error_msg = ('check_includes overrides are not allowed since it can cause '
'incorrect dependencies to form. It effectively means that your '
'module can include any .h file without depending on its '
'corresponding target. There are some exceptional cases when '
- 'this is allowed: if so, get approval from a .gn owner in the'
+ 'this is allowed: if so, get approval from a .gn owner in the '
'root OWNERS file.\n'
'Used in: %s (line %d).')
+ no_presubmit_re = input_api.re.compile(
+ r'# no-presubmit-check TODO\(bugs\.webrtc\.org/\d+\)')
for affected_file in gn_files:
for (line_number, affected_line) in affected_file.ChangedContents():
- if 'check_includes' in affected_line:
+ if ('check_includes' in affected_line
+ and not no_presubmit_re.search(affected_line)):
result.append(
output_api.PresubmitError(error_msg % (affected_file.LocalPath(),
line_number)))
@@ -573,7 +576,7 @@
result.extend(CheckNoPackageBoundaryViolations(input_api, gn_files,
output_api))
result.extend(CheckPublicDepsIsNotUsed(gn_files, input_api, output_api))
- result.extend(CheckCheckIncludesIsNotUsed(gn_files, output_api))
+ result.extend(CheckCheckIncludesIsNotUsed(gn_files, input_api, output_api))
result.extend(CheckNoWarningSuppressionFlagsAreAdded(gn_files, input_api,
output_api))
return result