OLD | NEW |
| (Empty) |
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 | |
3 # found in the LICENSE file. | |
4 | |
5 DEPS = [ | |
6 'json', | |
7 'python', | |
8 'step', | |
9 ] | |
10 | |
11 | |
12 def RunSteps(api): | |
13 step_result = api.step('echo1', ['echo', '[1, 2, 3]'], | |
14 stdout=api.json.output()) | |
15 assert step_result.stdout == [1, 2, 3] | |
16 | |
17 # Example demonstrating the usage of step_test_data for json stdout. | |
18 step_result = api.step('echo2', ['echo', '[2, 3, 4]'], | |
19 step_test_data=lambda: api.json.test_api.output_stream([2, 3, 4]), | |
20 stdout=api.json.output()) | |
21 assert step_result.stdout == [2, 3, 4] | |
22 | |
23 assert api.json.is_serializable('foo') | |
24 assert not api.json.is_serializable(set(['foo', 'bar', 'baz'])) | |
25 | |
26 # Example demonstrating multiple json output files. | |
27 result = api.python.inline( | |
28 'foo', | |
29 """ | |
30 import json | |
31 import sys | |
32 with open(sys.argv[1], 'w') as f: | |
33 f.write(json.dumps([1, 2, 3])) | |
34 with open(sys.argv[2], 'w') as f: | |
35 f.write(json.dumps([2, 3, 4])) | |
36 """, | |
37 args=[api.json.output(), api.json.output()], | |
38 ) | |
39 assert result.json.output_all == [[1, 2, 3], [2, 3, 4]] | |
40 | |
41 | |
42 def GenTests(api): | |
43 yield (api.test('basic') + | |
44 api.step_data('echo1', stdout=api.json.output([1, 2, 3])) + | |
45 api.step_data( | |
46 'foo', | |
47 api.json.output([1, 2, 3]) + | |
48 api.json.output([2, 3, 4]), | |
49 )) | |
OLD | NEW |