From 8fa42e2b5c4fc52b939eae2ceb027c79018b2a72 Mon Sep 17 00:00:00 2001 From: Bruce Dawson Date: Tue, 29 Mar 2022 17:05:38 +0000 Subject: [PATCH] Improve git cl presubmit --all output When running git cl presubmit --all which is handy for finding latent presubmit bugs, the 'No diff found for %s' gets printed many thousands of times, making actual issues difficult to find. This change suppresses that message, to make actual issues easier to find. The message for slow presubmits prints the name of the slow presubmit, but there are 243 different CheckChangeOnCommit functions, so the name is actually not sufficient. Therefore this change plumbs through the path to the script containing the presubmit and prints it. Similarly, the cpplint message "Done processing %s" doesn't add enough value. These changes will make it easier to find the signal in the presubmit noise. Bug: 1309977 Change-Id: Iba40b5748266e3296eeb530bb00182db4814aa5d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3556594 Reviewed-by: Gavin Mak Commit-Queue: Bruce Dawson --- cpplint.py | 1 - presubmit_support.py | 13 +++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cpplint.py b/cpplint.py index 8be609ec1a..f06f67760d 100755 --- a/cpplint.py +++ b/cpplint.py @@ -5970,7 +5970,6 @@ def ProcessFile(filename, vlevel, extra_check_functions=[]): Error(filename, linenum, 'whitespace/newline', 1, 'Unexpected \\r (^M) found; better to use only \\n') - sys.stderr.write('Done processing %s\n' % filename) _RestoreFilters() diff --git a/presubmit_support.py b/presubmit_support.py index 950cb1bbe8..b8979b384c 100755 --- a/presubmit_support.py +++ b/presubmit_support.py @@ -931,7 +931,6 @@ class _GitDiffCache(_DiffCache): # modified at all (e.g. user used --all flag in git cl presubmit). # Intead of failing, return empty string. # See: https://crbug.com/808346. - logging.warning('No diff found for %s' % path) return '' return self._diffs_by_file[path] @@ -1575,7 +1574,8 @@ class PresubmitExecuter(object): continue logging.debug('Running %s in %s', function_name, presubmit_path) results.extend( - self._run_check_function(function_name, context, sink)) + self._run_check_function(function_name, context, sink, + presubmit_path)) logging.debug('Running %s done.', function_name) self.more_cc.extend(output_api.more_cc) @@ -1587,7 +1587,8 @@ class PresubmitExecuter(object): if function_name in list(context.keys()): logging.debug('Running %s in %s', function_name, presubmit_path) results.extend( - self._run_check_function(function_name, context, sink)) + self._run_check_function(function_name, context, sink, + presubmit_path)) logging.debug('Running %s done.', function_name) self.more_cc.extend(output_api.more_cc) @@ -1599,7 +1600,7 @@ class PresubmitExecuter(object): os.chdir(main_path) return results - def _run_check_function(self, function_name, context, sink=None): + def _run_check_function(self, function_name, context, sink, presubmit_path): """Evaluates and returns the result of a given presubmit function. If sink is given, the result of the presubmit function will be reported @@ -1628,8 +1629,8 @@ class PresubmitExecuter(object): elapsed_time = time_time() - start_time if elapsed_time > 10.0: - sys.stdout.write( - '%s took %.1fs to run.\n' % (function_name, elapsed_time)) + sys.stdout.write('%s from %s took %.1fs to run.\n' % + (function_name, presubmit_path, elapsed_time)) if sink: status = rdb_wrapper.STATUS_PASS if any(r.fatal for r in result):