Commit 2c48f24c authored by Edward Lemur's avatar Edward Lemur Committed by Commit Bot

git-cl: Report presubmit execution time.

Bug: 970113
Change-Id: Iff31287d1ab8f683f7745fd0abc62b138ffcf219
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1642649Reviewed-by: 's avatarDirk Pranke <dpranke@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
parent 0f476788
......@@ -1591,11 +1591,18 @@ class Changelist(object):
def RunHook(self, committing, may_prompt, verbose, change, parallel):
"""Calls sys.exit() if the hook fails; returns a HookResults otherwise."""
try:
return presubmit_support.DoPresubmitChecks(change, committing,
start = time_time()
result = presubmit_support.DoPresubmitChecks(change, committing,
verbose=verbose, output_stream=sys.stdout, input_stream=sys.stdin,
default_presubmit=None, may_prompt=may_prompt,
gerrit_obj=self._codereview_impl.GetGerritObjForPresubmit(),
parallel=parallel)
metrics.collector.add_repeated('sub_commands', {
'command': 'presubmit',
'execution_time': time_time() - start,
'exit_code': 0 if result.should_continue() else 1,
})
return result
except presubmit_support.PresubmitFailure as e:
DieWithError('%s\nMaybe your depot_tools is out of date?' % e)
......
......@@ -894,6 +894,13 @@ class TestGitCl(TestCase):
calls += [
((['git', 'config', 'user.email'],), 'me@example.com'),
(('time.time',), 1000,),
(('time.time',), 3000,),
(('add_repeated', 'sub_commands', {
'execution_time': 2000,
'command': 'presubmit',
'exit_code': 0
}), None,),
((['git', 'diff', '--no-ext-diff', '--stat', '-l100000', '-C50'] +
([custom_cl_base] if custom_cl_base else
[ancestor_revision, 'HEAD']),),
......
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