mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 10:41:31 +00:00
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: Gavin Mak <gavinmak@google.com>
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user