• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2017 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5
6DEPS = [
7  'recipe_engine/context',
8  'recipe_engine/path',
9  'recipe_engine/platform',
10  'recipe_engine/properties',
11  'recipe_engine/step',
12  'run',
13  'vars',
14]
15
16
17def myfunc(api, i):
18  api.run(api.step, 'run %d' % i, cmd=['echo', str(i)])
19
20
21def RunSteps(api):
22  api.vars.setup()
23  try:
24    api.run(api.step, 'fail', cmd=['false'])
25  except api.step.StepFailure:
26    pass
27  api.run(api.step, 'fail again', cmd=['false'], abort_on_failure=False)
28  api.run(api.step, 'do a thing', cmd=['echo', 'do the thing'])
29  assert len(api.run.failed_steps) == 2
30
31  # Run once.
32  for i in range(10):
33    api.run.run_once(myfunc, api, i)
34
35  # Read and write files.
36  api.run.readfile('myfile.txt')
37  api.run.writefile('myfile.txt', 'contents')
38  api.run.rmtree('mydir')
39  api.run.asset_version('my_asset', api.vars.cache_dir.join('work', 'skia'))
40
41  # Merge PATHs.
42  with api.context(env={'PATH': 'mydir:%(PATH)s'}):
43    api.run(api.step, 'env', cmd=['env'])
44
45  def between_attempts_fn(attempt):
46    api.run(api.step, 'between_attempts #%d' % attempt,
47            cmd=['echo', 'between_attempt'])
48
49  # Retries.
50  try:
51    api.run.with_retry(api.step, 'retry fail', 5, cmd=['false'],
52                       between_attempts_fn=between_attempts_fn)
53  except api.step.StepFailure:
54    pass
55  assert len(api.run.failed_steps) == 7
56
57  api.run.with_retry(api.step, 'retry success', 3, cmd=['false'],
58                     between_attempts_fn=between_attempts_fn)
59  assert len(api.run.failed_steps) == 7
60
61  # Check failure.
62  api.run.check_failure()
63
64
65def GenTests(api):
66  buildername = 'Build-Win-Clang-x86_64-Release-Vulkan'
67  yield (
68      api.test('test') +
69      api.properties(buildername=buildername,
70                     repository='https://skia.googlesource.com/skia.git',
71                     revision='abc123',
72                     path_config='kitchen',
73                     swarm_out_dir='[SWARM_OUT_DIR]') +
74      api.platform('win', 64) +
75      api.step_data('fail', retcode=1) +
76      api.step_data('fail again', retcode=1) +
77      api.step_data('retry fail', retcode=1) +
78      api.step_data('retry fail (attempt 2)', retcode=1) +
79      api.step_data('retry fail (attempt 3)', retcode=1) +
80      api.step_data('retry fail (attempt 4)', retcode=1) +
81      api.step_data('retry fail (attempt 5)', retcode=1) +
82      api.step_data('retry success', retcode=1) +
83      api.step_data('retry success (attempt 2)', retcode=1)
84    )
85