From 0fb33b26eb533a6f6184cab75ad50c229ee5c130 Mon Sep 17 00:00:00 2001 From: Debrian Figueroa Date: Tue, 16 Jul 2019 18:22:50 +0000 Subject: [PATCH] Updated presubmit error message format. Changed all headers in message to be the size of header 4 tags. Made sure there is always a new line after code tag(```). Change-Id: I772941a8bbf0634c9496ec648533110997e23cde Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1702293 Commit-Queue: Debrian Figueroa Reviewed-by: Robbie Iannucci --- recipes/recipe_modules/presubmit/api.py | 9 +++++---- recipes/recipe_modules/presubmit/tests/execute.py | 11 ++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/recipes/recipe_modules/presubmit/api.py b/recipes/recipe_modules/presubmit/api.py index 989576a9d3..9fbb7f7d56 100644 --- a/recipes/recipe_modules/presubmit/api.py +++ b/recipes/recipe_modules/presubmit/api.py @@ -175,9 +175,10 @@ def _limitSize(message_list, char_limit=450): # If code is being cropped, the closing code tag will # get removed, so add it back before the hint. code_tag = '```' - oversized_msg = ('%s\n**Error size > %d chars, ' + message_list[index - 1] = '\n'.join((message_list[index - 1], code_tag)) + oversized_msg = ('\n**Error size > %d chars, ' 'there are %d more error(s) (%d total)**') % ( - code_tag, char_limit, total_errors - index, total_errors + char_limit, total_errors - index, total_errors ) return message_list[:index] + [oversized_msg, hint] return message_list @@ -223,7 +224,7 @@ def _createSummaryMarkdown(step_json): warning_count = len(step_json['warnings']) notif_count = len(step_json['notifications']) description = ( - '### There are %d error(s), %d warning(s),' + '#### There are %d error(s), %d warning(s),' ' and %d notifications(s). Here are the errors:') % ( len(errors), warning_count, notif_count ) @@ -241,7 +242,7 @@ def _createSummaryMarkdown(step_json): error_messages.insert(0, description) if warning_count or notif_count: error_messages.append( - ('##### To see notifications and warnings,' + ('#### To see notifications and warnings,' ' look at the stdout of the presubmit step.') ) return '\n\n'.join(error_messages) diff --git a/recipes/recipe_modules/presubmit/tests/execute.py b/recipes/recipe_modules/presubmit/tests/execute.py index 6d6281d21a..57efd3dd5d 100644 --- a/recipes/recipe_modules/presubmit/tests/execute.py +++ b/recipes/recipe_modules/presubmit/tests/execute.py @@ -78,7 +78,7 @@ def GenTests(api): api.post_process(post_process.StatusFailure) + api.post_process( post_process.ResultReason, - (u'### There are 0 error(s), 0 warning(s), and 0 notifications(s).' + (u'#### There are 0 error(s), 0 warning(s), and 0 notifications(s).' ' Here are the errors:' '\n\nTimeout occurred during presubmit step.')) + api.post_process(post_process.DropExpectation) @@ -124,7 +124,7 @@ def GenTests(api): ) + api.post_process(post_process.StatusFailure) + api.post_process(post_process.ResultReason, textwrap.dedent(u''' - ### There are 2 error(s), 1 warning(s), and 1 notifications(s). Here are the errors: + #### There are 2 error(s), 1 warning(s), and 1 notifications(s). Here are the errors: **ERROR** ``` @@ -138,7 +138,7 @@ def GenTests(api): Expected "," after item in list ``` - ##### To see notifications and warnings, look at the stdout of the presubmit step. + #### To see notifications and warnings, look at the stdout of the presubmit step. ''').strip() ) + api.post_process(post_process.DropExpectation) @@ -166,7 +166,7 @@ def GenTests(api): ) + api.post_process(post_process.StatusFailure) + api.post_process(post_process.ResultReason, textwrap.dedent(''' - ### There are 1 error(s), 0 warning(s), and 0 notifications(s). Here are the errors: + #### There are 1 error(s), 0 warning(s), and 0 notifications(s). Here are the errors: **ERROR** ``` @@ -182,6 +182,7 @@ def GenTests(api): reallyLongFakeAccountNameEmail@chromium.org reallyLongFakeAccountNameEmail@chromium.org ``` + **Error size > 450 chars, there are 2 more error(s) (15 total)** **The complete output can be found at the bottom of the presubmit stdout.** ''').strip() @@ -209,7 +210,7 @@ def GenTests(api): ) + api.post_process(post_process.StatusException) + api.post_process(post_process.ResultReason, textwrap.dedent(u''' - ### There are 1 error(s), 0 warning(s), and 0 notifications(s). Here are the errors: + #### There are 1 error(s), 0 warning(s), and 0 notifications(s). Here are the errors: **ERROR** ```