| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 import json | 5 import json |
| 6 | 6 |
| 7 from recipe_engine import recipe_test_api | 7 from recipe_engine import recipe_test_api |
| 8 | 8 |
| 9 class JsonTestApi(recipe_test_api.RecipeTestApi): | 9 class JsonTestApi(recipe_test_api.RecipeTestApi): |
| 10 @recipe_test_api.placeholder_step_data | 10 @recipe_test_api.placeholder_step_data |
| 11 @staticmethod | 11 @staticmethod |
| 12 def output(data, retcode=None): | 12 def output(data, retcode=None, name=None): |
| 13 return json.dumps(data), retcode | 13 return json.dumps(data), retcode, name |
| 14 | 14 |
| 15 def output_stream(self, data, stream='stdout', retcode=None): | 15 def output_stream(self, data, stream='stdout', retcode=None, name=None): |
| 16 assert stream in ('stdout', 'stderr') | 16 assert stream in ('stdout', 'stderr') |
| 17 ret = recipe_test_api.StepTestData() | 17 ret = recipe_test_api.StepTestData() |
| 18 setattr(ret, stream, self.output(data, retcode).unwrap_output_placeholder()) | 18 step_data = self.output(data, retcode=retcode, name=name) |
| 19 setattr(ret, stream, step_data.unwrap_output_placeholder()) |
| 19 return ret | 20 return ret |
| OLD | NEW |