async def run_with_client(self, args: Namespace, client: IdbClient) -> None: await super().run_with_client(args, client) tests_to_run = self.get_tests_to_run(args) tests_to_skip = self.get_tests_to_skip(args) app_bundle_id = args.app_bundle_id if hasattr( args, "app_bundle_id") else None test_host_app_bundle_id = (args.test_host_app_bundle_id if hasattr( args, "test_host_app_bundle_id") else None) arguments = getattr(args, "test_arguments", []) is_ui = args.run == "ui" is_logic = args.run == "logic" formatter = json_format_test_info if args.json else human_format_test_info async for test_result in client.run_xctest( test_bundle_id=args.test_bundle_id, app_bundle_id=app_bundle_id, test_host_app_bundle_id=test_host_app_bundle_id, is_ui_test=is_ui, is_logic_test=is_logic, tests_to_run=tests_to_run, tests_to_skip=tests_to_skip, timeout=args.timeout, env=get_env_with_idb_prefix(), args=arguments, result_bundle_path=args.result_bundle_path, ): print(formatter(test_result))
async def run_with_client(self, args: Namespace, client: IdbClient) -> None: await client.launch( bundle_id=args.bundle_id, args=args.app_arguments, env=get_env_with_idb_prefix(), foreground_if_running=args.foreground_if_running, stop=signal_handler_event("launch") if args.wait_for else None, )
async def run_with_client(self, args: Namespace, client: Client) -> None: await super().run_with_client(args, client) is_ui = args.run == "ui" is_logic = args.run == "logic" is_app = args.run == "app" if args.install: # Note for --install specified, test_bundle_id is a path initially, but # `install_bundles` will override it. test_bundle_location = args.test_bundle_id await self.install_bundles(args, client) if args.install_dsym_test_bundle: if is_ui or is_app: print( "--install-dsym-test-bundle is experimental for ui and app tests; this flag is only supported for logic tests." ) await self.install_dsym_test_bundle(args, client, test_bundle_location) tests_to_run = self.get_tests_to_run(args) tests_to_skip = self.get_tests_to_skip(args) app_bundle_id = args.app_bundle_id if hasattr( args, "app_bundle_id") else None test_host_app_bundle_id = (args.test_host_app_bundle_id if hasattr( args, "test_host_app_bundle_id") else None) arguments = getattr(args, "test_arguments", []) if args.wait_for_debugger and is_ui: print( "--wait_for_debugger flag is NOT supported for ui tests. It will default to False" ) formatter = json_format_test_info if args.json else human_format_test_info coverage_format = CodeCoverageFormat[args.coverage_format] async for test_result in client.run_xctest( test_bundle_id=args.test_bundle_id, app_bundle_id=app_bundle_id, test_host_app_bundle_id=test_host_app_bundle_id, is_ui_test=is_ui, is_logic_test=is_logic, tests_to_run=tests_to_run, tests_to_skip=tests_to_skip, timeout=args.timeout, env=get_env_with_idb_prefix(), args=arguments, result_bundle_path=args.result_bundle_path, report_activities=args.report_activities or args.report_attachments, report_attachments=args.report_attachments, activities_output_path=args.activities_output_path, coverage_output_path=args.coverage_output_path, coverage_format=coverage_format, log_directory_path=args.log_directory_path, wait_for_debugger=args.wait_for_debugger, ): print(formatter(test_result))
async def run_with_client(self, args: Namespace, client: Client) -> None: app_arguments = args.app_args app_environment = args.app_env # merge in special environment variables prefixed with 'IDB_' app_environment.update(get_env_with_idb_prefix()) post_process_arguments = args.post_args timings = ( InstrumentsTimings( terminate_timeout=args.terminate_timeout, launch_retry_timeout=args.launch_retry_timeout, launch_error_timeout=args.launch_error_timeout, operation_duration=args.operation_duration, ) if ( args.terminate_timeout or args.launch_retry_timeout or args.launch_error_timeout or args.operation_duration ) else None ) trace_extensions = ["trace"] trace_basename = args.output if trace_basename: if os.path.isdir(trace_basename): trace_basename = find_next_file_prefix( os.path.join(trace_basename, "trace"), trace_extensions ) else: # remove any user-specified file extension (e.g. 'foo.trace') trace_basename = os.path.splitext(trace_basename)[0] else: trace_basename = find_next_file_prefix("trace", trace_extensions) result = await client.run_instruments( stop=signal_handler_event("instruments"), trace_basename=trace_basename, template_name=args.template, app_bundle_id=args.app_bundle_id, app_environment=app_environment, app_arguments=app_arguments, tool_arguments=None, timings=timings, post_process_arguments=post_process_arguments, ) print(result)
async def run_with_client(self, args: Namespace, client: Client) -> None: if args.append_run: self.logger.info( "The '--append-run' option will be ignored. It's not implemented." ) if args.device: self.logger.info( "The '--device' option will be ignored. The target associated with " + "the companion will be used by default.") if args.target_stdin and args.target_stdin != "-": raise XctraceRecordException( 'Only "-" is supported as a valid value for --target-stdin') if args.target_stdout and args.target_stdout != "-": raise XctraceRecordException( 'Only "-" is supported as a valid value for --target-stdout') env = args.env # merge in special environment variables prefixed with 'IDB_' env.update(get_env_with_idb_prefix()) trace_extensions = ["trace"] trace_basename = args.output if trace_basename: if os.path.isdir(trace_basename): trace_basename = find_next_file_prefix( os.path.join(trace_basename, "trace"), trace_extensions) else: # remove any user-specified file extension (e.g. 'foo.trace') trace_basename = os.path.splitext(trace_basename)[0] else: trace_basename = find_next_file_prefix("trace", trace_extensions) result = await client.xctrace_record( stop=signal_handler_event("xctrace"), output=trace_basename, template_name=args.template, all_processes=args.all_processes, time_limit=formatted_time_to_seconds(args.time_limit), package=args.package, process_to_attach=args.attach, process_to_launch=args.launch, process_env=env, launch_args=args.launch_args, target_stdin=args.target_stdin, target_stdout=args.target_stdout, post_args=args.post_args, stop_timeout=formatted_time_to_seconds(args.stop_timeout), ) print(result)
async def run_with_client(self, args: Namespace, client: Client) -> None: await super().run_with_client(args, client) if args.install: await self.install_bundles(args, client) tests_to_run = self.get_tests_to_run(args) tests_to_skip = self.get_tests_to_skip(args) app_bundle_id = args.app_bundle_id if hasattr( args, "app_bundle_id") else None test_host_app_bundle_id = (args.test_host_app_bundle_id if hasattr( args, "test_host_app_bundle_id") else None) arguments = getattr(args, "test_arguments", []) is_ui = args.run == "ui" is_logic = args.run == "logic" if args.wait_for_debugger and is_ui: print( "--wait_for_debugger flag is NOT supported for ui tests. It will default to False" ) formatter = json_format_test_info if args.json else human_format_test_info crashed_outside_test_case = False coverage_format = CodeCoverageFormat[args.coverage_format] async for test_result in client.run_xctest( test_bundle_id=args.test_bundle_id, app_bundle_id=app_bundle_id, test_host_app_bundle_id=test_host_app_bundle_id, is_ui_test=is_ui, is_logic_test=is_logic, tests_to_run=tests_to_run, tests_to_skip=tests_to_skip, timeout=args.timeout, env=get_env_with_idb_prefix(), args=arguments, result_bundle_path=args.result_bundle_path, report_activities=args.report_activities or args.report_attachments, report_attachments=args.report_attachments, activities_output_path=args.activities_output_path, coverage_output_path=args.coverage_output_path, coverage_format=coverage_format, log_directory_path=args.log_directory_path, wait_for_debugger=args.wait_for_debugger, ): print(formatter(test_result)) crashed_outside_test_case = (crashed_outside_test_case or test_result.crashed_outside_test_case) if crashed_outside_test_case: raise ExitWithCodeException(3)
async def run_with_client(self, args: Namespace, client: IdbClient) -> None: trace_path = args.trace_path if trace_path is None: trace_path = f"{args.template}.trace" app_args = None if not args.app_args else args.app_args post_process_arguments = None if not args.post_args else args.post_args result = await client.run_instruments( stop=signal_handler_event("instruments"), template=args.template, app_bundle_id=args.app_bundle_id, post_process_arguments=post_process_arguments, env=get_env_with_idb_prefix(), app_args=app_args, trace_path=trace_path, ) print(result)