[recipes] Migrate away from deprecated post_process checks

Migrate away from ResultReason/ResultReasonRE. Also, do some minor
reformatting.

Bug: 339834630
Change-Id: Ibad136c4389955476af87bcc148581bea408415c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5565454
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
Auto-Submit: Rob Mohr <mohrr@google.com>
changes/54/5565454/2
Rob Mohr 1 year ago committed by LUCI CQ
parent 499342211b
commit 2377dbfdbc

@ -185,12 +185,15 @@ def GenTests(api):
api.expect_status('INFRA_FAILURE'), api.expect_status('INFRA_FAILURE'),
) )
yield ( yield api.test(
api.test('tryjob_fail_missing_bot_update_json', status="INFRA_FAILURE") + 'tryjob_fail_missing_bot_update_json',
try_build() + api.override_step_data('bot_update', retcode=1) + try_build(),
api.post_process(post_process.ResultReasonRE, 'Infra Failure.*') + api.override_step_data('bot_update', retcode=1),
api.post_process(post_process.StatusException) + api.post_process(post_process.SummaryMarkdownRE, 'Infra Failure.*'),
api.post_process(post_process.DropExpectation)) api.post_process(post_process.StatusException),
api.post_process(post_process.DropExpectation),
status='INFRA_FAILURE')
yield ( yield (
api.test('clobber') + api.test('clobber') +
api.properties(clobber=1) api.properties(clobber=1)

@ -21,6 +21,7 @@ def GenTests(api):
'no-json', 'no-json',
api.override_step_data('gclient sync', retcode=1), api.override_step_data('gclient sync', retcode=1),
# Should not fail with uncaught exception # Should not fail with uncaught exception
api.post_process(post_process.ResultReasonRE, r'^(?!Uncaught Exception)'), api.post_process(post_process.SummaryMarkdownRE,
r'^(?!Uncaught Exception)'),
api.post_process(post_process.DropExpectation), api.post_process(post_process.DropExpectation),
status="INFRA_FAILURE") status="INFRA_FAILURE")

@ -68,11 +68,12 @@ def GenTests(api):
['--skip_canned', 'CheckOwners']) + ['--skip_canned', 'CheckOwners']) +
api.post_process(post_process.DropExpectation)) api.post_process(post_process.DropExpectation))
yield ( yield api.test(
api.test('timeout', status="FAILURE") + 'timeout',
api.runtime(is_experimental=False) + api.runtime(is_experimental=False),
api.buildbucket.try_build(project='infra') + api.buildbucket.try_build(project='infra'),
api.presubmit(timeout_s=600) + api.step_data( api.presubmit(timeout_s=600),
api.step_data(
'presubmit', 'presubmit',
api.json.output({ api.json.output({
'errors': [], 'errors': [],
@ -80,16 +81,20 @@ def GenTests(api):
'warnings': [] 'warnings': []
}), }),
times_out_after=1200, times_out_after=1200,
) + api.post_process(post_process.StatusFailure) + api.post_process( ),
post_process.ResultReason, api.post_process(post_process.StatusFailure),
api.post_process(
post_process.SummaryMarkdown,
(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).'
'\n\nTimeout occurred during presubmit step.')) + '\n\nTimeout occurred during presubmit step.')),
api.post_process(post_process.DropExpectation)) api.post_process(post_process.DropExpectation),
status="FAILURE")
yield ( yield api.test(
api.test('failure', status="FAILURE") + 'failure',
api.runtime(is_experimental=False) + api.runtime(is_experimental=False),
api.buildbucket.try_build(project='infra') + api.step_data( api.buildbucket.try_build(project='infra'),
api.step_data(
'presubmit', 'presubmit',
api.json.output( api.json.output(
{ {
@ -117,9 +122,10 @@ def GenTests(api):
'fatal': False 'fatal': False
}] }]
}, },
retcode=1)) + api.post_process(post_process.StatusFailure) + retcode=1)),
api.post_process(post_process.StatusFailure),
api.post_process( api.post_process(
post_process.ResultReason, post_process.SummaryMarkdown,
textwrap.dedent(u''' textwrap.dedent(u'''
#### There are 2 error(s), 1 warning(s), and 1 notifications(s). #### There are 2 error(s), 1 warning(s), and 1 notifications(s).
@ -136,29 +142,34 @@ def GenTests(api):
``` ```
#### 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)) ''').strip()),
api.post_process(post_process.DropExpectation),
status="FAILURE")
long_message = (u'Here are some suggested OWNERS:' + long_message = (u'Here are some suggested OWNERS:' +
u'\nreallyLongFakeAccountNameEmail@chromium.org' * 10) u'\nreallyLongFakeAccountNameEmail@chromium.org' * 10)
yield (api.test('failure-long-message', status="FAILURE") + yield api.test(
api.runtime(is_experimental=False) + 'failure-long-message',
api.buildbucket.try_build(project='infra') + api.step_data( api.runtime(is_experimental=False),
'presubmit', api.buildbucket.try_build(project='infra'),
api.json.output( api.step_data(
{ 'presubmit',
'errors': [{ api.json.output(
'message': 'Missing LGTM', {
'long_text': long_message, 'errors': [{
'items': [], 'message': 'Missing LGTM',
'fatal': True 'long_text': long_message,
}], 'items': [],
'notifications': [], 'fatal': True
'warnings': [] }],
}, 'notifications': [],
retcode=1)) + api.post_process(post_process.StatusFailure) + 'warnings': []
api.post_process( },
post_process.ResultReason, retcode=1)),
textwrap.dedent(''' api.post_process(post_process.StatusFailure),
api.post_process(
post_process.SummaryMarkdown,
textwrap.dedent('''
#### There are 1 error(s), 0 warning(s), and 0 notifications(s). #### There are 1 error(s), 0 warning(s), and 0 notifications(s).
**ERROR** **ERROR**
@ -178,52 +189,63 @@ def GenTests(api):
**Error size > 450 chars, there are 2 more error(s) (15 total)** **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.** **The complete output can be found at the bottom of the presubmit stdout.**
''').strip()) + api.post_process(post_process.DropExpectation)) ''').strip()),
api.post_process(post_process.DropExpectation),
status="FAILURE")
yield (api.test('infra-failure', status="INFRA_FAILURE") + yield api.test(
api.runtime(is_experimental=False) + 'infra-failure',
api.buildbucket.try_build(project='infra') + api.step_data( api.runtime(is_experimental=False),
'presubmit', api.buildbucket.try_build(project='infra'),
api.json.output( api.step_data(
{ 'presubmit',
'errors': [{ api.json.output(
'message': 'Infra Failure', {
'long_text': '', 'errors': [{
'items': [], 'message': 'Infra Failure',
'fatal': True 'long_text': '',
}], 'items': [],
'notifications': [], 'fatal': True
'warnings': [] }],
}, 'notifications': [],
retcode=2)) + api.post_process(post_process.StatusException) + 'warnings': []
api.post_process( },
post_process.ResultReason, retcode=2)),
textwrap.dedent(u''' api.post_process(post_process.StatusException),
#### There are 1 error(s), 0 warning(s), and 0 notifications(s). api.post_process(
post_process.SummaryMarkdown,
**ERROR** textwrap.dedent(u'''
``` #### There are 1 error(s), 0 warning(s), and 0 notifications(s).
Infra Failure
**ERROR**
``` ```
''').strip()) + api.post_process(post_process.DropExpectation)) Infra Failure
```
''').strip()),
api.post_process(post_process.DropExpectation),
status="INFRA_FAILURE")
bug_msg = ('Something unexpected occurred' bug_msg = ('Something unexpected occurred'
' while running presubmit checks.' ' while running presubmit checks.'
' Please [file a bug](https://issues.chromium.org' ' Please [file a bug](https://issues.chromium.org'
'/issues/new?component=1456211)') '/issues/new?component=1456211)')
yield (api.test('failure-no-json', status="INFRA_FAILURE") + yield api.test(
api.runtime(is_experimental=False) + 'failure-no-json',
api.buildbucket.try_build(project='infra') + api.runtime(is_experimental=False),
api.step_data('presubmit', api.json.output(None, retcode=1)) + api.buildbucket.try_build(project='infra'),
api.post_process(post_process.StatusException) + api.step_data('presubmit', api.json.output(None, retcode=1)),
api.post_process(post_process.ResultReason, bug_msg) + api.post_process(post_process.StatusException),
api.post_process(post_process.DropExpectation)) api.post_process(post_process.SummaryMarkdown, bug_msg),
api.post_process(post_process.DropExpectation),
status="INFRA_FAILURE")
yield (api.test('infra-failure-no-json', status="INFRA_FAILURE") + yield api.test(
api.runtime(is_experimental=False) + 'infra-failure-no-json',
api.buildbucket.try_build(project='infra') + api.runtime(is_experimental=False),
api.step_data('presubmit', api.json.output(None, retcode=2)) + api.buildbucket.try_build(project='infra'),
api.post_process(post_process.StatusException) + api.step_data('presubmit', api.json.output(None, retcode=2)),
api.post_process(post_process.ResultReason, bug_msg) + api.post_process(post_process.StatusException),
api.post_process(post_process.DropExpectation)) api.post_process(post_process.SummaryMarkdown, bug_msg),
api.post_process(post_process.DropExpectation),
status="INFRA_FAILURE")

Loading…
Cancel
Save