Jelajahi Sumber

[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>
Rob Mohr 1 tahun lalu
induk
melakukan
2377dbfdbc

+ 9 - 6
recipes/recipe_modules/bot_update/examples/full.py

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

+ 2 - 1
recipes/recipe_modules/gclient/tests/sync_failure.py

@@ -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")

+ 99 - 77
recipes/recipe_modules/presubmit/tests/execute.py

@@ -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 (
-      api.test('timeout', status="FAILURE") +
-      api.runtime(is_experimental=False) +
-      api.buildbucket.try_build(project='infra') +
-      api.presubmit(timeout_s=600) + api.step_data(
+  yield api.test(
+      'timeout',
+      api.runtime(is_experimental=False),
+      api.buildbucket.try_build(project='infra'),
+      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.')) +
-      api.post_process(post_process.DropExpectation))
+           '\n\nTimeout occurred during presubmit step.')),
+      api.post_process(post_process.DropExpectation),
+      status="FAILURE")
 
 
-  yield (
-      api.test('failure', status="FAILURE") +
-      api.runtime(is_experimental=False) +
-      api.buildbucket.try_build(project='infra') + api.step_data(
+  yield api.test(
+      'failure',
+      api.runtime(is_experimental=False),
+      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") +
-         api.runtime(is_experimental=False) +
-         api.buildbucket.try_build(project='infra') + api.step_data(
-             'presubmit',
-             api.json.output(
-                 {
-                     'errors': [{
-                         'message': 'Missing LGTM',
-                         'long_text': long_message,
-                         'items': [],
-                         'fatal': True
-                     }],
-                     'notifications': [],
-                     'warnings': []
-                 },
-                 retcode=1)) + api.post_process(post_process.StatusFailure) +
-         api.post_process(
-             post_process.ResultReason,
-             textwrap.dedent('''
+  yield api.test(
+      'failure-long-message',
+      api.runtime(is_experimental=False),
+      api.buildbucket.try_build(project='infra'),
+      api.step_data(
+          'presubmit',
+          api.json.output(
+              {
+                  'errors': [{
+                      'message': 'Missing LGTM',
+                      'long_text': long_message,
+                      'items': [],
+                      'fatal': True
+                  }],
+                  'notifications': [],
+                  'warnings': []
+              },
+              retcode=1)),
+      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") +
-         api.runtime(is_experimental=False) +
-         api.buildbucket.try_build(project='infra') + api.step_data(
-             'presubmit',
-             api.json.output(
-                 {
-                     'errors': [{
-                         'message': 'Infra Failure',
-                         'long_text': '',
-                         'items': [],
-                         'fatal': True
-                     }],
-                     'notifications': [],
-                     'warnings': []
-                 },
-                 retcode=2)) + 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).
-
-        **ERROR**
-        ```
-        Infra Failure
-
-        ```
-        ''').strip()) + api.post_process(post_process.DropExpectation))
+  yield api.test(
+      'infra-failure',
+      api.runtime(is_experimental=False),
+      api.buildbucket.try_build(project='infra'),
+      api.step_data(
+          'presubmit',
+          api.json.output(
+              {
+                  'errors': [{
+                      'message': 'Infra Failure',
+                      'long_text': '',
+                      'items': [],
+                      'fatal': True
+                  }],
+                  'notifications': [],
+                  'warnings': []
+              },
+              retcode=2)),
+      api.post_process(post_process.StatusException),
+      api.post_process(
+          post_process.SummaryMarkdown,
+          textwrap.dedent(u'''
+          #### There are 1 error(s), 0 warning(s), and 0 notifications(s).
+
+          **ERROR**
+          ```
+          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") +
-         api.runtime(is_experimental=False) +
-         api.buildbucket.try_build(project='infra') +
-         api.step_data('presubmit', api.json.output(None, retcode=1)) +
-         api.post_process(post_process.StatusException) +
-         api.post_process(post_process.ResultReason, bug_msg) +
-         api.post_process(post_process.DropExpectation))
+  yield api.test(
+      'failure-no-json',
+      api.runtime(is_experimental=False),
+      api.buildbucket.try_build(project='infra'),
+      api.step_data('presubmit', api.json.output(None, retcode=1)),
+      api.post_process(post_process.StatusException),
+      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") +
-         api.runtime(is_experimental=False) +
-         api.buildbucket.try_build(project='infra') +
-         api.step_data('presubmit', api.json.output(None, retcode=2)) +
-         api.post_process(post_process.StatusException) +
-         api.post_process(post_process.ResultReason, bug_msg) +
-         api.post_process(post_process.DropExpectation))
+  yield api.test(
+      'infra-failure-no-json',
+      api.runtime(is_experimental=False),
+      api.buildbucket.try_build(project='infra'),
+      api.step_data('presubmit', api.json.output(None, retcode=2)),
+      api.post_process(post_process.StatusException),
+      api.post_process(post_process.SummaryMarkdown, bug_msg),
+      api.post_process(post_process.DropExpectation),
+      status="INFRA_FAILURE")