Commit 0ba2fd42 authored by Bruce Dawson's avatar Bruce Dawson Committed by LUCI CQ

Get full paths in presubmit traceback stacks

When investigating presubmits it is sometimes handy to get stacks in
order to understand where a presubmit is being called from. In one
recent investigation to see why CheckOwners was being called multiple
times the traceback just said:

   File "c:\src\depot_tools\presubmit_support.py", line 1646, in _run_check_function
    result = eval(function_name + '(*__args)', context)
   File "<string>", line 1, in <module>
   File "PRESUBMIT.py", line 251, in CheckChangeOnUpload

That's not very helpful because Chromium has 288 files named
PRESUBMIT.py. This change just uses the actual presubmit path as the
filename parameter to compile instead of a hard-coded string, which
means that "PRESUBMIT.py" is replaced with the full path in the
tracebacks.

Bug: 1309977
Change-Id: Icacfae4399444cb24e9cfb07475b90099e2e18d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3776955
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: 's avatarGavin Mak <gavinmak@google.com>
parent 39e33e6e
......@@ -1558,7 +1558,7 @@ class PresubmitExecuter(object):
context = {}
try:
exec(compile(script_text, 'PRESUBMIT.py', 'exec', dont_inherit=True),
exec(compile(script_text, presubmit_path, 'exec', dont_inherit=True),
context)
except Exception as e:
raise PresubmitFailure('"%s" had an exception.\n%s' % (presubmit_path, e))
......
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