| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from slave import recipe_api | 5 from slave import recipe_api |
| 6 | 6 |
| 7 class GeneratorScriptApi(recipe_api.RecipeApi): | 7 class GeneratorScriptApi(recipe_api.RecipeApi): |
| 8 def __call__(self, path_to_script, *args): # pragma: no cover | 8 def __call__(self, path_to_script, *args): # pragma: no cover |
| 9 """Run a script and generate the steps emitted by that script.""" | 9 """Run a script and generate the steps emitted by that script.""" |
| 10 f = '--output-json' |
| 10 step_name = 'gen step(%s)' % self.m.path.basename(path_to_script) | 11 step_name = 'gen step(%s)' % self.m.path.basename(path_to_script) |
| 11 if path_to_script.endswith('.py'): | 12 if path_to_script.endswith('.py'): |
| 12 yield self.m.python( | 13 yield self.m.python( |
| 13 step_name, | 14 step_name, |
| 14 path_to_script, list(args) + [self.m.json.output()], | 15 path_to_script, list(args) + [f, self.m.json.output()], |
| 15 cwd=self.m.path.checkout()) | 16 cwd=self.m.path.checkout()) |
| 16 else: | 17 else: |
| 17 yield self.m.step( | 18 yield self.m.step( |
| 18 step_name, | 19 step_name, |
| 19 [path_to_script,] + list(args) + [self.m.json.output()], | 20 [path_to_script,] + list(args) + [f, self.m.json.output()], |
| 20 cwd=self.m.path.checkout()) | 21 cwd=self.m.path.checkout()) |
| 21 new_steps = self.m.step_history.last_step().json.output | 22 new_steps = self.m.step_history.last_step().json.output |
| 22 assert isinstance(new_steps, list) | 23 assert isinstance(new_steps, list) |
| 23 yield new_steps | 24 yield new_steps |
| OLD | NEW |