Index: recipe_modules/step/example.py |
diff --git a/recipe_modules/step/example.py b/recipe_modules/step/example.py |
index 2eaf220fbce1a514b0d11bd6814c7994d38a848b..882caab98826411ac88685b998087deab0a9b57f 100644 |
--- a/recipe_modules/step/example.py |
+++ b/recipe_modules/step/example.py |
@@ -3,8 +3,8 @@ |
# found in the LICENSE file. |
DEPS = [ |
- 'properties', |
- 'step', |
+ 'recipe_engine/properties', |
+ 'recipe_engine/step', |
] |
from recipe_engine import recipe_api |
@@ -35,9 +35,17 @@ def RunSteps(api): |
api.step('goodbye', ['echo', 'goodbye']) |
# Modifying step_result now would raise an AssertionError. |
except api.step.StepFailure: |
- # Raising anything besides StepFailure causes the build to go purple. |
+ # Raising anything besides StepFailure or StepWarning causes the build to go |
+ # purple. |
raise ValueError('goodbye must exit 0!') |
+ try: |
+ api.step('warning', ['echo', 'warning']) |
+ except api.step.StepFailure as e: |
+ e.result.presentation.status = api.step.WARNING |
+ raise api.step.StepWarning(e.message) |
+ |
+ |
# Aggregate failures from tests! |
try: |
with recipe_api.defer_results(): |
@@ -56,17 +64,13 @@ def RunSteps(api): |
# Run a step through a made-up wrapper program. |
api.step('application', ['echo', 'main', 'application'], |
- wrapper=['python', 'test-wrapper.py', '-v', '--']) |
+ wrapper=['python', '-c', 'import sys; print sys.argv']) |
if api.properties.get('access_invalid_data'): |
result = api.step('no-op', ['echo', 'I', 'do', 'nothing']) |
# Trying to access non-existent attributes on the result should raise. |
_ = result.json.output |
- # You can also raise a warning, which will act like a step failure, but |
- # will turn the build yellow, and stop the build. |
- raise api.step.StepWarning("Warning, robots approaching!") |
- |
def GenTests(api): |
yield ( |
@@ -94,6 +98,12 @@ def GenTests(api): |
) |
yield ( |
+ api.test('warning') + |
+ api.step_data('warning', retcode=1) + |
+ api.expect_exception('StepWarning') |
+ ) |
+ |
+ yield ( |
api.test('defer_results') + |
api.step_data('testa', retcode=1) |
) |