Fix IOS/OSX macro tests
When switching to BUILDFLAGS in crrev.com/c/3407775 the presubmits and
presubmit tests were not appropriate updated. Now they are.
This can be tested with "vpython3 chrome\PRESUBMIT_test.py"
Bug: 1309977
Change-Id: Ieb83be41404920cfb03b404bcdfec0ea1bd83790
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3566820
Reviewed-by: Xiaohan Wang <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Auto-Submit: Bruce Dawson <[email protected]>
Commit-Queue: Avi Drissman <[email protected]>
Cr-Commit-Position: refs/heads/main@{#996711}
diff --git a/chrome/PRESUBMIT.py b/chrome/PRESUBMIT.py
index 3f4d409..1c3a7bc 100644
--- a/chrome/PRESUBMIT.py
+++ b/chrome/PRESUBMIT.py
@@ -64,68 +64,68 @@
items=problems)]
-def _CheckNoOSAPPLEMacrosInChromeFile(input_api, f):
- """Check for OS_APPLE in a given file in chrome/."""
+def _CheckNoIsAppleBuildFlagsInChromeFile(input_api, f):
+ """Check for IS_APPLE in a given file in chrome/."""
preprocessor_statement = input_api.re.compile(r'^\s*#')
- apple_macro = input_api.re.compile(r'defined\(OS_APPLE\)')
+ apple_buildflag = input_api.re.compile(r'BUILDFLAG\(IS_APPLE\)')
results = []
for lnum, line in f.ChangedContents():
- if preprocessor_statement.search(line) and apple_macro.search(line):
+ if preprocessor_statement.search(line) and apple_buildflag.search(line):
results.append(' %s:%d' % (f.LocalPath(), lnum))
return results
-def _CheckNoOSAPPLEMacrosInChrome(input_api, output_api):
- """Check for OS_APPLE which isn't used in chrome/."""
- apple_macros = []
+def _CheckNoIsAppleBuildFlagsInChrome(input_api, output_api):
+ """Check for IS_APPLE which isn't used in chrome/."""
+ apple_buildflags = []
def SourceFilter(affected_file):
return input_api.FilterSourceFile(affected_file, INCLUDE_SOURCE_FILES_ONLY,
input_api.DEFAULT_FILES_TO_SKIP)
for f in input_api.AffectedSourceFiles(SourceFilter):
- apple_macros.extend(_CheckNoOSAPPLEMacrosInChromeFile(input_api, f))
+ apple_buildflags.extend(_CheckNoIsAppleBuildFlagsInChromeFile(input_api, f))
- if not apple_macros:
+ if not apple_buildflags:
return []
return [output_api.PresubmitError(
- 'OS_APPLE is not used in chrome/ but found in:\n', apple_macros)]
+ 'IS_APPLE is not used in chrome/ but found in:\n', apple_buildflags)]
-def _CheckNoOSIOSMacrosInChromeFile(input_api, f):
- """Check for OS_IOS in a given file in chrome/."""
+def _CheckNoIsIOSBuildFlagsInChromeFile(input_api, f):
+ """Check for IS_IOS in a given file in chrome/."""
preprocessor_statement = input_api.re.compile(r'^\s*#')
- ios_macro = input_api.re.compile(r'defined\(OS_IOS\)')
+ ios_buildflag = input_api.re.compile(r'BUILDFLAG\(IS_IOS\)')
results = []
for lnum, line in f.ChangedContents():
- if preprocessor_statement.search(line) and ios_macro.search(line):
+ if preprocessor_statement.search(line) and ios_buildflag.search(line):
results.append(' %s:%d' % (f.LocalPath(), lnum))
return results
-def _CheckNoOSIOSMacrosInChrome(input_api, output_api):
- """Check for OS_IOS which isn't used in chrome/."""
- ios_macros = []
+def _CheckNoIsIOSBuildFlagsInChrome(input_api, output_api):
+ """Check for IS_IOS which isn't used in chrome/."""
+ ios_buildflags = []
def SourceFilter(affected_file):
return input_api.FilterSourceFile(affected_file, INCLUDE_SOURCE_FILES_ONLY,
input_api.DEFAULT_FILES_TO_SKIP)
for f in input_api.AffectedSourceFiles(SourceFilter):
- ios_macros.extend(_CheckNoOSIOSMacrosInChromeFile(input_api, f))
+ ios_buildflags.extend(_CheckNoIsIOSBuildFlagsInChromeFile(input_api, f))
- if not ios_macros:
+ if not ios_buildflags:
return []
return [output_api.PresubmitError(
- 'OS_IOS is not used in chrome/ but found in:\n', ios_macros)]
+ 'IS_IOS is not used in chrome/ but found in:\n', ios_buildflags)]
def _CommonChecks(input_api, output_api):
"""Checks common to both upload and commit."""
results = []
results.extend(_CheckNoContentUnitTestsInChrome(input_api, output_api))
- results.extend(_CheckNoOSAPPLEMacrosInChrome(input_api, output_api))
- results.extend(_CheckNoOSIOSMacrosInChrome(input_api, output_api))
+ results.extend(_CheckNoIsAppleBuildFlagsInChrome(input_api, output_api))
+ results.extend(_CheckNoIsIOSBuildFlagsInChrome(input_api, output_api))
return results