(context)
| 638 | |
| 639 | |
| 640 | async def gradle_task(context): |
| 641 | env = os.environ.copy() |
| 642 | if context.managed: |
| 643 | task_prefix = context.managed |
| 644 | else: |
| 645 | task_prefix = "connected" |
| 646 | env["ANDROID_SERIAL"] = context.connected |
| 647 | |
| 648 | if context.ci_mode: |
| 649 | context.args[0:0] = [ |
| 650 | # See _add_ci_python_opts in libregrtest/main.py. |
| 651 | "-W", "error", "-bb", "-E", |
| 652 | |
| 653 | # Randomization is disabled because order-dependent failures are |
| 654 | # much less likely to pass on a rerun in single-process mode. |
| 655 | "-m", "test", |
| 656 | f"--{context.ci_mode}-ci", "--single-process", "--no-randomize", |
| 657 | "--pythoninfo", |
| 658 | ] |
| 659 | |
| 660 | if not any(arg in context.args for arg in ["-c", "-m"]): |
| 661 | context.args[0:0] = ["-m", "test"] |
| 662 | |
| 663 | args = [ |
| 664 | gradlew, "--console", "plain", f"{task_prefix}DebugAndroidTest", |
| 665 | ] + [ |
| 666 | f"-P{name}={value}" |
| 667 | for name, value in [ |
| 668 | ("python.sitePackages", context.site_packages), |
| 669 | ("python.cwd", context.cwd), |
| 670 | ( |
| 671 | "android.testInstrumentationRunnerArguments.pythonArgs", |
| 672 | json.dumps(context.args), |
| 673 | ), |
| 674 | ] |
| 675 | if value |
| 676 | ] |
| 677 | if context.verbose >= 2: |
| 678 | args.append("--info") |
| 679 | log_verbose(context, f"> {join_command(args)}\n") |
| 680 | |
| 681 | try: |
| 682 | async with async_process( |
| 683 | *args, cwd=TESTBED_DIR, env=env, |
| 684 | stdout=subprocess.PIPE, stderr=subprocess.STDOUT, |
| 685 | ) as process: |
| 686 | while line := (await process.stdout.readline()).decode(*DECODE_ARGS): |
| 687 | # Gradle may take several minutes to install SDK packages, so |
| 688 | # it's worth showing those messages even in non-verbose mode. |
| 689 | if line.startswith('Preparing "Install'): |
| 690 | sys.stdout.write(line) |
| 691 | else: |
| 692 | log_verbose(context, line) |
| 693 | |
| 694 | status = await wait_for(process.wait(), timeout=1) |
| 695 | if status == 0: |
| 696 | exit(0) |
| 697 | else: |
no test coverage detected
searching dependent graphs…