Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Unified Diff: recipe_modules/json/example.py

Issue 2750793002: [json] improve output to get leak_to and better logging. (Closed)
Patch Set: fixit Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « recipe_modules/json/api.py ('k') | recipe_modules/json/example.expected/basic.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_modules/json/example.py
diff --git a/recipe_modules/json/example.py b/recipe_modules/json/example.py
index 31f6bee0ac0c180a27cbddda627fbcf226498cce..5ecc78d6d7aad543025828794f2990d86d2eb689 100644
--- a/recipe_modules/json/example.py
+++ b/recipe_modules/json/example.py
@@ -62,12 +62,38 @@ def RunSteps(api):
step_test_data=lambda: api.json.test_api.output(example_dict))
assert step_result.json.output == example_dict
+ # can leak directly to a file
+ step_result = api.step('leaking json', [
+ 'python', api.resource('cool_script.py'),
+ '{"x":1,"y":2}',
+ api.json.output(leak_to=api.path['tmp_base'].join('leak.json')),
+ ])
+ assert step_result.json.output == example_dict
+
+ # invalid data gets rendered
+ step_result = api.step('invalid json', [
+ 'python', api.resource('cool_script.py'),
+ '{"here is some total\ngarbage',
+ api.json.output(),
+ ])
+ assert step_result.json.output is None
+
def GenTests(api):
- yield (api.test('basic') +
- api.step_data('echo1', stdout=api.json.output([1, 2, 3])) +
- api.step_data(
- 'foo',
- api.json.output([1, 2, 3], name='1') +
- api.json.output(['x', 'y', FULLWIDTH_Z], name='2'),
- ))
+ yield (
+ api.test('basic')
+ + api.step_data('echo1', stdout=api.json.output([1, 2, 3]))
+ + api.step_data(
+ 'foo',
+ api.json.output([1, 2, 3], name='1') +
+ api.json.output(['x', 'y', FULLWIDTH_Z], name='2'),
+ )
+ + api.step_data(
+ 'leaking json',
+ api.json.output({'x': 1, 'y': 2}),
+ )
+ + api.step_data(
+ 'invalid json',
+ api.json.invalid('{"here is some total\ngarbage'),
+ )
+ )
« no previous file with comments | « recipe_modules/json/api.py ('k') | recipe_modules/json/example.expected/basic.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698