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

Side by Side Diff: scripts/slave/recipe_modules/raw_io/api.py

Issue 23889036: Refactor the way that TestApi works so that it is actually useful. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: once more... Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 from slave import recipe_api
2 from slave import recipe_util
3
4 import os
5 import tempfile
6
7 class InputDataPlaceholder(recipe_util.Placeholder):
8 def __init__(self, data, suffix, mod_name):
9 assert isinstance(data, basestring)
10 self.data = data
11 self.suffix = suffix
12 self.input_file = None
13 super(InputDataPlaceholder, self).__init__('input', mod_name)
14
15 def render(self, test):
16 if test.enabled:
17 # cheat and pretend like we're going to pass the data on the
18 # cmdline for test expectation purposes.
19 return [self.data]
20 else: # pragma: no cover
21 input_fd, self.input_file = tempfile.mkstemp(suffix=self.suffix)
22 os.write(input_fd, self.data)
23 os.close(input_fd)
24 return [self.input_file]
25
26 def result(self, presentation, test):
27 if not test.enabled: # pragma: no cover
28 os.unlink(self.input_file)
29
30
31 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
32 def input(self, data, suffix, mod_name=None):
33 return InputDataPlaceholder(data, suffix, mod_name or self.name)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698