Commit 174c2933 authored by Nodir Turakulov's avatar Nodir Turakulov Committed by Commit Bot

tryserver module: fix in set_failure_hash

set_failure_hash assumes that (StepFailure is raised) => (some steps
were ran), which is not a correct implication.
Check that there was a step before.

R=iannucci@chromium.org
BUG=

Change-Id: I36ad187584cb42696676e3339f6a77fc77dfd3b1
Reviewed-on: https://chromium-review.googlesource.com/412994
Commit-Queue: Nodir Turakulov <nodir@chromium.org>
Reviewed-by: 's avatarRobbie Iannucci <iannucci@chromium.org>
parent 1d196c25
......@@ -284,14 +284,17 @@ class TryserverApi(recipe_api.RecipeApi):
except self.m.step.StepFailure as e:
self.add_failure_reason(e.reason)
failure_hash = hashlib.sha1()
failure_hash.update(self.m.json.dumps(self._failure_reasons))
step_result = self.m.step.active_result
step_result.presentation.properties['failure_hash'] = \
failure_hash.hexdigest()
raise
try:
step_result = self.m.step.active_result
except ValueError:
step_result = None
if step_result:
failure_hash = hashlib.sha1()
failure_hash.update(self.m.json.dumps(self._failure_reasons))
step_result.presentation.properties['failure_hash'] = (
failure_hash.hexdigest())
raise e
def get_footers(self, patch_text=None):
"""Retrieves footers from the patch description.
......
[
{
"name": "$result",
"reason": "boom!",
"recipe_result": null,
"status_code": 1
}
]
\ No newline at end of file
......@@ -15,6 +15,10 @@ DEPS = [
def RunSteps(api):
if api.properties.get('set_failure_hash_with_no_steps'):
with api.tryserver.set_failure_hash():
raise api.step.StepFailure('boom!')
api.path['checkout'] = api.path['start_dir']
if api.properties.get('patch_text'):
api.step('patch_text test', [
......@@ -106,3 +110,6 @@ def GenTests(api):
'parse description (2)',
api.json.output({'Foo': ['bar']}))
)
yield (api.test('set_failure_hash_with_no_steps') +
api.properties(set_failure_hash_with_no_steps=True))
\ No newline at end of file
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