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

Side by Side Diff: scripts/slave/recipe_modules/bot_update/test_api.py

Issue 288843003: Let bot_update recipe api force usage of bot_update. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Rebase Created 6 years, 7 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
« no previous file with comments | « scripts/slave/recipe_modules/bot_update/example.expected/off.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 hashlib 5 import hashlib
6 import struct 6 import struct
7 7
8 from slave import bot_update 8 from slave import bot_update
9 from slave import recipe_test_api 9 from slave import recipe_test_api
10 10
11 11
12 class BotUpdateTestApi(recipe_test_api.RecipeTestApi): 12 class BotUpdateTestApi(recipe_test_api.RecipeTestApi):
13 def output_json(self, master, builder, slave, root, first_sln, 13 def output_json(self, master, builder, slave, root, first_sln,
14 revision_mapping, git_mode): 14 revision_mapping, git_mode, force=False):
15 """Deterministically synthesize json.output test data for gclient's 15 """Deterministically synthesize json.output test data for gclient's
16 --output-json option. 16 --output-json option.
17 """ 17 """
18 active = bot_update.check_valid_host(master, builder, slave) 18 active = bot_update.check_valid_host(master, builder, slave) or force
19 19
20 output = { 20 output = {
21 'did_run': active 21 'did_run': active
22 } 22 }
23 23
24 # Add in extra json output if active. 24 # Add in extra json output if active.
25 if active: 25 if active:
26 properties = { 26 properties = {
27 property_name: self.gen_revision(project_name, git_mode) 27 property_name: self.gen_revision(project_name, git_mode)
28 for project_name, property_name in revision_mapping.iteritems() 28 for project_name, property_name in revision_mapping.iteritems()
(...skipping 15 matching lines...) Expand all
44 44
45 45
46 @staticmethod 46 @staticmethod
47 def gen_revision(project, GIT_MODE): 47 def gen_revision(project, GIT_MODE):
48 """Hash project to bogus deterministic revision values.""" 48 """Hash project to bogus deterministic revision values."""
49 h = hashlib.sha1(project) 49 h = hashlib.sha1(project)
50 if GIT_MODE: 50 if GIT_MODE:
51 return h.hexdigest() 51 return h.hexdigest()
52 else: 52 else:
53 return struct.unpack('!I', h.digest()[:4])[0] % 300000 53 return struct.unpack('!I', h.digest()[:4])[0] % 300000
OLDNEW
« no previous file with comments | « scripts/slave/recipe_modules/bot_update/example.expected/off.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698