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

Side by Side Diff: build/android/pylib/utils/test_options_parser.py

Issue 13989007: [Android] Split uiautomator test runner from instrumentation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 (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 """Parses options for the instrumentation tests.""" 5 """Parses options for the instrumentation tests."""
6 6
7 #TODO(craigdh): pylib/utils/ should not depend on pylib/. 7 #TODO(craigdh): pylib/utils/ should not depend on pylib/.
8 from pylib import constants 8 from pylib import constants
9 9
10 import optparse 10 import optparse
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 help='If set, use the exe test runner instead of ' 127 help='If set, use the exe test runner instead of '
128 'the APK.') 128 'the APK.')
129 option_parser.add_option('--abi', default='armeabi-v7a', 129 option_parser.add_option('--abi', default='armeabi-v7a',
130 help='Platform of emulators to launch.') 130 help='Platform of emulators to launch.')
131 131
132 132
133 def AddCommonInstrumentationOptions(option_parser): 133 def AddCommonInstrumentationOptions(option_parser):
134 """Decorates OptionParser with base instrumentation tests options.""" 134 """Decorates OptionParser with base instrumentation tests options."""
135 135
136 AddTestRunnerOptions(option_parser) 136 AddTestRunnerOptions(option_parser)
137 option_parser.add_option('-w', '--wait_debugger', dest='wait_for_debugger',
138 action='store_true', help='Wait for debugger.')
139 option_parser.add_option('-f', '--test_filter', 137 option_parser.add_option('-f', '--test_filter',
140 help='Test filter (if not fully qualified, ' 138 help='Test filter (if not fully qualified, '
141 'will run all matches).') 139 'will run all matches).')
142 option_parser.add_option('-A', '--annotation', dest='annotation_str', 140 option_parser.add_option(
143 help=('Run only tests with any of the given ' 141 '-A', '--annotation', dest='annotation_str',
144 'annotations. ' 142 help=('Comma-separated list of annotations. Run only tests with any of '
145 'An annotation can be either a key or a ' 143 'the given annotations. An annotation can be either a key or a '
146 'key-values pair. ' 144 'key-values pair. A test that has no annotation is considered '
147 'A test that has no annotation is ' 145 '"SmallTest".'))
148 'considered "SmallTest".'))
149 option_parser.add_option('-j', '--java_only', action='store_true', 146 option_parser.add_option('-j', '--java_only', action='store_true',
150 help='Run only the Java tests.') 147 help='Run only the Java tests.')
151 option_parser.add_option('-p', '--python_only', action='store_true', 148 option_parser.add_option('-p', '--python_only', action='store_true',
152 help='Run only the Python tests.') 149 help='Run only the Python tests.')
153 option_parser.add_option('-n', '--run_count', type='int',
154 dest='number_of_runs', default=1,
155 help=('How many times to run each test, regardless '
156 'of the result. (Default is 1)'))
157 option_parser.add_option('--screenshot', dest='screenshot_failures', 150 option_parser.add_option('--screenshot', dest='screenshot_failures',
158 action='store_true', 151 action='store_true',
159 help='Capture screenshots of test failures') 152 help='Capture screenshots of test failures')
160 option_parser.add_option('--save-perf-json', action='store_true', 153 option_parser.add_option('--save-perf-json', action='store_true',
161 help='Saves the JSON file for each UI Perf test.') 154 help='Saves the JSON file for each UI Perf test.')
162 option_parser.add_option('--shard_retries', type=int, default=1, 155 option_parser.add_option('--shard_retries', type=int, default=1,
163 help=('Number of times to retry each failure when ' 156 help=('Number of times to retry each failure when '
164 'sharding.')) 157 'sharding.'))
165 option_parser.add_option('--official-build', help='Run official build tests.') 158 option_parser.add_option('--official-build', help='Run official build tests.')
166 option_parser.add_option('--device', 159 option_parser.add_option('--device',
(...skipping 20 matching lines...) Expand all
187 'should be of the form <target>:<source>, ' 180 'should be of the form <target>:<source>, '
188 '<target> is relative to the device data' 181 '<target> is relative to the device data'
189 'directory, and <source> is relative to the ' 182 'directory, and <source> is relative to the '
190 'chromium build directory.')) 183 'chromium build directory.'))
191 184
192 185
193 def AddInstrumentationOptions(option_parser): 186 def AddInstrumentationOptions(option_parser):
194 """Decorates OptionParser with instrumentation tests options.""" 187 """Decorates OptionParser with instrumentation tests options."""
195 188
196 AddCommonInstrumentationOptions(option_parser) 189 AddCommonInstrumentationOptions(option_parser)
190 option_parser.add_option('-w', '--wait_debugger', dest='wait_for_debugger',
191 action='store_true', help='Wait for debugger.')
197 option_parser.add_option('-I', dest='install_apk', 192 option_parser.add_option('-I', dest='install_apk',
198 help='Install APK.', action='store_true') 193 help='Install APK.', action='store_true')
199 option_parser.add_option( 194 option_parser.add_option(
200 '--test-apk', dest='test_apk', 195 '--test-apk', dest='test_apk',
201 help=('The name of the apk containing the tests (without the .apk ' 196 help=('The name of the apk containing the tests (without the .apk '
202 'extension; e.g. "ContentShellTest"). Alternatively, this can ' 197 'extension; e.g. "ContentShellTest"). Alternatively, this can '
203 'be a full path to the apk.')) 198 'be a full path to the apk.'))
204 199
205 200
206 def AddUIAutomatorOptions(option_parser): 201 def AddUIAutomatorOptions(option_parser):
(...skipping 20 matching lines...) Expand all
227 option_parser.error('Options java_only (-j) and python_only (-p) ' 222 option_parser.error('Options java_only (-j) and python_only (-p) '
228 'are mutually exclusive.') 223 'are mutually exclusive.')
229 options.run_java_tests = True 224 options.run_java_tests = True
230 options.run_python_tests = True 225 options.run_python_tests = True
231 if options.java_only: 226 if options.java_only:
232 options.run_python_tests = False 227 options.run_python_tests = False
233 elif options.python_only: 228 elif options.python_only:
234 options.run_java_tests = False 229 options.run_java_tests = False
235 230
236 if options.annotation_str: 231 if options.annotation_str:
237 options.annotation = options.annotation_str.split() 232 options.annotations = options.annotation_str.split(',')
238 elif options.test_filter: 233 elif options.test_filter:
239 options.annotation = [] 234 options.annotations = []
240 else: 235 else:
241 options.annotation = ['Smoke', 'SmallTest', 'MediumTest', 'LargeTest'] 236 options.annotations = ['Smoke', 'SmallTest', 'MediumTest', 'LargeTest']
242 237
243 238
244 def ValidateInstrumentationOptions(option_parser, options, args): 239 def ValidateInstrumentationOptions(option_parser, options, args):
245 """Validate options/arguments and populate options with defaults.""" 240 """Validate options/arguments and populate options with defaults."""
246 ValidateCommonInstrumentationOptions(option_parser, options, args) 241 ValidateCommonInstrumentationOptions(option_parser, options, args)
247 242
248 if not options.test_apk: 243 if not options.test_apk:
249 option_parser.error('--test-apk must be specified.') 244 option_parser.error('--test-apk must be specified.')
250 245
251 if os.path.exists(options.test_apk): 246 if os.path.exists(options.test_apk):
(...skipping 25 matching lines...) Expand all
277 # The dexed JAR is fully qualified, assume the info JAR lives along side. 272 # The dexed JAR is fully qualified, assume the info JAR lives along side.
278 options.uiautomator_jar = options.test_jar 273 options.uiautomator_jar = options.test_jar
279 else: 274 else:
280 options.uiautomator_jar = os.path.join( 275 options.uiautomator_jar = os.path.join(
281 _SDK_OUT_DIR, options.build_type, constants.SDK_BUILD_JAVALIB_DIR, 276 _SDK_OUT_DIR, options.build_type, constants.SDK_BUILD_JAVALIB_DIR,
282 '%s.dex.jar' % options.test_jar) 277 '%s.dex.jar' % options.test_jar)
283 options.uiautomator_info_jar = ( 278 options.uiautomator_info_jar = (
284 options.uiautomator_jar[:options.uiautomator_jar.find('.dex.jar')] + 279 options.uiautomator_jar[:options.uiautomator_jar.find('.dex.jar')] +
285 '_java.jar') 280 '_java.jar')
286 281
OLDNEW
« no previous file with comments | « build/android/pylib/uiautomator/test_runner.py ('k') | build/android/run_instrumentation_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698