summaryrefslogtreecommitdiff
path: root/chromium/PRESUBMIT.py
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-05-24 11:40:17 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-05-24 12:42:11 +0000
commit5d87695f37678f96492b258bbab36486c59866b4 (patch)
treebe9783bbaf04fb930c4d74ca9c00b5e7954c8bc6 /chromium/PRESUBMIT.py
parent6c11fb357ec39bf087b8b632e2b1e375aef1b38b (diff)
downloadqtwebengine-chromium-5d87695f37678f96492b258bbab36486c59866b4.tar.gz
BASELINE: Update Chromium to 75.0.3770.56
Change-Id: I86d2007fd27a45d5797eee06f4c9369b8b50ac4f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/PRESUBMIT.py')
-rw-r--r--chromium/PRESUBMIT.py228
1 files changed, 219 insertions, 9 deletions
diff --git a/chromium/PRESUBMIT.py b/chromium/PRESUBMIT.py
index 894304619dc..96103413e19 100644
--- a/chromium/PRESUBMIT.py
+++ b/chromium/PRESUBMIT.py
@@ -48,6 +48,7 @@ _TEST_CODE_EXCLUDED_PATHS = (
r'.+_test_(base|support|util)%s' % _IMPLEMENTATION_EXTENSIONS,
r'.+_(api|browser|eg|int|perf|pixel|unit|ui)?test(_[a-z]+)?%s' %
_IMPLEMENTATION_EXTENSIONS,
+ r'.+_(fuzz|fuzzer)(_[a-z]+)?%s' % _IMPLEMENTATION_EXTENSIONS,
r'.+profile_sync_service_harness%s' % _IMPLEMENTATION_EXTENSIONS,
r'.*[\\/](test|tool(s)?)[\\/].*',
# content_shell is used for running layout tests.
@@ -58,6 +59,7 @@ _TEST_CODE_EXCLUDED_PATHS = (
r'testing[\\/]iossim[\\/]iossim\.mm$',
)
+_THIRD_PARTY_EXCEPT_BLINK = 'third_party/(?!blink/)'
_TEST_ONLY_WARNING = (
'You might be calling functions intended only for testing from\n'
@@ -72,6 +74,10 @@ _INCLUDE_ORDER_WARNING = (
'cppguide.html#Names_and_Order_of_Includes')
+# Format: Sequence of tuples containing:
+# * String pattern or, if starting with a slash, a regular expression.
+# * Sequence of strings to show when the pattern matches.
+# * Error flag. True if a match is a presubmit error, otherwise it's a warning.
_BANNED_JAVA_FUNCTIONS = (
(
'StrictMode.allowThreadDiskReads()',
@@ -91,6 +97,10 @@ _BANNED_JAVA_FUNCTIONS = (
),
)
+# Format: Sequence of tuples containing:
+# * String pattern or, if starting with a slash, a regular expression.
+# * Sequence of strings to show when the pattern matches.
+# * Error flag. True if a match is a presubmit error, otherwise it's a warning.
_BANNED_OBJC_FUNCTIONS = (
(
'addTrackingRect:',
@@ -184,6 +194,10 @@ _BANNED_OBJC_FUNCTIONS = (
),
)
+# Format: Sequence of tuples containing:
+# * String pattern or, if starting with a slash, a regular expression.
+# * Sequence of strings to show when the pattern matches.
+# * Error flag. True if a match is a presubmit error, otherwise it's a warning.
_BANNED_IOS_OBJC_FUNCTIONS = (
(
r'/\bTEST[(]',
@@ -207,10 +221,12 @@ _BANNED_IOS_OBJC_FUNCTIONS = (
)
+# Format: Sequence of tuples containing:
+# * String pattern or, if starting with a slash, a regular expression.
+# * Sequence of strings to show when the pattern matches.
+# * Error flag. True if a match is a presubmit error, otherwise it's a warning.
+# * Sequence of paths to *not* check (regexps).
_BANNED_CPP_FUNCTIONS = (
- # Make sure that gtest's FRIEND_TEST() macro is not used; the
- # FRIEND_TEST_ALL_PREFIXES() macro from base/gtest_prod_util.h should be
- # used instead since that allows for FLAKY_ and DISABLED_ prefixes.
(
r'\bNULL\b',
(
@@ -219,6 +235,9 @@ _BANNED_CPP_FUNCTIONS = (
True,
(),
),
+ # Make sure that gtest's FRIEND_TEST() macro is not used; the
+ # FRIEND_TEST_ALL_PREFIXES() macro from base/gtest_prod_util.h should be
+ # used instead since that allows for FLAKY_ and DISABLED_ prefixes.
(
'FRIEND_TEST(',
(
@@ -447,6 +466,86 @@ _BANNED_CPP_FUNCTIONS = (
(),
),
(
+ r'/\bstd::to_string\b',
+ (
+ 'std::to_string is locale dependent and slower than alternatives.',
+ 'For locale-independent strings, e.g. writing numbers to and from',
+ 'disk profiles, use base::NumberToString().',
+ 'For user-visible strings, use base::FormatNumber() and',
+ 'the related functions in base/i18n/number_formatting.h.',
+ ),
+ False, # Only a warning for now since it is already used,
+ [_THIRD_PARTY_EXCEPT_BLINK], # Don't warn in third_party folders.
+ ),
+ (
+ r'/\bstd::shared_ptr\b',
+ (
+ 'std::shared_ptr should not be used. Use scoped_refptr instead.',
+ ),
+ True,
+ [_THIRD_PARTY_EXCEPT_BLINK], # Not an error in third_party folders.
+ ),
+ (
+ r'/\blong long\b',
+ (
+ 'long long is banned. Use stdint.h if you need a 64 bit number.',
+ ),
+ False, # Only a warning since it is already used.
+ [_THIRD_PARTY_EXCEPT_BLINK], # Don't warn in third_party folders.
+ ),
+ (
+ r'/\bstd::bind\b',
+ (
+ 'std::bind is banned because of lifetime risks.',
+ 'Use base::BindOnce or base::BindRepeating instead.',
+ ),
+ True,
+ [_THIRD_PARTY_EXCEPT_BLINK], # Not an error in third_party folders.
+ ),
+ (
+ r'/\b#include <chrono>\b',
+ (
+ '<chrono> overlaps with Time APIs in base. Keep using',
+ 'base classes.',
+ ),
+ True,
+ [_THIRD_PARTY_EXCEPT_BLINK], # Not an error in third_party folders.
+ ),
+ (
+ r'/\b#include <exception>\b',
+ (
+ 'Exceptions are banned and disabled in Chromium.',
+ ),
+ True,
+ [_THIRD_PARTY_EXCEPT_BLINK], # Not an error in third_party folders.
+ ),
+ (
+ r'/\bstd::function\b',
+ (
+ 'std::function is banned. Instead use base::Callback which directly',
+ 'supports Chromium\'s weak pointers, ref counting and more.',
+ ),
+ False, # Only a warning since there are dozens of uses already.
+ [_THIRD_PARTY_EXCEPT_BLINK], # Do not warn in third_party folders.
+ ),
+ (
+ r'/\b#include <random>\b',
+ (
+ 'Do not use any random number engines from <random>. Instead',
+ 'use base::RandomBitGenerator.',
+ ),
+ True,
+ [_THIRD_PARTY_EXCEPT_BLINK], # Not an error in third_party folders.
+ ),
+ (
+ r'/\bstd::ratio\b',
+ (
+ 'std::ratio is banned by the Google Style Guide.',
+ ),
+ True,
+ [_THIRD_PARTY_EXCEPT_BLINK], # Not an error in third_party folders.
+ ),
+ (
(r'/base::ThreadRestrictions::(ScopedAllowIO|AssertIOAllowed|'
r'DisallowWaiting|AssertWaitAllowed|SetWaitAllowed|ScopedAllowWait)'),
(
@@ -483,6 +582,15 @@ _BANNED_CPP_FUNCTIONS = (
(),
),
(
+ r'/base::SharedMemory(|Handle)',
+ (
+ 'base::SharedMemory is deprecated. Please use',
+ '{Writable,ReadOnly}SharedMemoryRegion instead.',
+ ),
+ False,
+ (),
+ ),
+ (
r'RunMessageLoop',
(
'RunMessageLoop is deprecated, use RunLoop instead.',
@@ -536,9 +644,9 @@ _BANNED_CPP_FUNCTIONS = (
(),
),
(
- 'sqlite3_initialize',
+ 'sqlite3_initialize(',
(
- 'Instead of sqlite3_initialize, depend on //sql, ',
+ 'Instead of calling sqlite3_initialize(), depend on //sql, ',
'#include "sql/initialize.h" and use sql::EnsureSqliteInitialized().',
),
True,
@@ -591,6 +699,25 @@ _BANNED_CPP_FUNCTIONS = (
True,
(),
),
+ (
+ 'DEFINE_TYPE_CASTS',
+ (
+ 'DEFINE_TYPE_CASTS is deprecated. Instead, use downcast helpers from ',
+ '//third_party/blink/renderer/platform/casting.h.'
+ ),
+ True,
+ (
+ r'^third_party/blink/renderer/.*\.(cc|h)$',
+ ),
+ ),
+ (
+ r'/\bmojo::DataPipe\b',
+ (
+ 'mojo::DataPipe is deprecated. Use mojo::CreateDataPipe instead.',
+ ),
+ True,
+ (),
+ ),
)
@@ -652,6 +779,7 @@ _ANDROID_SPECIFIC_PYDEPS_FILES = [
'android_webview/tools/run_cts.pydeps',
'base/android/jni_generator/jni_generator.pydeps',
'base/android/jni_generator/jni_registration_generator.pydeps',
+ 'build/android/devil_chromium.pydeps',
'build/android/gyp/aar.pydeps',
'build/android/gyp/aidl.pydeps',
'build/android/gyp/apkbuilder.pydeps',
@@ -666,7 +794,6 @@ _ANDROID_SPECIFIC_PYDEPS_FILES = [
'build/android/gyp/create_java_binary_script.pydeps',
'build/android/gyp/create_size_info_files.pydeps',
'build/android/gyp/create_stack_script.pydeps',
- 'build/android/gyp/create_test_runner_script.pydeps',
'build/android/gyp/create_tool_wrapper.pydeps',
'build/android/gyp/desugar.pydeps',
'build/android/gyp/dexsplitter.pydeps',
@@ -695,9 +822,8 @@ _ANDROID_SPECIFIC_PYDEPS_FILES = [
'build/android/test_runner.pydeps',
'build/android/test_wrapper/logdog_wrapper.pydeps',
'build/protoc_java.pydeps',
- ('build/secondary/third_party/android_platform/'
- 'development/scripts/stack.pydeps'),
'net/tools/testserver/testserver.pydeps',
+ 'third_party/android_platform/development/scripts/stack.pydeps',
]
@@ -1635,6 +1761,7 @@ def _CheckSpamLogging(input_api, output_api):
r"^chrome[\\/]browser[\\/]chrome_browser_main\.cc$",
r"^chrome[\\/]browser[\\/]ui[\\/]startup[\\/]"
r"startup_browser_creator\.cc$",
+ r"^chrome[\\/]browser[\\/]browser_switcher[\\/]bho[\\/].*",
r"^chrome[\\/]installer[\\/]setup[\\/].*",
r"^chrome[\\/]chrome_cleaner[\\/].*",
r"chrome[\\/]browser[\\/]diagnostics[\\/]" +
@@ -2223,6 +2350,43 @@ def _CheckUselessForwardDeclarations(input_api, output_api):
return results
+def _CheckAndroidDebuggableBuild(input_api, output_api):
+ """Checks that code uses BuildInfo.isDebugAndroid() instead of
+ Build.TYPE.equals('') or ''.equals(Build.TYPE) to check if
+ this is a debuggable build of Android.
+ """
+ build_type_check_pattern = input_api.re.compile(
+ r'\bBuild\.TYPE\.equals\(|\.equals\(\s*\bBuild\.TYPE\)')
+
+ errors = []
+
+ sources = lambda affected_file: input_api.FilterSourceFile(
+ affected_file,
+ black_list=(_EXCLUDED_PATHS +
+ _TEST_CODE_EXCLUDED_PATHS +
+ input_api.DEFAULT_BLACK_LIST +
+ (r"^android_webview[\\/]support_library[\\/]"
+ "boundary_interfaces[\\/]",
+ r"^chrome[\\/]android[\\/]webapk[\\/].*",
+ r'^third_party[\\/].*',
+ r"tools[\\/]android[\\/]customtabs_benchmark[\\/].*",
+ r"webview[\\/]chromium[\\/]License.*",)),
+ white_list=[r'.*\.java$'])
+
+ for f in input_api.AffectedSourceFiles(sources):
+ for line_num, line in f.ChangedContents():
+ if build_type_check_pattern.search(line):
+ errors.append("%s:%d" % (f.LocalPath(), line_num))
+
+ results = []
+
+ if errors:
+ results.append(output_api.PresubmitPromptWarning(
+ 'Build.TYPE.equals or .equals(Build.TYPE) usage is detected.'
+ ' Please use BuildInfo.isDebugAndroid() instead.',
+ errors))
+
+ return results
# TODO: add unit tests
def _CheckAndroidToastUsage(input_api, output_api):
@@ -2556,7 +2720,11 @@ class PydepsChecker(object):
file_to_pydeps_map = None
for f in self._input_api.AffectedFiles(include_deletes=True):
local_path = f.LocalPath()
- if local_path == 'DEPS':
+ # Changes to DEPS can lead to .pydeps changes if any .py files are in
+ # subrepositories. We can't figure out which files change, so re-check
+ # all files.
+ # Changes to print_python_deps.py affect all .pydeps.
+ if local_path == 'DEPS' or local_path.endswith('print_python_deps.py'):
return self._pydeps_files
elif local_path.endswith('.pydeps'):
if local_path in self._pydeps_files:
@@ -3015,10 +3183,51 @@ def _CheckCorrectProductNameInMessages(input_api, output_api):
return all_problems
+def _CheckBuildtoolsRevisionsAreInSync(input_api, output_api):
+ # TODO(crbug.com/941824): We need to make sure the entries in
+ # //buildtools/DEPS are kept in sync with the entries in //DEPS
+ # so that users of //buildtools in other projects get the same tooling
+ # Chromium gets. If we ever fix the referenced bug and add 'includedeps'
+ # support to gclient, we can eliminate the duplication and delete
+ # this presubmit check.
+
+ # Update this regexp if new revisions are added to the files.
+ rev_regexp = input_api.re.compile(
+ "'((clang_format|libcxx|libcxxabi|libunwind)_revision|gn_version)':")
+
+ # If a user is changing one revision, they need to change the same
+ # line in both files. This means that any given change should contain
+ # exactly the same list of changed lines that match the regexps. The
+ # replace(' ', '') call allows us to ignore whitespace changes to the
+ # lines. The 'long_text' parameter to the error will contain the
+ # list of changed lines in both files, which should make it easy enough
+ # to spot the error without going overboard in this implementation.
+ revs_changes = {
+ 'DEPS': {},
+ 'buildtools/DEPS': {},
+ }
+ long_text = ''
+
+ for f in input_api.AffectedFiles(
+ file_filter=lambda f: f.LocalPath() in ('DEPS', 'buildtools/DEPS')):
+ for line_num, line in f.ChangedContents():
+ if rev_regexp.search(line):
+ revs_changes[f.LocalPath()][line.replace(' ', '')] = line
+ long_text += '%s:%d: %s\n' % (f.LocalPath(), line_num, line)
+
+ if set(revs_changes['DEPS']) != set(revs_changes['buildtools/DEPS']):
+ return [output_api.PresubmitError(
+ 'Change buildtools revisions in sync in both //DEPS and '
+ '//buildtools/DEPS.', long_text=long_text + '\n')]
+ else:
+ return []
+
+
def _AndroidSpecificOnUploadChecks(input_api, output_api):
"""Groups upload checks that target android code."""
results = []
results.extend(_CheckAndroidCrLogUsage(input_api, output_api))
+ results.extend(_CheckAndroidDebuggableBuild(input_api, output_api))
results.extend(_CheckAndroidNewMdpiAssetLocation(input_api, output_api))
results.extend(_CheckAndroidToastUsage(input_api, output_api))
results.extend(_CheckAndroidTestJUnitInheritance(input_api, output_api))
@@ -3099,6 +3308,7 @@ def _CommonChecks(input_api, output_api):
input_api.canned_checks.CheckVPythonSpec(input_api, output_api)))
results.extend(_CheckTranslationScreenshots(input_api, output_api))
results.extend(_CheckCorrectProductNameInMessages(input_api, output_api))
+ results.extend(_CheckBuildtoolsRevisionsAreInSync(input_api, output_api))
for f in input_api.AffectedFiles():
path, name = input_api.os_path.split(f.LocalPath())