Beispiel #1
0
 async def run_with_client(self, args: Namespace, client: Client) -> None:
     artifact: Optional[InstalledArtifact] = None
     compression = (Compression[args.compression]
                    if args.compression is not None else None)
     async for info in client.install(
             bundle=args.bundle_path,
             make_debuggable=args.make_debuggable,
             compression=compression,
             override_modification_time=args.override_mtime,
     ):
         artifact = info
         progress = info.progress
         if progress is None:
             continue
         self.logger.info(f"Progress: {progress}")
     if args.json:
         print(
             json.dumps({
                 "installedAppBundleId": none_throws(artifact).name,
                 "uuid": none_throws(artifact).uuid,
             }))
     else:
         print(
             f"Installed: {none_throws(artifact).name} {none_throws(artifact).uuid}"
         )
Beispiel #2
0
 async def run_with_container(self, container: FileContainer,
                              args: Namespace, client: Client) -> None:
     async for data in client.tail(container=container,
                                   path=args.src,
                                   stop=signal_handler_event("tail")):
         sys.stdout.buffer.write(data)
         sys.stdout.flush()
Beispiel #3
0
 async def run_with_client(self, args: Namespace, client: Client) -> None:
     async for chunk in client.tail_logs(
             stop=signal_handler_event("log"),
             arguments=self.normalise_log_arguments(args.log_arguments),
     ):
         print(chunk, end="")
     print("")
Beispiel #4
0
    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"

        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,
            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,
        ):
            print(formatter(test_result))
Beispiel #5
0
 async def run_with_client(self, args: Namespace, client: Client) -> None:
     async for install_response in client.install_dsym(args.dsym_path):
         if install_response.progress != 0.0 and not args.json:
             print("Installed {install_response.progress}%")
         elif args.json:
             print(json.dumps({"dsym": install_response.name}))
         else:
             print(f"Installed: {install_response.name}")
Beispiel #6
0
    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))
Beispiel #7
0
 async def run_with_client(self, args: Namespace, client: Client) -> None:
     async for data in signal_handler_generator(
             iterable=client.stream_video(
                 output_file=args.output_file,
                 fps=args.fps,
                 format=_FORMAT_CHOICE_MAP[args.format],
             ),
             name="stream",
             logger=self.logger,
     ):
         sys.stdout.buffer.write(data)
Beispiel #8
0
    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)
Beispiel #9
0
 async def run_with_client(self, args: Namespace, client: Client) -> None:
     async for install_response in client.install_xctest(
             args.test_bundle_path):
         if install_response.progress != 0.0 and not args.json:
             print("Installed {install_response.progress}%")
         elif args.json:
             print(
                 json.dumps({
                     "installedTestBundleId": install_response.name,
                     "uuid": install_response.uuid,
                 }))
         else:
             print(
                 f"Installed: {install_response.name} {install_response.uuid}"
             )
Beispiel #10
0
 async def run_with_client(self, args: Namespace, client: Client) -> None:
     async for install_response in client.install_framework(
             args.framework_path):
         if install_response.progress != 0.0 and not args.json:
             print("Installed {install_response.progress}%")
         elif args.json:
             print(
                 json.dumps({
                     "framework": install_response.name,
                     "uuid": install_response.uuid,
                 }))
         else:
             print(
                 f"Installed: {install_response.name} {install_response.uuid}"
             )
Beispiel #11
0
    async def run_with_client(self, args: Namespace, client: Client) -> None:
        compression = (Compression[args.compression]
                       if args.compression is not None else None)

        bundle_type = FileContainerType.APPLICATION if args.bundle_id else None
        async for install_response in client.install_dsym(
                args.dsym_path,
                args.bundle_id,
                compression,
                bundle_type,
        ):
            if install_response.progress != 0.0 and not args.json:
                print("Installed {install_response.progress}%")
            elif args.json:
                print(json.dumps({"dsym": install_response.name}))
            else:
                print(f"Installed: {install_response.name}")
Beispiel #12
0
 async def run_with_client(self, args: Namespace, client: Client) -> None:
     artifact: Optional[InstalledArtifact] = None
     async for info in client.install(args.bundle_path):
         artifact = info
         progress = info.progress
         if progress is None:
             continue
         self.logger.info(f"Progress: {progress}")
     if args.json:
         print(
             json.dumps({
                 "installedAppBundleId": none_throws(artifact).name,
                 "uuid": none_throws(artifact).uuid,
             }))
     else:
         print(
             f"Installed: {none_throws(artifact).name} {none_throws(artifact).uuid}"
         )
Beispiel #13
0
    async def install_dsym_test_bundle(
            self, args: Namespace, client: Client,
            test_bundle_location: str) -> Optional[str]:
        dsym_name = None
        dsym_path_location = args.install_dsym_test_bundle
        if args.install_dsym_test_bundle == NO_SPECIFIED_PATH:
            dsym_path_location = test_bundle_location + ".dSYM"

        if not os.path.exists(dsym_path_location):
            raise IdbException(
                "XCTest run failed! Error: --install-dsym flag was used but there is no file at location {}."
                .format(dsym_path_location))

        async for install_response in client.install_dsym(
                dsym=dsym_path_location,
                bundle_id=args.test_bundle_id,
                bundle_type=FileContainerType.XCTEST,
                compression=None,
        ):
            if install_response.progress == 0.0:
                dsym_name = install_response.name
        return dsym_name
Beispiel #14
0
 async def install_bundles(self, args: Namespace, client: Client) -> None:
     await super().install_bundles(args, client)
     async for app in client.install(args.test_host_app_bundle_id):
         args.test_host_app_bundle_id = app.name
Beispiel #15
0
 async def install_bundles(self, args: Namespace, client: Client) -> None:
     async for test in client.install_xctest(args.test_bundle_id):
         args.test_bundle_id = test.name
Beispiel #16
0
 async def run_with_client(self, args: Namespace, client: Client) -> None:
     async for chunk in client.tail_companion_logs(
             stop=signal_handler_event("log")):
         print(chunk, end="")
     print("")