From d895d01ac42f2556b5db9782b9b6fcb7415bce1b Mon Sep 17 00:00:00 2001 From: Bruce Dawson Date: Tue, 2 Aug 2022 19:07:02 +0000 Subject: [PATCH] Report more issues as errors with presubmit --all Change crrev.com/c/3788227 fixed one instance of errors being treated as warnings when running "git cl presubmit" with the --upload option. This is undesirable when testing "git cl presubmit" with --all or --files, because it makes the errors harder to find. This change fixes four more newly discovered instances of this behavior. That is, this change makes it so that pylint issues and other serious problems will be reported as errors when running: git cl presubmit --force --all --upload This will make the pylint errors that this command triggers easier to find and fix: git cl presubmit --force --upload --files mojo\public\tools\bindings\*.py This change does _not_ turn cpplint warnings into errors, even though they are errors when running non-upload presubmits. That is because there are several directories that only run cpplint on upload and these directories have many errors and there is no short-term path to changing this. Bug: 1309977 Change-Id: If49f820fc6894dcd1d9aaaf4d932b04f79922bc5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3791744 Commit-Queue: Bruce Dawson Reviewed-by: Jesse McKenna --- presubmit_canned_checks.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index 81f91f5f1..b0945c565 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -152,7 +152,7 @@ def CheckAuthorizedAuthor(input_api, output_api, bot_allowlist=None): """For non-googler/chromites committers, verify the author's email address is in AUTHORS. """ - if input_api.is_committing: + if input_api.is_committing or input_api.no_diffs: error_type = output_api.PresubmitError else: error_type = output_api.PresubmitPromptWarning @@ -263,6 +263,9 @@ def CheckChangeLintsClean(input_api, output_api, source_file_filter=None, cpplint.ProcessFile(file_name, verbose_level) if cpplint._cpplint_state.error_count > 0: + # cpplint errors currently cannot be counted as errors during upload + # presubmits because some directories only run cpplint during upload and + # therefore are far from cpplint clean. if input_api.is_committing: res_type = output_api.PresubmitError else: @@ -894,7 +897,7 @@ def GetPythonUnitTests(input_api, output_api, unit_tests, python3=False): DEPRECATED. """ # We don't want to hinder users from uploading incomplete patches. - if input_api.is_committing: + if input_api.is_committing or input_api.no_diffs: message_type = output_api.PresubmitError else: message_type = output_api.PresubmitNotifyResult @@ -1020,7 +1023,7 @@ def GetPylint(input_api, 'Unsupported pylint version: %s' % version python2 = (version == '1.5') - if input_api.is_committing: + if input_api.is_committing or input_api.no_diffs: error_type = output_api.PresubmitError else: error_type = output_api.PresubmitPromptWarning