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

Unified Diff: scripts/slave/recipe_modules/json/example.py

Issue 1347263002: Revert of Cross-repo recipe package system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 5 years, 3 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: scripts/slave/recipe_modules/json/example.py
diff --git a/scripts/slave/recipe_modules/json/example.py b/scripts/slave/recipe_modules/json/example.py
new file mode 100644
index 0000000000000000000000000000000000000000..888158d4ba203c2da047d241a2e9b4e50c8df325
--- /dev/null
+++ b/scripts/slave/recipe_modules/json/example.py
@@ -0,0 +1,49 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+DEPS = [
+ 'json',
+ 'python',
+ 'step',
+]
+
+
+def RunSteps(api):
+ step_result = api.step('echo1', ['echo', '[1, 2, 3]'],
+ stdout=api.json.output())
+ assert step_result.stdout == [1, 2, 3]
+
+ # Example demonstrating the usage of step_test_data for json stdout.
+ step_result = api.step('echo2', ['echo', '[2, 3, 4]'],
+ step_test_data=lambda: api.json.test_api.output_stream([2, 3, 4]),
+ stdout=api.json.output())
+ assert step_result.stdout == [2, 3, 4]
+
+ assert api.json.is_serializable('foo')
+ assert not api.json.is_serializable(set(['foo', 'bar', 'baz']))
+
+ # Example demonstrating multiple json output files.
+ result = api.python.inline(
+ 'foo',
+ """
+ import json
+ import sys
+ with open(sys.argv[1], 'w') as f:
+ f.write(json.dumps([1, 2, 3]))
+ with open(sys.argv[2], 'w') as f:
+ f.write(json.dumps([2, 3, 4]))
+ """,
+ args=[api.json.output(), api.json.output()],
+ )
+ assert result.json.output_all == [[1, 2, 3], [2, 3, 4]]
+
+
+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]) +
+ api.json.output([2, 3, 4]),
+ ))
« no previous file with comments | « scripts/slave/recipe_modules/json/api.py ('k') | scripts/slave/recipe_modules/json/example.expected/basic.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698