| # Copyright 2020 The Fuchsia 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 = [ |
| 'fuchsia/utils', |
| 'fuchsia/status_check', |
| 'recipe_engine/step', |
| ] |
| |
| |
| def RunSteps(api): |
| unique_call_count = {'count': 0} |
| |
| @api.utils.memoize |
| def sleep(seconds, add_one=False): |
| unique_call_count['count'] += 1 |
| if add_one: |
| seconds += 1 |
| api.step('sleep %d seconds' % seconds, ['sleep', str(seconds)]) |
| return seconds |
| |
| assert sleep(5) == 5 |
| assert unique_call_count['count'] == 1 |
| assert sleep(5) == 5 |
| assert unique_call_count['count'] == 1 |
| |
| # Cached inputs should be keyed by both args and kwargs. |
| assert sleep(5, add_one=True) == 6 |
| assert unique_call_count['count'] == 2 |
| assert sleep(5, add_one=True) == 6 |
| assert unique_call_count['count'] == 2 |
| |
| |
| def GenTests(api): |
| yield api.status_check.test('basic') |