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

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: 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
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 if force: # pragma: no cover
24 output.update({'force': True})
23 25
24 # Add in extra json output if active. 26 # Add in extra json output if active.
25 if active: 27 if active:
26 properties = { 28 properties = {
27 property_name: self.gen_revision(project_name, git_mode) 29 property_name: self.gen_revision(project_name, git_mode)
28 for project_name, property_name in revision_mapping.iteritems() 30 for project_name, property_name in revision_mapping.iteritems()
29 } 31 }
30 # We also want to simulate outputting "got_revision_git": ... 32 # We also want to simulate outputting "got_revision_git": ...
31 # when git mode is off to match what bot_update.py does. 33 # when git mode is off to match what bot_update.py does.
32 if not git_mode: 34 if not git_mode:
(...skipping 11 matching lines...) Expand all
44 46
45 47
46 @staticmethod 48 @staticmethod
47 def gen_revision(project, GIT_MODE): 49 def gen_revision(project, GIT_MODE):
48 """Hash project to bogus deterministic revision values.""" 50 """Hash project to bogus deterministic revision values."""
49 h = hashlib.sha1(project) 51 h = hashlib.sha1(project)
50 if GIT_MODE: 52 if GIT_MODE:
51 return h.hexdigest() 53 return h.hexdigest()
52 else: 54 else:
53 return struct.unpack('!I', h.digest()[:4])[0] % 300000 55 return struct.unpack('!I', h.digest()[:4])[0] % 300000
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698