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

Side by Side Diff: scripts/slave/recipe_api.py

Issue 17635005: Make blink_trybot recipe work on windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 5 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
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import imp 5 import imp
6 import inspect 6 import inspect
7 import os 7 import os
8 import sys 8 import sys
9 9
10 10
11 class Placeholder(object): 11 class Placeholder(object):
12 """Base class for json placeholders. Do not use directly.""" 12 """Base class for json placeholders. Do not use directly."""
13 def render(self, test_data): # pragma: no cover 13 def render(self, test_data): # pragma: no cover
14 """Return [cmd items]*""" 14 """Return [cmd items]*"""
15 raise NotImplementedError 15 raise NotImplementedError
16 16
17 def step_finished(self, stream, step_result, test_data): # pragma: no cover 17 def step_finished(self, stream, step_result, test_data): # pragma: no cover
18 """Called after step completion. Intended to modify step_result.""" 18 """Called after step completion. Intended to modify step_result."""
19 pass 19 pass
20 20
21 21
22 class InputDataPlaceholder(Placeholder):
23 def __init__(self, data, suffix):
24 assert isinstance(data, basestring)
25 self.data = data
26 self.suffix = suffix
27 self.input_file = None
28 super(InputDataPlaceholder, self).__init__()
29
30 def render(self, test_data):
31 if test_data is not None:
32 # cheat and pretend like we're going to pass the data on the
33 # cmdline for test expectation purposes.
34 return [self.data]
35 else: # pragma: no cover
36 input_fd, self.input_file = tempfile.mkstemp(suffix=self.suffix)
37 os.write(input_fd, self.data)
38 os.close(input_fd)
39 return [self.input_file]
40
41 def step_finished(self, stream, step_result, test_data):
42 if test_data is None: # pragma: no cover
43 os.unlink(self.input_file)
44
45
22 class ModuleInjectionSite(object): 46 class ModuleInjectionSite(object):
23 pass 47 pass
24 48
25 49
26 class RecipeApi(object): 50 class RecipeApi(object):
27 """ 51 """
28 Framework class for handling recipe_modules. 52 Framework class for handling recipe_modules.
29 53
30 Inherit from this in your recipe_modules/<name>/api.py . This class provides 54 Inherit from this in your recipe_modules/<name>/api.py . This class provides
31 wiring for your config context (in self.c and methods, and for dependency 55 wiring for your config context (in self.c and methods, and for dependency
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 to_remove.append(dep) 251 to_remove.append(dep)
228 did_something = True 252 did_something = True
229 map(deps.remove, to_remove) 253 map(deps.remove, to_remove)
230 if not deps: 254 if not deps:
231 to_pop.append(api_name) 255 to_pop.append(api_name)
232 did_something = True 256 did_something = True
233 map(dep_map.pop, to_pop) 257 map(dep_map.pop, to_pop)
234 assert did_something, 'Did nothing on this loop. %s' % dep_map 258 assert did_something, 'Did nothing on this loop. %s' % dep_map
235 259
236 return inst_map[None] 260 return inst_map[None]
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698