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

Unified Diff: recipe_modules/json/example.py

Issue 2750793002: [json] improve output to get leak_to and better logging. (Closed)
Patch Set: 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
Index: recipe_modules/json/example.py
diff --git a/recipe_modules/json/example.py b/recipe_modules/json/example.py
index 31f6bee0ac0c180a27cbddda627fbcf226498cce..4905d141a175b9ee1afa5ecffc75f179af7dcefb 100644
--- a/recipe_modules/json/example.py
+++ b/recipe_modules/json/example.py
@@ -62,12 +62,34 @@ 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', 'cool_script.py',
+ api.json.output(leak_to=api.path['tmp_base'].join('leak.json')),
+ ])
+ assert step_result.json.output == example_dict
+
+ # invalid data gets rendered
+ api.step('invalid json', [
+ 'python', 'garbage.py', api.json.output(),
+ ])
+
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'),
+ )
+ )

Powered by Google App Engine
This is Rietveld 408576698