OLD | NEW |
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 TODO(gkanwar): | 9 TODO(gkanwar): |
10 * Add options to run Monkey tests. | 10 * Add options to run Monkey tests. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 option_parser.add_option('--num_retries', dest='num_retries', type='int', | 61 option_parser.add_option('--num_retries', dest='num_retries', type='int', |
62 default=2, | 62 default=2, |
63 help=('Number of retries for a test before ' | 63 help=('Number of retries for a test before ' |
64 'giving up.')) | 64 'giving up.')) |
65 option_parser.add_option('-v', | 65 option_parser.add_option('-v', |
66 '--verbose', | 66 '--verbose', |
67 dest='verbose_count', | 67 dest='verbose_count', |
68 default=0, | 68 default=0, |
69 action='count', | 69 action='count', |
70 help='Verbose level (multiple times for more)') | 70 help='Verbose level (multiple times for more)') |
71 profilers = ['devicestatsmonitor', 'chrometrace', 'dumpheap', 'smaps', | |
72 'traceview'] | |
73 option_parser.add_option('--profiler', dest='profilers', action='append', | |
74 choices=profilers, | |
75 help=('Profiling tool to run during test. Pass ' | |
76 'multiple times to run multiple profilers. ' | |
77 'Available profilers: %s' % profilers)) | |
78 option_parser.add_option('--tool', | 71 option_parser.add_option('--tool', |
79 dest='tool', | 72 dest='tool', |
80 help=('Run the test under a tool ' | 73 help=('Run the test under a tool ' |
81 '(use --tool help to list them)')) | 74 '(use --tool help to list them)')) |
82 option_parser.add_option('--flakiness-dashboard-server', | 75 option_parser.add_option('--flakiness-dashboard-server', |
83 dest='flakiness_dashboard_server', | 76 dest='flakiness_dashboard_server', |
84 help=('Address of the server that is hosting the ' | 77 help=('Address of the server that is hosting the ' |
85 'Chrome for Android flakiness dashboard.')) | 78 'Chrome for Android flakiness dashboard.')) |
86 option_parser.add_option('--skip-deps-push', dest='push_deps', | 79 option_parser.add_option('--skip-deps-push', dest='push_deps', |
87 action='store_false', default=True, | 80 action='store_false', default=True, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 option_parser.add_option('--save-perf-json', action='store_true', | 158 option_parser.add_option('--save-perf-json', action='store_true', |
166 help='Saves the JSON file for each UI Perf test.') | 159 help='Saves the JSON file for each UI Perf test.') |
167 option_parser.add_option('--official-build', action='store_true', | 160 option_parser.add_option('--official-build', action='store_true', |
168 help='Run official build tests.') | 161 help='Run official build tests.') |
169 option_parser.add_option('--keep_test_server_ports', | 162 option_parser.add_option('--keep_test_server_ports', |
170 action='store_true', | 163 action='store_true', |
171 help=('Indicates the test server ports must be ' | 164 help=('Indicates the test server ports must be ' |
172 'kept. When this is run via a sharder ' | 165 'kept. When this is run via a sharder ' |
173 'the test server ports should be kept and ' | 166 'the test server ports should be kept and ' |
174 'should not be reset.')) | 167 'should not be reset.')) |
175 # TODO(gkanwar): This option is deprecated. Remove it in the future. | |
176 option_parser.add_option('--disable_assertions', action='store_true', | |
177 help=('(DEPRECATED) Run with java assertions ' | |
178 'disabled.')) | |
179 option_parser.add_option('--test_data', action='append', default=[], | 168 option_parser.add_option('--test_data', action='append', default=[], |
180 help=('Each instance defines a directory of test ' | 169 help=('Each instance defines a directory of test ' |
181 'data that should be copied to the target(s) ' | 170 'data that should be copied to the target(s) ' |
182 'before running the tests. The argument ' | 171 'before running the tests. The argument ' |
183 'should be of the form <target>:<source>, ' | 172 'should be of the form <target>:<source>, ' |
184 '<target> is relative to the device data' | 173 '<target> is relative to the device data' |
185 'directory, and <source> is relative to the ' | 174 'directory, and <source> is relative to the ' |
186 'chromium build directory.')) | 175 'chromium build directory.')) |
187 | 176 |
188 | 177 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 option_parser.add_option('-j', '--java_only', action='store_true', | 210 option_parser.add_option('-j', '--java_only', action='store_true', |
222 default=False, help='Run only the Java tests.') | 211 default=False, help='Run only the Java tests.') |
223 option_parser.add_option('-p', '--python_only', action='store_true', | 212 option_parser.add_option('-p', '--python_only', action='store_true', |
224 default=False, | 213 default=False, |
225 help='Run only the host-driven tests.') | 214 help='Run only the host-driven tests.') |
226 option_parser.add_option('--python_test_root', | 215 option_parser.add_option('--python_test_root', |
227 help='Root of the host-driven tests.') | 216 help='Root of the host-driven tests.') |
228 option_parser.add_option('-w', '--wait_debugger', dest='wait_for_debugger', | 217 option_parser.add_option('-w', '--wait_debugger', dest='wait_for_debugger', |
229 action='store_true', | 218 action='store_true', |
230 help='Wait for debugger.') | 219 help='Wait for debugger.') |
231 #TODO(craigdh): Remove option once -I is no longer passed downstream. | |
232 option_parser.add_option('-I', dest='install_apk', action='store_true', | |
233 help='(DEPRECATED) Install the test apk.') | |
234 option_parser.add_option( | 220 option_parser.add_option( |
235 '--test-apk', dest='test_apk', | 221 '--test-apk', dest='test_apk', |
236 help=('The name of the apk containing the tests ' | 222 help=('The name of the apk containing the tests ' |
237 '(without the .apk extension; e.g. "ContentShellTest"). ' | 223 '(without the .apk extension; e.g. "ContentShellTest"). ' |
238 'Alternatively, this can be a full path to the apk.')) | 224 'Alternatively, this can be a full path to the apk.')) |
239 | 225 |
240 | 226 |
241 def ProcessInstrumentationOptions(options, error_func): | 227 def ProcessInstrumentationOptions(options, error_func): |
242 """Processes options/arguments and populate |options| with defaults. | 228 """Processes options/arguments and populate |options| with defaults. |
243 | 229 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 options.build_type, | 272 options.build_type, |
287 options.tool, | 273 options.tool, |
288 options.cleanup_test_files, | 274 options.cleanup_test_files, |
289 options.push_deps, | 275 options.push_deps, |
290 options.annotations, | 276 options.annotations, |
291 options.exclude_annotations, | 277 options.exclude_annotations, |
292 options.test_filter, | 278 options.test_filter, |
293 options.test_data, | 279 options.test_data, |
294 options.save_perf_json, | 280 options.save_perf_json, |
295 options.screenshot_failures, | 281 options.screenshot_failures, |
296 options.disable_assertions, | |
297 options.wait_for_debugger, | 282 options.wait_for_debugger, |
298 options.test_apk, | 283 options.test_apk, |
299 options.test_apk_path, | 284 options.test_apk_path, |
300 options.test_apk_jar_path) | 285 options.test_apk_jar_path) |
301 | 286 |
302 | 287 |
303 def AddUIAutomatorTestOptions(option_parser): | 288 def AddUIAutomatorTestOptions(option_parser): |
304 """Adds UI Automator test options to |option_parser|.""" | 289 """Adds UI Automator test options to |option_parser|.""" |
305 | 290 |
306 option_parser.usage = '%prog uiautomator [options]' | 291 option_parser.usage = '%prog uiautomator [options]' |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 options.build_type, | 341 options.build_type, |
357 options.tool, | 342 options.tool, |
358 options.cleanup_test_files, | 343 options.cleanup_test_files, |
359 options.push_deps, | 344 options.push_deps, |
360 options.annotations, | 345 options.annotations, |
361 options.exclude_annotations, | 346 options.exclude_annotations, |
362 options.test_filter, | 347 options.test_filter, |
363 options.test_data, | 348 options.test_data, |
364 options.save_perf_json, | 349 options.save_perf_json, |
365 options.screenshot_failures, | 350 options.screenshot_failures, |
366 options.disable_assertions, | |
367 options.uiautomator_jar, | 351 options.uiautomator_jar, |
368 options.uiautomator_info_jar, | 352 options.uiautomator_info_jar, |
369 options.package_name) | 353 options.package_name) |
370 | 354 |
371 | 355 |
372 def _RunGTests(options, error_func): | 356 def _RunGTests(options, error_func): |
373 """Subcommand of RunTestsCommands which runs gtests.""" | 357 """Subcommand of RunTestsCommands which runs gtests.""" |
374 ProcessGTestOptions(options) | 358 ProcessGTestOptions(options) |
375 | 359 |
376 exit_code = 0 | 360 exit_code = 0 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 return 0 | 601 return 0 |
618 command = argv[1] | 602 command = argv[1] |
619 VALID_COMMANDS[command].add_options_func(option_parser) | 603 VALID_COMMANDS[command].add_options_func(option_parser) |
620 options, args = option_parser.parse_args(argv) | 604 options, args = option_parser.parse_args(argv) |
621 return VALID_COMMANDS[command].run_command_func( | 605 return VALID_COMMANDS[command].run_command_func( |
622 command, options, args, option_parser) | 606 command, options, args, option_parser) |
623 | 607 |
624 | 608 |
625 if __name__ == '__main__': | 609 if __name__ == '__main__': |
626 sys.exit(main(sys.argv)) | 610 sys.exit(main(sys.argv)) |
OLD | NEW |