# Copyright 2015 The LUCI Authors. All rights reserved. # Use of this source code is governed under the Apache License, Version 2.0 # that can be found in the LICENSE file. from recipe_engine.recipe_api import Property from recipe_engine import config DEPS = [ 'properties', ] # Missing PROPERTIES on purpose RETURN_SCHEMA = config.ReturnSchema(result=config.Single(int), ) def RunSteps(api): return RETURN_SCHEMA(result=0) def GenTests(api): yield (api.test('basic'))
# Copyright 2013 The LUCI Authors. All rights reserved. # Use of this source code is governed under the Apache License, Version 2.0 # that can be found in the LICENSE file. from recipe_engine import recipe_api, config DEPS = [ 'context', 'path', 'properties', 'step', ] RETURN_SCHEMA = config.ReturnSchema(test_me=config.Single(int)) PROPERTIES = { 'bad_return': recipe_api.Property(default=False), 'access_invalid_data': recipe_api.Property(default=False), 'timeout': recipe_api.Property(default=0, kind=int), } def RunSteps(api, bad_return, access_invalid_data, timeout): if bad_return: return RETURN_SCHEMA.new(test_me='this should fail') elif timeout: # Timeout causes the recipe engine to raise an exception if your step takes # longer to run than you allow. Units are seconds. if timeout == 1: api.step('timeout', ['sleep', '20'], timeout=1) elif timeout == 2:
# that can be found in the LICENSE file. from recipe_engine.recipe_api import Property from recipe_engine import config DEPS = [ 'raw_io', 'properties', 'step', ] PROPERTIES = { 'number': Property(kind=int), } RETURN_SCHEMA = config.ReturnSchema(number_times_two=config.Single(int), ) def RunSteps(api, number): # Newline cause bc complains if it doesn't have it num_s = '%s*%s\n' % (number, 2) result = api.step('calc it', ['bc'], stdin=api.raw_io.input(data=num_s), stdout=api.raw_io.output('out')) return RETURN_SCHEMA(number_times_two=int(result.stdout)) def GenTests(api): yield (api.test('basic') + api.properties(number=3) + api.step_data('calc it', stdout=api.raw_io.output('6')))