OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 DEPS = [ | 5 DEPS = [ |
6 'json', | 6 'json', |
7 'path', | 7 'path', |
8 'python', | 8 'python', |
9 'raw_io', | 9 'raw_io', |
10 'step', | 10 'step', |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 example_dict = {'x': 1, 'y': 2} | 46 example_dict = {'x': 1, 'y': 2} |
47 | 47 |
48 # json.input(json_data) expands to a path containing that rendered json | 48 # json.input(json_data) expands to a path containing that rendered json |
49 step_result = api.step('json through', | 49 step_result = api.step('json through', |
50 ['cat', api.json.input(example_dict)], | 50 ['cat', api.json.input(example_dict)], |
51 stdout=api.json.output(), | 51 stdout=api.json.output(), |
52 step_test_data=lambda: api.json.test_api.output_stream(example_dict)) | 52 step_test_data=lambda: api.json.test_api.output_stream(example_dict)) |
53 assert step_result.stdout == example_dict | 53 assert step_result.stdout == example_dict |
54 | 54 |
55 # json.read reads a file containing json data. | 55 # json.read reads a file containing json data. |
56 leak_path = api.path['slave_build'].join('temp.json') | 56 leak_path = api.path['tmp'].join('temp.json') |
57 api.step('write json to file', | 57 api.step('write json to file', |
58 ['cat', api.json.input(example_dict)], | 58 ['cat', api.json.input(example_dict)], |
59 stdout=api.raw_io.output(leak_to=leak_path)) | 59 stdout=api.raw_io.output(leak_to=leak_path)) |
60 step_result = api.json.read( | 60 step_result = api.json.read( |
61 'read json from file we just wrote', leak_path, | 61 'read json from file we just wrote', leak_path, |
62 step_test_data=lambda: api.json.test_api.output(example_dict)) | 62 step_test_data=lambda: api.json.test_api.output(example_dict)) |
63 assert step_result.json.output == example_dict | 63 assert step_result.json.output == example_dict |
64 | 64 |
65 | 65 |
66 def GenTests(api): | 66 def GenTests(api): |
67 yield (api.test('basic') + | 67 yield (api.test('basic') + |
68 api.step_data('echo1', stdout=api.json.output([1, 2, 3])) + | 68 api.step_data('echo1', stdout=api.json.output([1, 2, 3])) + |
69 api.step_data( | 69 api.step_data( |
70 'foo', | 70 'foo', |
71 api.json.output([1, 2, 3], name='1') + | 71 api.json.output([1, 2, 3], name='1') + |
72 api.json.output(['x', 'y', FULLWIDTH_Z], name='2'), | 72 api.json.output(['x', 'y', FULLWIDTH_Z], name='2'), |
73 )) | 73 )) |
OLD | NEW |