Index: scripts/slave/recipe_modules/raw_io/api.py |
diff --git a/scripts/slave/recipe_modules/raw_io/api.py b/scripts/slave/recipe_modules/raw_io/api.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3e8553649665b684846bc6b63cc0adfdcc97ee5f |
--- /dev/null |
+++ b/scripts/slave/recipe_modules/raw_io/api.py |
@@ -0,0 +1,33 @@ |
+from slave import recipe_api |
+from slave import recipe_util |
+ |
+import os |
+import tempfile |
+ |
+class InputDataPlaceholder(recipe_util.Placeholder): |
+ def __init__(self, data, suffix, mod_name): |
+ assert isinstance(data, basestring) |
+ self.data = data |
+ self.suffix = suffix |
+ self.input_file = None |
+ super(InputDataPlaceholder, self).__init__('input', mod_name) |
+ |
+ def render(self, test): |
+ if test.enabled: |
+ # cheat and pretend like we're going to pass the data on the |
+ # cmdline for test expectation purposes. |
+ return [self.data] |
+ else: # pragma: no cover |
+ input_fd, self.input_file = tempfile.mkstemp(suffix=self.suffix) |
+ os.write(input_fd, self.data) |
+ os.close(input_fd) |
+ return [self.input_file] |
+ |
+ def result(self, presentation, test): |
+ if not test.enabled: # pragma: no cover |
+ os.unlink(self.input_file) |
+ |
+ |
+class RawApi(recipe_api.RecipeApi): |
agable
2013/09/23 22:57:58
a) This class name should match the file name.
b)
iannucci
2013/09/24 02:18:51
a) yes. Done.
b) implemented output, made json.out
|
+ def input(self, data, suffix, mod_name=None): |
+ return InputDataPlaceholder(data, suffix, mod_name or self.name) |