
from recipe_engine import post_process

DEPS = ['gclient']

def RunSteps(api):
  src_cfg = api.gclient.make_config(CACHE_DIR='[ROOT]/git_cache')
  api.gclient.sync(src_cfg)

def GenTests(api):
  yield api.test(
      'no-json',
      api.override_step_data('gclient sync', retcode=1),
      api.post_check(
          lambda check, steps:
          check(not steps['$result']['failure']['humanReason']
                .startswith('Uncaught Exception'))),
      api.post_process(post_process.DropExpectation)
  )


from recipe_engine import post_process

DEPS = ['gclient']

def RunSteps(api):
  src_cfg = api.gclient.make_config(CACHE_DIR='[ROOT]/git_cache')
  api.gclient.sync(src_cfg)

def GenTests(api):
  yield api.test(
      'no-json',
      api.override_step_data('gclient sync', retcode=1),
      # Should not fail with uncaught exception
      api.post_process(post_process.ResultReasonRE, r'^(?!Uncaught Exception)'),
      api.post_process(post_process.DropExpectation)
  )

Replace customzied test failure assertion with ResultReasonRE from engine
Replace customzied test failure assertion with ResultReasonRE from engine

This change is to facilitate the annotation protocol -> luciexe protocol
migration in the future. The failure response structure will be changed
after the migration. Therefore, we only need to change the
implementation detail of ResultReasonRE at that time.

R=iannucci

Change-Id: If5e0005dddcaf6ccdfbcb047e3855763cf4eadc5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2146066
Auto-Submit: Yiwei Zhang <50b2a565e2e78c292794832469a30ce5abc9959c@google.com>
Reviewed-by: Robbie Iannucci <40f3d43a28ebae3cb819288542e1c84d73d962d5@chromium.org>
Commit-Queue: Robbie Iannucci <40f3d43a28ebae3cb819288542e1c84d73d962d5@chromium.org>

  
  from recipe_engine import post_process
  
  DEPS = ['gclient']
  
  def RunSteps(api):
    src_cfg = api.gclient.make_config(CACHE_DIR='[ROOT]/git_cache')
    api.gclient.sync(src_cfg)
  
  def GenTests(api):
    yield api.test(
        'no-json',
        api.override_step_data('gclient sync', retcode=1),
+       # Should not fail with uncaught exception
+       api.post_process(post_process.ResultReasonRE, r'^(?!Uncaught Exception)'),
-       api.post_check(
-           lambda check, steps:
-           check(not steps['$result']['failure']['humanReason']
-                 .startswith('Uncaught Exception'))),
        api.post_process(post_process.DropExpectation)
    )
  
Replace customzied test failure assertion with ResultReasonRE from engine
## Code Before:

from recipe_engine import post_process

DEPS = ['gclient']

def RunSteps(api):
  src_cfg = api.gclient.make_config(CACHE_DIR='[ROOT]/git_cache')
  api.gclient.sync(src_cfg)

def GenTests(api):
  yield api.test(
      'no-json',
      api.override_step_data('gclient sync', retcode=1),
      api.post_check(
          lambda check, steps:
          check(not steps['$result']['failure']['humanReason']
                .startswith('Uncaught Exception'))),
      api.post_process(post_process.DropExpectation)
  )

## Instruction:
Replace customzied test failure assertion with ResultReasonRE from engine
## Code After:

from recipe_engine import post_process

DEPS = ['gclient']

def RunSteps(api):
  src_cfg = api.gclient.make_config(CACHE_DIR='[ROOT]/git_cache')
  api.gclient.sync(src_cfg)

def GenTests(api):
  yield api.test(
      'no-json',
      api.override_step_data('gclient sync', retcode=1),
      # Should not fail with uncaught exception
      api.post_process(post_process.ResultReasonRE, r'^(?!Uncaught Exception)'),
      api.post_process(post_process.DropExpectation)
  )
