| Index: recipe_modules/raw_io/example.py
|
| diff --git a/recipe_modules/raw_io/example.py b/recipe_modules/raw_io/example.py
|
| index 3bcbc44498a110f5e986981ab462c871fccdd222..ba8bb6d83ada6bdd4a6b94dd75250f9a8e599f94 100644
|
| --- a/recipe_modules/raw_io/example.py
|
| +++ b/recipe_modules/raw_io/example.py
|
| @@ -4,6 +4,8 @@
|
|
|
| DEPS = [
|
| 'path',
|
| + 'properties',
|
| + 'python',
|
| 'raw_io',
|
| 'step',
|
| ]
|
| @@ -56,11 +58,37 @@ def RunSteps(api):
|
| api.step('leak dir', ['ls', api.raw_io.output_dir(
|
| leak_to=api.path['slave_build'].join('out'))])
|
|
|
| + # Example of overriding default mocked output for a single named output.
|
| + step_result = api.python.inline(
|
| + 'override_default_mock',
|
| + """
|
| + import sys
|
| + with open(sys.argv[1], 'w') as f:
|
| + f.write(%r)
|
| + """ % api.properties.get('some_prop', 'good_value'),
|
| + args=[api.raw_io.output(name='test')],
|
| + step_test_data=(
|
| + lambda: api.raw_io.test_api.output('second_bad_value', name='test')))
|
| + assert step_result.raw_io.outputs['test'] == 'good_value'
|
| + assert step_result.raw_io.output == 'good_value'
|
| +
|
|
|
| def GenTests(api):
|
| + # This test shows that you can override a specific placeholder, even with
|
| + # default `step_test_data`. However, since this recipe is ACTUALLY run in
|
| + # the presubmit, we need to do a trick with properties:
|
| + # When run for real, "some_prop" will be "good_value" and pass.
|
| + # When run for simulation, we override this property to provide a bad value,
|
| + # AND the default step_test_data in RunSteps above ALSO provides another
|
| + # bad value, the simulation passes ONLY because of the
|
| + # 'override_default_mock' below.
|
| yield (api.test('basic') +
|
| + api.properties(some_prop='bad_value') +
|
| api.step_data('echo',
|
| stdout=api.raw_io.output('Hello World\n'),
|
| stderr=api.raw_io.output('')) +
|
| api.step_data('cat',
|
| - stdout=api.raw_io.output('hello')))
|
| + stdout=api.raw_io.output('hello')) +
|
| + api.step_data('override_default_mock',
|
| + api.raw_io.output('good_value', name='test'))
|
| + )
|
|
|