• 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/properties',
10  'recipe_engine/step',
11  'run',
12  'vars',
13]
14
15
16def myfunc(api, i):
17  api.run(api.step, 'run %d' % i, cmd=['echo', str(i)])
18
19
20def RunSteps(api):
21  api.vars.setup()
22  try:
23    api.run(api.step, 'fail', cmd=['false'])
24  except api.step.StepFailure:
25    pass
26  api.run(api.step, 'fail again', cmd=['false'], abort_on_failure=False)
27  api.run(api.step, 'do a thing', cmd=['echo', 'do the thing'])
28  assert len(api.run.failed_steps) == 2
29
30  # Run once.
31  for i in range(10):
32    api.run.run_once(myfunc, api, i)
33
34  # Read and write files.
35  api.run.readfile('myfile.txt')
36  api.run.writefile('myfile.txt', 'contents')
37  api.run.rmtree('mydir')
38
39  # Merge PATHs.
40  with api.context(env={'PATH': 'mydir:%(PATH)s'}):
41    api.run(api.step, 'env', cmd=['env'])
42
43  # Copy build products.
44  api.run.copy_build_products('src', 'dst')
45
46  # Retries.
47  try:
48    api.run.with_retry(api.step, 'retry fail', 5, cmd=['false'])
49  except api.step.StepFailure:
50    pass
51  api.run.with_retry(api.step, 'retry success', 3, cmd=['false'])
52
53  # Check failure.
54  api.run.check_failure()
55
56
57def GenTests(api):
58  buildername = 'Build-Win-MSVC-x86_64-Release-Vulkan'
59  yield (
60      api.test('test') +
61      api.properties(buildername=buildername,
62                     repository='https://skia.googlesource.com/skia.git',
63                     revision='abc123',
64                     path_config='kitchen',
65                     swarm_out_dir='[SWARM_OUT_DIR]') +
66      api.step_data('fail', retcode=1) +
67      api.step_data('fail again', retcode=1) +
68      api.step_data('retry fail', retcode=1) +
69      api.step_data('retry fail (attempt 2)', retcode=1) +
70      api.step_data('retry fail (attempt 3)', retcode=1) +
71      api.step_data('retry fail (attempt 4)', retcode=1) +
72      api.step_data('retry fail (attempt 5)', retcode=1) +
73      api.step_data('retry success', retcode=1) +
74      api.step_data('retry success (attempt 2)', retcode=1)
75    )
76