aboutsummaryrefslogtreecommitdiffhomepage
path: root/infra/bots/recipe_modules/run/example.py
diff options
context:
space:
mode:
authorGravatar Eric Boren <borenet@google.com>2017-04-18 15:49:27 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-19 11:24:24 +0000
commite16fb7584a15802949d1eb8b4ad60952619da7d4 (patch)
tree948e2e2d4c9caf2a2994249559f9ba1680d48a97 /infra/bots/recipe_modules/run/example.py
parentc1e9617e82a2d573c890ee17e69a3d4699800f05 (diff)
Recipes: Use strict coverage, part 1
Shouldn't change any behavior. Bug: skia: Change-Id: I953e0da886a6d61096eba7915101f245a6cec741 Reviewed-on: https://skia-review.googlesource.com/13765 Reviewed-by: Ravi Mistry <rmistry@google.com> Commit-Queue: Eric Boren <borenet@google.com>
Diffstat (limited to 'infra/bots/recipe_modules/run/example.py')
-rw-r--r--infra/bots/recipe_modules/run/example.py69
1 files changed, 69 insertions, 0 deletions
diff --git a/infra/bots/recipe_modules/run/example.py b/infra/bots/recipe_modules/run/example.py
new file mode 100644
index 0000000000..fb61b48846
--- /dev/null
+++ b/infra/bots/recipe_modules/run/example.py
@@ -0,0 +1,69 @@
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+DEPS = [
+ 'recipe_engine/path',
+ 'recipe_engine/properties',
+ 'recipe_engine/step',
+ 'run',
+ 'vars',
+]
+
+
+def myfunc(api, i):
+ api.run(api.step, 'run %d' % i, cmd=['echo', str(i)])
+
+
+def RunSteps(api):
+ api.vars.setup()
+ api.run(api.step, 'fail', cmd=['false'], abort_on_failure=False)
+ api.run(api.step, 'do a thing', cmd=['echo', 'do the thing'])
+ assert len(api.run.failed_steps) == 1
+
+ # Run once.
+ for i in range(10):
+ api.run.run_once(myfunc, api, i)
+
+ # Read and write files.
+ api.run.readfile('myfile.txt')
+ api.run.writefile('myfile.txt', 'contents')
+ api.run.rmtree('mydir')
+
+ # Merge PATHs.
+ with api.step.context({'env': {'PATH': 'mydir:%(PATH)s'}}):
+ api.run(api.step, 'env', cmd=['env'])
+
+ # Copy build products.
+ api.run.copy_build_products('src', 'dst')
+
+ # Retries.
+ try:
+ api.run.with_retry(api.step, 'retry fail', 5, cmd=['false'])
+ except api.step.StepFailure:
+ pass
+ api.run.with_retry(api.step, 'retry success', 3, cmd=['false'])
+
+ # Check failure.
+ api.run.check_failure()
+
+
+def GenTests(api):
+ buildername = 'Build-Win-MSVC-x86_64-Release-Vulkan'
+ yield (
+ api.test('test') +
+ api.properties(buildername=buildername,
+ repository='https://skia.googlesource.com/skia.git',
+ revision='abc123',
+ path_config='kitchen',
+ swarm_out_dir='[SWARM_OUT_DIR]') +
+ api.step_data('fail', retcode=1) +
+ api.step_data('retry fail', retcode=1) +
+ api.step_data('retry fail (attempt 2)', retcode=1) +
+ api.step_data('retry fail (attempt 3)', retcode=1) +
+ api.step_data('retry fail (attempt 4)', retcode=1) +
+ api.step_data('retry fail (attempt 5)', retcode=1) +
+ api.step_data('retry success', retcode=1) +
+ api.step_data('retry success (attempt 2)', retcode=1)
+ )