def _RunInstrumentationTests(options, error_func, devices): """Subcommand of RunTestsCommands which runs instrumentation tests.""" instrumentation_options = ProcessInstrumentationOptions( options, error_func) if len(devices) > 1 and options.wait_for_debugger: logging.warning( 'Debugger can not be sharded, using first available device') devices = devices[:1] results = base_test_result.TestRunResults() exit_code = 0 if options.run_java_tests: runner_factory, tests = instrumentation_setup.Setup( instrumentation_options, devices) test_results, exit_code = test_dispatcher.RunTests( tests, runner_factory, devices, shard=True, test_timeout=None, num_retries=options.num_retries) results.AddTestRunResults(test_results) if options.run_python_tests: runner_factory, tests = host_driven_setup.InstrumentationSetup( options.host_driven_root, options.official_build, instrumentation_options) if tests: test_results, test_exit_code = test_dispatcher.RunTests( tests, runner_factory, devices, shard=True, test_timeout=None, num_retries=options.num_retries) results.AddTestRunResults(test_results) # Only allow exit code escalation if test_exit_code and exit_code != constants.ERROR_EXIT_CODE: exit_code = test_exit_code if options.device_flags: options.device_flags = os.path.join(constants.DIR_SOURCE_ROOT, options.device_flags) report_results.LogFull(results=results, test_type='Instrumentation', test_package=os.path.basename(options.test_apk), annotation=options.annotations, flakiness_server=options.flakiness_dashboard_server) return exit_code
def _RunInstrumentationTests(options, error_func): """Subcommand of RunTestsCommands which runs instrumentation tests.""" instrumentation_options = ProcessInstrumentationOptions( options, error_func) results = base_test_result.TestRunResults() exit_code = 0 if options.run_java_tests: runner_factory, tests = instrumentation_setup.Setup( instrumentation_options) test_results, exit_code = test_dispatcher.RunTests( tests, runner_factory, options.wait_for_debugger, options.test_device, shard=True, build_type=options.build_type, test_timeout=None, num_retries=options.num_retries) results.AddTestRunResults(test_results) if options.run_python_tests: runner_factory, tests = host_driven_setup.InstrumentationSetup( options.python_test_root, options.official_build, instrumentation_options) if tests: test_results, test_exit_code = test_dispatcher.RunTests( tests, runner_factory, False, options.test_device, shard=True, build_type=options.build_type, test_timeout=None, num_retries=options.num_retries) results.AddTestRunResults(test_results) # Only allow exit code escalation if test_exit_code and exit_code != constants.ERROR_EXIT_CODE: exit_code = test_exit_code report_results.LogFull(results=results, test_type='Instrumentation', test_package=os.path.basename(options.test_apk), annotation=options.annotations, build_type=options.build_type, flakiness_server=options.flakiness_dashboard_server) return exit_code
def _RunInstrumentationTests(args, devices): """Subcommand of RunTestsCommands which runs instrumentation tests.""" logging.info('_RunInstrumentationTests(%s, %s)', str(args), str(devices)) instrumentation_options = ProcessInstrumentationOptions(args) if len(devices) > 1 and args.wait_for_debugger: logging.warning('Debugger can not be sharded, using first available device') devices = devices[:1] results = base_test_result.TestRunResults() exit_code = 0 if args.run_java_tests: java_runner_factory, java_tests = instrumentation_setup.Setup( instrumentation_options, devices) else: java_runner_factory = None java_tests = None if args.run_python_tests: py_runner_factory, py_tests = host_driven_setup.InstrumentationSetup( args.host_driven_root, args.official_build, instrumentation_options) else: py_runner_factory = None py_tests = None results = [] repetitions = (xrange(args.repeat + 1) if args.repeat >= 0 else itertools.count()) code_counts = {constants.INFRA_EXIT_CODE: 0, constants.ERROR_EXIT_CODE: 0, constants.WARNING_EXIT_CODE: 0, 0: 0} def _escalate_code(old, new): for x in (constants.INFRA_EXIT_CODE, constants.ERROR_EXIT_CODE, constants.WARNING_EXIT_CODE): if x in (old, new): return x return 0 for _ in repetitions: iteration_results = base_test_result.TestRunResults() if java_tests: test_results, test_exit_code = test_dispatcher.RunTests( java_tests, java_runner_factory, devices, shard=True, test_timeout=None, num_retries=args.num_retries) iteration_results.AddTestRunResults(test_results) code_counts[test_exit_code] += 1 exit_code = _escalate_code(exit_code, test_exit_code) if py_tests: test_results, test_exit_code = test_dispatcher.RunTests( py_tests, py_runner_factory, devices, shard=True, test_timeout=None, num_retries=args.num_retries) iteration_results.AddTestRunResults(test_results) code_counts[test_exit_code] += 1 exit_code = _escalate_code(exit_code, test_exit_code) results.append(iteration_results) report_results.LogFull( results=iteration_results, test_type='Instrumentation', test_package=os.path.basename(args.test_apk), annotation=args.annotations, flakiness_server=args.flakiness_dashboard_server) if args.break_on_failure and exit_code in (constants.ERROR_EXIT_CODE, constants.INFRA_EXIT_CODE): break logging.critical('Instr tests: %s success, %s infra, %s errors, %s warnings', str(code_counts[0]), str(code_counts[constants.INFRA_EXIT_CODE]), str(code_counts[constants.ERROR_EXIT_CODE]), str(code_counts[constants.WARNING_EXIT_CODE])) if args.json_results_file: json_results.GenerateJsonResultsFile(results, args.json_results_file) return exit_code
def _RunInstrumentationTests(args, devices): """Subcommand of RunTestsCommands which runs instrumentation tests.""" logging.info('_RunInstrumentationTests(%s, %s)', str(args), str(devices)) instrumentation_options = ProcessInstrumentationOptions(args) if len(devices) > 1 and args.wait_for_debugger: logging.warning( 'Debugger can not be sharded, using first available device') devices = devices[:1] results = base_test_result.TestRunResults() exit_code = 0 if args.run_java_tests: java_runner_factory, java_tests = instrumentation_setup.Setup( instrumentation_options, devices) else: java_runner_factory = None java_tests = None if args.run_python_tests: py_runner_factory, py_tests = host_driven_setup.InstrumentationSetup( args.host_driven_root, args.official_build, instrumentation_options) else: py_runner_factory = None py_tests = None results = [] repetitions = (xrange(args.repeat + 1) if args.repeat >= 0 else itertools.count()) for _ in repetitions: iteration_results = base_test_result.TestRunResults() if java_tests: test_results, test_exit_code = test_dispatcher.RunTests( java_tests, java_runner_factory, devices, shard=True, test_timeout=None, num_retries=args.num_retries) iteration_results.AddTestRunResults(test_results) # Only allow exit code escalation if test_exit_code and exit_code != constants.ERROR_EXIT_CODE: exit_code = test_exit_code if py_tests: test_results, test_exit_code = test_dispatcher.RunTests( py_tests, py_runner_factory, devices, shard=True, test_timeout=None, num_retries=args.num_retries) iteration_results.AddTestRunResults(test_results) # Only allow exit code escalation if test_exit_code and exit_code != constants.ERROR_EXIT_CODE: exit_code = test_exit_code results.append(iteration_results) report_results.LogFull( results=iteration_results, test_type='Instrumentation', test_package=os.path.basename(args.test_apk), annotation=args.annotations, flakiness_server=args.flakiness_dashboard_server) if args.json_results_file: json_results.GenerateJsonResultsFile(results, args.json_results_file) return exit_code