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

Side by Side Diff: build/android/pylib/constants.py

Issue 711113002: Add option to specify ADB binary in test runner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed nits. Created 6 years, 1 month 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
« no previous file with comments | « build/android/pylib/android_commands.py ('k') | build/android/pylib/device/adb_wrapper.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 """Defines a set of constants shared by test runners and other scripts.""" 5 """Defines a set of constants shared by test runners and other scripts."""
6 # pylint: disable=W0212 6 # pylint: disable=W0212
7 7
8 import collections 8 import collections
9 import logging 9 import logging
10 import os 10 import os
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 def _Memoize(func): 239 def _Memoize(func):
240 def Wrapper(): 240 def Wrapper():
241 try: 241 try:
242 return func._result 242 return func._result
243 except AttributeError: 243 except AttributeError:
244 func._result = func() 244 func._result = func()
245 return func._result 245 return func._result
246 return Wrapper 246 return Wrapper
247 247
248 248
249 def SetAdbPath(adb_path):
250 os.environ['ADB_PATH'] = adb_path
251
252
253 def GetAdbPath():
254 # Check if a custom adb path as been set. If not, try to find adb
255 # on the system.
256 if os.environ.get('ADB_PATH'):
257 return os.environ.get('ADB_PATH')
258 else:
259 return _FindAdbPath()
260
261
249 @_Memoize 262 @_Memoize
250 def GetAdbPath(): 263 def _FindAdbPath():
251 if os.environ.get('ANDROID_SDK_ROOT'): 264 if os.environ.get('ANDROID_SDK_ROOT'):
252 return 'adb' 265 return 'adb'
253 # If envsetup.sh hasn't been sourced and there's no adb in the path, 266 # If envsetup.sh hasn't been sourced and there's no adb in the path,
254 # set it here. 267 # set it here.
255 try: 268 try:
256 with file(os.devnull, 'w') as devnull: 269 with file(os.devnull, 'w') as devnull:
257 subprocess.call(['adb', 'version'], stdout=devnull, stderr=devnull) 270 subprocess.call(['adb', 'version'], stdout=devnull, stderr=devnull)
258 return 'adb' 271 return 'adb'
259 except OSError: 272 except OSError:
260 logging.debug('No adb found in $PATH, fallback to checked in binary.') 273 logging.debug('No adb found in $PATH, fallback to checked in binary.')
261 return os.path.join(ANDROID_SDK_ROOT, 'platform-tools', 'adb') 274 return os.path.join(ANDROID_SDK_ROOT, 'platform-tools', 'adb')
262 275
263
264 # Exit codes 276 # Exit codes
265 ERROR_EXIT_CODE = 1 277 ERROR_EXIT_CODE = 1
266 WARNING_EXIT_CODE = 88 278 WARNING_EXIT_CODE = 88
OLDNEW
« no previous file with comments | « build/android/pylib/android_commands.py ('k') | build/android/pylib/device/adb_wrapper.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698