| 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. |
| 11 """ | 11 """ |
| 12 | 12 |
| 13 import collections | 13 import collections |
| 14 import optparse | 14 import optparse |
| 15 import os | 15 import os |
| 16 import shutil | 16 import shutil |
| 17 import sys | 17 import sys |
| 18 | 18 |
| 19 from pylib import cmd_helper | 19 from pylib import cmd_helper |
| 20 from pylib import constants | 20 from pylib import constants |
| 21 from pylib import ports | 21 from pylib import ports |
| 22 from pylib.base import base_test_result | 22 from pylib.base import base_test_result |
| 23 from pylib.base import test_dispatcher | 23 from pylib.base import test_dispatcher |
| 24 from pylib.browsertests import setup as browsertests_setup | 24 from pylib.browsertests import setup as browsertests_setup |
| 25 from pylib.gtest import gtest_config |
| 25 from pylib.gtest import setup as gtest_setup | 26 from pylib.gtest import setup as gtest_setup |
| 26 from pylib.gtest import gtest_config | 27 from pylib.host_driven import setup as host_driven_setup |
| 27 from pylib.host_driven import run_python_tests as python_dispatch | |
| 28 from pylib.instrumentation import setup as instrumentation_setup | 28 from pylib.instrumentation import setup as instrumentation_setup |
| 29 from pylib.uiautomator import setup as uiautomator_setup | 29 from pylib.uiautomator import setup as uiautomator_setup |
| 30 from pylib.utils import report_results | 30 from pylib.utils import report_results |
| 31 from pylib.utils import run_tests_helper | 31 from pylib.utils import run_tests_helper |
| 32 | 32 |
| 33 | 33 |
| 34 _SDK_OUT_DIR = os.path.join(constants.DIR_SOURCE_ROOT, 'out') | 34 _SDK_OUT_DIR = os.path.join(constants.DIR_SOURCE_ROOT, 'out') |
| 35 | 35 |
| 36 | 36 |
| 37 def AddBuildTypeOption(option_parser): | 37 def AddBuildTypeOption(option_parser): |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 tests, runner_factory, options.wait_for_debugger, | 427 tests, runner_factory, options.wait_for_debugger, |
| 428 options.test_device, | 428 options.test_device, |
| 429 shard=True, | 429 shard=True, |
| 430 build_type=options.build_type, | 430 build_type=options.build_type, |
| 431 test_timeout=None, | 431 test_timeout=None, |
| 432 num_retries=options.num_retries) | 432 num_retries=options.num_retries) |
| 433 | 433 |
| 434 results.AddTestRunResults(test_results) | 434 results.AddTestRunResults(test_results) |
| 435 | 435 |
| 436 if options.run_python_tests: | 436 if options.run_python_tests: |
| 437 test_results, test_exit_code = ( | 437 runner_factory, tests = host_driven_setup.InstrumentationSetup( |
| 438 python_dispatch.DispatchPythonTests(options)) | 438 options.python_test_root, options.official_build, options.annotations, |
| 439 options.exclude_annotations, options.test_filter, options.tool, |
| 440 options.build_type, options.push_deps, options.cleanup_test_files, |
| 441 options.test_apk_path, options.test_apk_jar_path, options.test_data, |
| 442 options.install_apk, options.save_perf_json, |
| 443 options.screenshot_failures, options.wait_for_debugger, |
| 444 options.disable_assertions) |
| 445 |
| 446 test_results, test_exit_code = test_dispatcher.RunTests( |
| 447 tests, runner_factory, False, |
| 448 options.test_device, |
| 449 shard=True, |
| 450 build_type=options.build_type, |
| 451 test_timeout=None, |
| 452 num_retries=options.num_retries) |
| 439 | 453 |
| 440 results.AddTestRunResults(test_results) | 454 results.AddTestRunResults(test_results) |
| 441 | 455 |
| 442 # Only allow exit code escalation | 456 # Only allow exit code escalation |
| 443 if test_exit_code and exit_code != constants.ERROR_EXIT_CODE: | 457 if test_exit_code and exit_code != constants.ERROR_EXIT_CODE: |
| 444 exit_code = test_exit_code | 458 exit_code = test_exit_code |
| 445 | 459 |
| 446 report_results.LogFull( | 460 report_results.LogFull( |
| 447 results=results, | 461 results=results, |
| 448 test_type='Instrumentation', | 462 test_type='Instrumentation', |
| (...skipping 24 matching lines...) Expand all Loading... |
| 473 test_results, exit_code = test_dispatcher.RunTests( | 487 test_results, exit_code = test_dispatcher.RunTests( |
| 474 tests, runner_factory, False, options.test_device, | 488 tests, runner_factory, False, options.test_device, |
| 475 shard=True, | 489 shard=True, |
| 476 build_type=options.build_type, | 490 build_type=options.build_type, |
| 477 test_timeout=None, | 491 test_timeout=None, |
| 478 num_retries=options.num_retries) | 492 num_retries=options.num_retries) |
| 479 | 493 |
| 480 results.AddTestRunResults(test_results) | 494 results.AddTestRunResults(test_results) |
| 481 | 495 |
| 482 if options.run_python_tests: | 496 if options.run_python_tests: |
| 483 test_results, test_exit_code = ( | 497 # TODO(gkanwar): Create a UIAutomator Setup, use it here |
| 484 python_dispatch.DispatchPythonTests(options)) | 498 runner_factory, tests = host_driven_setup.InstrumentationSetup( |
| 499 options.python_test_root, options.official_build, options.annotations, |
| 500 options.exclude_annotations, options.test_filter, options.tool, |
| 501 options.build_type, options.push_deps, options.cleanup_test_files, |
| 502 options.test_apk_path, options.test_apk_jar_path, options.test_data, |
| 503 options.install_apk, options.save_perf_json, |
| 504 options.screenshot_failures, options.wait_for_debugger, |
| 505 options.disable_assertion) |
| 506 |
| 507 test_results, test_exit_code = test_dispatcher.RunTests( |
| 508 tests, runner_factory, False, |
| 509 options.test_device, |
| 510 shard=True, |
| 511 build_type=options.build_type, |
| 512 test_timeout=None, |
| 513 num_retries=options.num_retries) |
| 485 | 514 |
| 486 results.AddTestRunResults(test_results) | 515 results.AddTestRunResults(test_results) |
| 487 | 516 |
| 488 # Only allow exit code escalation | 517 # Only allow exit code escalation |
| 489 if test_exit_code and exit_code != constants.ERROR_EXIT_CODE: | 518 if test_exit_code and exit_code != constants.ERROR_EXIT_CODE: |
| 490 exit_code = test_exit_code | 519 exit_code = test_exit_code |
| 491 | 520 |
| 492 report_results.LogFull( | 521 report_results.LogFull( |
| 493 results=results, | 522 results=results, |
| 494 test_type='UIAutomator', | 523 test_type='UIAutomator', |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 return _RunGTests(options, option_parser.error) | 558 return _RunGTests(options, option_parser.error) |
| 530 elif command == 'content_browsertests': | 559 elif command == 'content_browsertests': |
| 531 return _RunContentBrowserTests(options, option_parser.error) | 560 return _RunContentBrowserTests(options, option_parser.error) |
| 532 elif command == 'instrumentation': | 561 elif command == 'instrumentation': |
| 533 return _RunInstrumentationTests(options, option_parser.error) | 562 return _RunInstrumentationTests(options, option_parser.error) |
| 534 elif command == 'uiautomator': | 563 elif command == 'uiautomator': |
| 535 return _RunUIAutomatorTests(options, option_parser.error) | 564 return _RunUIAutomatorTests(options, option_parser.error) |
| 536 else: | 565 else: |
| 537 raise Exception('Unknown test type.') | 566 raise Exception('Unknown test type.') |
| 538 | 567 |
| 539 return exit_code | |
| 540 | |
| 541 | 568 |
| 542 def HelpCommand(command, options, args, option_parser): | 569 def HelpCommand(command, options, args, option_parser): |
| 543 """Display help for a certain command, or overall help. | 570 """Display help for a certain command, or overall help. |
| 544 | 571 |
| 545 Args: | 572 Args: |
| 546 command: String indicating the command that was received to trigger | 573 command: String indicating the command that was received to trigger |
| 547 this function. | 574 this function. |
| 548 options: optparse options dictionary. | 575 options: optparse options dictionary. |
| 549 args: List of extra args from optparse. | 576 args: List of extra args from optparse. |
| 550 option_parser: optparse.OptionParser object. | 577 option_parser: optparse.OptionParser object. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 return 0 | 661 return 0 |
| 635 command = argv[1] | 662 command = argv[1] |
| 636 VALID_COMMANDS[command].add_options_func(option_parser) | 663 VALID_COMMANDS[command].add_options_func(option_parser) |
| 637 options, args = option_parser.parse_args(argv) | 664 options, args = option_parser.parse_args(argv) |
| 638 return VALID_COMMANDS[command].run_command_func( | 665 return VALID_COMMANDS[command].run_command_func( |
| 639 command, options, args, option_parser) | 666 command, options, args, option_parser) |
| 640 | 667 |
| 641 | 668 |
| 642 if __name__ == '__main__': | 669 if __name__ == '__main__': |
| 643 sys.exit(main(sys.argv)) | 670 sys.exit(main(sys.argv)) |
| OLD | NEW |