| 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 import collections | 9 import collections |
| 10 import logging | 10 import logging |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 194 |
| 195 def ProcessJavaTestOptions(options): | 195 def ProcessJavaTestOptions(options): |
| 196 """Processes options/arguments and populates |options| with defaults.""" | 196 """Processes options/arguments and populates |options| with defaults.""" |
| 197 | 197 |
| 198 if options.annotation_str: | 198 if options.annotation_str: |
| 199 options.annotations = options.annotation_str.split(',') | 199 options.annotations = options.annotation_str.split(',') |
| 200 elif options.test_filter: | 200 elif options.test_filter: |
| 201 options.annotations = [] | 201 options.annotations = [] |
| 202 else: | 202 else: |
| 203 options.annotations = ['Smoke', 'SmallTest', 'MediumTest', 'LargeTest', | 203 options.annotations = ['Smoke', 'SmallTest', 'MediumTest', 'LargeTest', |
| 204 'EnormousTest'] | 204 'EnormousTest', 'IntegrationTest'] |
| 205 | 205 |
| 206 if options.exclude_annotation_str: | 206 if options.exclude_annotation_str: |
| 207 options.exclude_annotations = options.exclude_annotation_str.split(',') | 207 options.exclude_annotations = options.exclude_annotation_str.split(',') |
| 208 else: | 208 else: |
| 209 options.exclude_annotations = [] | 209 options.exclude_annotations = [] |
| 210 | 210 |
| 211 | 211 |
| 212 def AddInstrumentationTestOptions(option_parser): | 212 def AddInstrumentationTestOptions(option_parser): |
| 213 """Adds Instrumentation test options to |option_parser|.""" | 213 """Adds Instrumentation test options to |option_parser|.""" |
| 214 | 214 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 230 option_parser.add_option('-w', '--wait_debugger', dest='wait_for_debugger', | 230 option_parser.add_option('-w', '--wait_debugger', dest='wait_for_debugger', |
| 231 action='store_true', | 231 action='store_true', |
| 232 help='Wait for debugger.') | 232 help='Wait for debugger.') |
| 233 option_parser.add_option( | 233 option_parser.add_option( |
| 234 '--test-apk', dest='test_apk', | 234 '--test-apk', dest='test_apk', |
| 235 help=('The name of the apk containing the tests ' | 235 help=('The name of the apk containing the tests ' |
| 236 '(without the .apk extension; e.g. "ContentShellTest").')) | 236 '(without the .apk extension; e.g. "ContentShellTest").')) |
| 237 option_parser.add_option('--coverage-dir', | 237 option_parser.add_option('--coverage-dir', |
| 238 help=('Directory in which to place all generated ' | 238 help=('Directory in which to place all generated ' |
| 239 'EMMA coverage files.')) | 239 'EMMA coverage files.')) |
| 240 option_parser.add_option('--device-flags', dest='device_flags', default='', |
| 241 help='The relative filepath to a file containing ' |
| 242 'command-line flags to set on the device') |
| 240 | 243 |
| 241 | 244 |
| 242 def ProcessInstrumentationOptions(options, error_func): | 245 def ProcessInstrumentationOptions(options, error_func): |
| 243 """Processes options/arguments and populate |options| with defaults. | 246 """Processes options/arguments and populate |options| with defaults. |
| 244 | 247 |
| 245 Args: | 248 Args: |
| 246 options: optparse.Options object. | 249 options: optparse.Options object. |
| 247 error_func: Function to call with the error message in case of an error. | 250 error_func: Function to call with the error message in case of an error. |
| 248 | 251 |
| 249 Returns: | 252 Returns: |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 options.test_filter, | 295 options.test_filter, |
| 293 options.test_data, | 296 options.test_data, |
| 294 options.save_perf_json, | 297 options.save_perf_json, |
| 295 options.screenshot_failures, | 298 options.screenshot_failures, |
| 296 options.wait_for_debugger, | 299 options.wait_for_debugger, |
| 297 options.coverage_dir, | 300 options.coverage_dir, |
| 298 options.test_apk, | 301 options.test_apk, |
| 299 options.test_apk_path, | 302 options.test_apk_path, |
| 300 options.test_apk_jar_path, | 303 options.test_apk_jar_path, |
| 301 options.test_runner, | 304 options.test_runner, |
| 302 options.test_support_apk_path | 305 options.test_support_apk_path, |
| 306 options.device_flags |
| 303 ) | 307 ) |
| 304 | 308 |
| 305 | 309 |
| 306 def AddUIAutomatorTestOptions(option_parser): | 310 def AddUIAutomatorTestOptions(option_parser): |
| 307 """Adds UI Automator test options to |option_parser|.""" | 311 """Adds UI Automator test options to |option_parser|.""" |
| 308 | 312 |
| 309 option_parser.usage = '%prog uiautomator [options]' | 313 option_parser.usage = '%prog uiautomator [options]' |
| 310 option_parser.commands_dict = {} | 314 option_parser.commands_dict = {} |
| 311 option_parser.example = ( | 315 option_parser.example = ( |
| 312 '%prog uiautomator --test-jar=chrome_shell_uiautomator_tests' | 316 '%prog uiautomator --test-jar=chrome_shell_uiautomator_tests' |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 test_results, test_exit_code = test_dispatcher.RunTests( | 594 test_results, test_exit_code = test_dispatcher.RunTests( |
| 591 tests, runner_factory, devices, shard=True, test_timeout=None, | 595 tests, runner_factory, devices, shard=True, test_timeout=None, |
| 592 num_retries=options.num_retries) | 596 num_retries=options.num_retries) |
| 593 | 597 |
| 594 results.AddTestRunResults(test_results) | 598 results.AddTestRunResults(test_results) |
| 595 | 599 |
| 596 # Only allow exit code escalation | 600 # Only allow exit code escalation |
| 597 if test_exit_code and exit_code != constants.ERROR_EXIT_CODE: | 601 if test_exit_code and exit_code != constants.ERROR_EXIT_CODE: |
| 598 exit_code = test_exit_code | 602 exit_code = test_exit_code |
| 599 | 603 |
| 604 if options.device_flags: |
| 605 options.device_flags = '%s/%s' % (constants.DIR_SOURCE_ROOT, |
| 606 options.device_flags) |
| 607 |
| 600 report_results.LogFull( | 608 report_results.LogFull( |
| 601 results=results, | 609 results=results, |
| 602 test_type='Instrumentation', | 610 test_type='Instrumentation', |
| 603 test_package=os.path.basename(options.test_apk), | 611 test_package=os.path.basename(options.test_apk), |
| 604 annotation=options.annotations, | 612 annotation=options.annotations, |
| 605 flakiness_server=options.flakiness_dashboard_server) | 613 flakiness_server=options.flakiness_dashboard_server) |
| 606 | 614 |
| 607 return exit_code | 615 return exit_code |
| 608 | 616 |
| 609 | 617 |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 | 835 |
| 828 def main(): | 836 def main(): |
| 829 signal.signal(signal.SIGUSR1, DumpThreadStacks) | 837 signal.signal(signal.SIGUSR1, DumpThreadStacks) |
| 830 option_parser = command_option_parser.CommandOptionParser( | 838 option_parser = command_option_parser.CommandOptionParser( |
| 831 commands_dict=VALID_COMMANDS) | 839 commands_dict=VALID_COMMANDS) |
| 832 return command_option_parser.ParseAndExecute(option_parser) | 840 return command_option_parser.ParseAndExecute(option_parser) |
| 833 | 841 |
| 834 | 842 |
| 835 if __name__ == '__main__': | 843 if __name__ == '__main__': |
| 836 sys.exit(main()) | 844 sys.exit(main()) |
| OLD | NEW |