(location: Path, platform: str, simulator: str, verbose: bool)
| 61 | |
| 62 | |
| 63 | def xcode_test(location: Path, platform: str, simulator: str, verbose: bool): |
| 64 | # Build and run the test suite on the named simulator. |
| 65 | args = [ |
| 66 | "-project", |
| 67 | str(location / f"{platform}Testbed.xcodeproj"), |
| 68 | "-scheme", |
| 69 | f"{platform}Testbed", |
| 70 | "-destination", |
| 71 | f"platform={platform} Simulator,name={simulator}", |
| 72 | "-derivedDataPath", |
| 73 | str(location / "DerivedData"), |
| 74 | ] |
| 75 | verbosity_args = [] if verbose else ["-quiet"] |
| 76 | |
| 77 | print("Building test project...") |
| 78 | subprocess.run( |
| 79 | ["xcodebuild", "build-for-testing"] + args + verbosity_args, |
| 80 | check=True, |
| 81 | ) |
| 82 | |
| 83 | # Any environment variable prefixed with TEST_RUNNER_ is exposed into the |
| 84 | # test runner environment. There are some variables (like those identifying |
| 85 | # CI platforms) that can be useful to have access to. |
| 86 | test_env = os.environ.copy() |
| 87 | if "GITHUB_ACTIONS" in os.environ: |
| 88 | test_env["TEST_RUNNER_GITHUB_ACTIONS"] = os.environ["GITHUB_ACTIONS"] |
| 89 | |
| 90 | print("Running test project...") |
| 91 | # Test execution *can't* be run -quiet; verbose mode |
| 92 | # is how we see the output of the test output. |
| 93 | process = subprocess.Popen( |
| 94 | ["xcodebuild", "test-without-building"] + args, |
| 95 | stdout=subprocess.PIPE, |
| 96 | stderr=subprocess.STDOUT, |
| 97 | env=test_env, |
| 98 | ) |
| 99 | while line := (process.stdout.readline()).decode(*DECODE_ARGS): |
| 100 | # Strip the timestamp/process prefix from each log line |
| 101 | line = LOG_PREFIX_REGEX.sub("", line) |
| 102 | sys.stdout.write(line) |
| 103 | sys.stdout.flush() |
| 104 | |
| 105 | status = process.wait(timeout=5) |
| 106 | exit(status) |
| 107 | |
| 108 | |
| 109 | def copy(src, tgt): |
no test coverage detected
searching dependent graphs…