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

Side by Side Diff: build/android/test_runner.py

Issue 1416703003: [Android] Add a configurable environment for devil/. (RELAND 2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed Created 5 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/setup.gyp ('k') | build/android/tombstones.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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2013 The Chromium Authors. All rights reserved. 3 # Copyright 2013 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Runs all types of tests from one unified interface.""" 7 """Runs all types of tests from one unified interface."""
8 8
9 import argparse 9 import argparse
10 import collections 10 import collections
11 import itertools 11 import itertools
12 import logging 12 import logging
13 import os 13 import os
14 import signal 14 import signal
15 import sys 15 import sys
16 import threading 16 import threading
17 import unittest 17 import unittest
18 18
19 import devil_chromium
20
19 from devil import base_error 21 from devil import base_error
20 from devil.android import apk_helper 22 from devil.android import apk_helper
21 from devil.android import device_blacklist 23 from devil.android import device_blacklist
22 from devil.android import device_errors 24 from devil.android import device_errors
23 from devil.android import device_utils 25 from devil.android import device_utils
24 from devil.android import ports 26 from devil.android import ports
25 from devil.utils import reraiser_thread 27 from devil.utils import reraiser_thread
26 from devil.utils import run_tests_helper 28 from devil.utils import run_tests_helper
27 29
28 from pylib import constants 30 from pylib import constants
(...skipping 11 matching lines...) Expand all
40 from pylib.junit import test_dispatcher as junit_dispatcher 42 from pylib.junit import test_dispatcher as junit_dispatcher
41 from pylib.monkey import setup as monkey_setup 43 from pylib.monkey import setup as monkey_setup
42 from pylib.monkey import test_options as monkey_test_options 44 from pylib.monkey import test_options as monkey_test_options
43 from pylib.perf import setup as perf_setup 45 from pylib.perf import setup as perf_setup
44 from pylib.perf import test_options as perf_test_options 46 from pylib.perf import test_options as perf_test_options
45 from pylib.perf import test_runner as perf_test_runner 47 from pylib.perf import test_runner as perf_test_runner
46 from pylib.results import json_results 48 from pylib.results import json_results
47 from pylib.results import report_results 49 from pylib.results import report_results
48 50
49 51
52 _DEVIL_STATIC_CONFIG_FILE = os.path.abspath(os.path.join(
53 constants.DIR_SOURCE_ROOT, 'build', 'android', 'devil_config.json'))
54
55
50 def AddCommonOptions(parser): 56 def AddCommonOptions(parser):
51 """Adds all common options to |parser|.""" 57 """Adds all common options to |parser|."""
52 58
53 group = parser.add_argument_group('Common Options') 59 group = parser.add_argument_group('Common Options')
54 60
55 default_build_type = os.environ.get('BUILDTYPE', 'Debug') 61 default_build_type = os.environ.get('BUILDTYPE', 'Debug')
56 62
57 debug_or_release_group = group.add_mutually_exclusive_group() 63 debug_or_release_group = group.add_mutually_exclusive_group()
58 debug_or_release_group.add_argument( 64 debug_or_release_group.add_argument(
59 '--debug', action='store_const', const='Debug', dest='build_type', 65 '--debug', action='store_const', const='Debug', dest='build_type',
60 default=default_build_type, 66 default=default_build_type,
61 help=('If set, run test suites under out/Debug. ' 67 help=('If set, run test suites under out/Debug. '
62 'Default is env var BUILDTYPE or Debug.')) 68 'Default is env var BUILDTYPE or Debug.'))
63 debug_or_release_group.add_argument( 69 debug_or_release_group.add_argument(
64 '--release', action='store_const', const='Release', dest='build_type', 70 '--release', action='store_const', const='Release', dest='build_type',
65 help=('If set, run test suites under out/Release. ' 71 help=('If set, run test suites under out/Release. '
66 'Default is env var BUILDTYPE or Debug.')) 72 'Default is env var BUILDTYPE or Debug.'))
67 73
68 group.add_argument('--build-directory', dest='build_directory', 74 group.add_argument('--build-directory', dest='build_directory',
69 help=('Path to the directory in which build files are' 75 help=('Path to the directory in which build files are'
70 ' located (should not include build type)')) 76 ' located (should not include build type)'))
71 group.add_argument('--output-directory', dest='output_directory', 77 group.add_argument('--output-directory', dest='output_directory',
72 help=('Path to the directory in which build files are' 78 help=('Path to the directory in which build files are'
73 ' located (must include build type). This will take' 79 ' located (must include build type). This will take'
74 ' precedence over --debug, --release and' 80 ' precedence over --debug, --release and'
75 ' --build-directory')) 81 ' --build-directory'))
76 group.add_argument('--num_retries', '--num-retries', dest='num_retries', 82 group.add_argument('--num_retries', '--num-retries', dest='num_retries',
nednguyen 2015/10/28 16:52:32 Duplicate args?
jbudorick 2015/10/28 16:54:24 _ and -
nednguyen 2015/10/28 16:55:22 Ah, didn't know that argparse support this. Really
77 type=int, default=2, 83 type=int, default=2,
78 help=('Number of retries for a test before ' 84 help=('Number of retries for a test before '
79 'giving up (default: %(default)s).')) 85 'giving up (default: %(default)s).'))
80 group.add_argument('-v', 86 group.add_argument('-v',
81 '--verbose', 87 '--verbose',
82 dest='verbose_count', 88 dest='verbose_count',
83 default=0, 89 default=0,
84 action='count', 90 action='count',
85 help='Verbose level (multiple times for more)') 91 help='Verbose level (multiple times for more)')
86 group.add_argument('--flakiness-dashboard-server', 92 group.add_argument('--flakiness-dashboard-server',
(...skipping 16 matching lines...) Expand all
103 'to specified file.') 109 'to specified file.')
104 110
105 def ProcessCommonOptions(args): 111 def ProcessCommonOptions(args):
106 """Processes and handles all common options.""" 112 """Processes and handles all common options."""
107 run_tests_helper.SetLogLevel(args.verbose_count) 113 run_tests_helper.SetLogLevel(args.verbose_count)
108 constants.SetBuildType(args.build_type) 114 constants.SetBuildType(args.build_type)
109 if args.build_directory: 115 if args.build_directory:
110 constants.SetBuildDirectory(args.build_directory) 116 constants.SetBuildDirectory(args.build_directory)
111 if args.output_directory: 117 if args.output_directory:
112 constants.SetOutputDirectory(args.output_directory) 118 constants.SetOutputDirectory(args.output_directory)
119
120 devil_custom_deps = None
113 if args.adb_path: 121 if args.adb_path:
114 constants.SetAdbPath(args.adb_path) 122 devil_custom_deps = {
123 'adb': {
124 'android_host': [args.adb_path]
125 }
126 }
127
128 devil_chromium.Initialize(
129 output_directory=constants.GetOutDirectory(),
130 custom_deps=devil_custom_deps)
131
115 # Some things such as Forwarder require ADB to be in the environment path. 132 # Some things such as Forwarder require ADB to be in the environment path.
116 adb_dir = os.path.dirname(constants.GetAdbPath()) 133 adb_dir = os.path.dirname(constants.GetAdbPath())
117 if adb_dir and adb_dir not in os.environ['PATH'].split(os.pathsep): 134 if adb_dir and adb_dir not in os.environ['PATH'].split(os.pathsep):
118 os.environ['PATH'] = adb_dir + os.pathsep + os.environ['PATH'] 135 os.environ['PATH'] = adb_dir + os.pathsep + os.environ['PATH']
119 136
120 137
121 def AddRemoteDeviceOptions(parser): 138 def AddRemoteDeviceOptions(parser):
122 group = parser.add_argument_group('Remote Device Options') 139 group = parser.add_argument_group('Remote Device Options')
123 140
124 group.add_argument('--trigger', 141 group.add_argument('--trigger',
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 if e.is_infra_error: 1018 if e.is_infra_error:
1002 return constants.INFRA_EXIT_CODE 1019 return constants.INFRA_EXIT_CODE
1003 return constants.ERROR_EXIT_CODE 1020 return constants.ERROR_EXIT_CODE
1004 except: # pylint: disable=W0702 1021 except: # pylint: disable=W0702
1005 logging.exception('Unrecognized error occurred.') 1022 logging.exception('Unrecognized error occurred.')
1006 return constants.ERROR_EXIT_CODE 1023 return constants.ERROR_EXIT_CODE
1007 1024
1008 1025
1009 if __name__ == '__main__': 1026 if __name__ == '__main__':
1010 sys.exit(main()) 1027 sys.exit(main())
OLDNEW
« no previous file with comments | « build/android/setup.gyp ('k') | build/android/tombstones.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698