Commit 8fa42e2b authored by Bruce Dawson's avatar Bruce Dawson Committed by LUCI CQ

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/+/3556594Reviewed-by: 's avatarGavin Mak <gavinmak@google.com>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
parent f560d36b
......@@ -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()
......
......@@ -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):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment