fix: support platform-specific test runtime environment variables (#2941)

Honor platform-specific test runtime settings

Let the shared option reader apply Android and iOS environment overrides, matching the documented configuration precedence.

Constraint: Preserve existing global, TOML, and override behavior for test-runtime.
Rejected: Add Android/iOS-specific lookup code | OptionsReader already implements platform environment precedence.
Confidence: high
Scope-risk: narrow
Directive: Keep test-runtime on the shared option cascade when adding future platforms.
Tested: Focused red/green regression; 824 unit tests; prek all hooks; pylint 10.00/10; diff check.
Not-tested: Android and iOS device integration runs.

Co-authored-by: ychampion <ychampion@users.noreply.github.com>
This commit is contained in:
Yashas Gunderia
2026-07-21 21:12:40 -04:00
committed by GitHub
co-authored by ychampion
parent 17b74206ab
commit 1520daf8ae
2 changed files with 25 additions and 1 deletions
-1
View File
@@ -821,7 +821,6 @@ class Options:
test_runtime_str = self.reader.get(
"test-runtime",
env_plat=False,
option_format=ShlexTableFormat(sep="; ", pair_sep=":", allow_merge=False),
)
if not test_runtime_str:
+25
View File
@@ -832,6 +832,31 @@ def test_test_runtime_handling(
assert local.test_runtime.args == expected_args
@pytest.mark.parametrize(
("platform", "platform_envvar"),
[
("android", "CIBW_TEST_RUNTIME_ANDROID"),
("ios", "CIBW_TEST_RUNTIME_IOS"),
],
)
def test_test_runtime_platform_environment(
tmp_path: Path, platform: PlatformName, platform_envvar: str
) -> None:
args = CommandLineArguments.defaults()
args.package_dir = tmp_path
options = Options(
platform=platform,
command_line_arguments=args,
env={
"CIBW_TEST_RUNTIME": "args: --global",
platform_envvar: "args: --platform-specific",
},
)
assert options.build_options(None).test_runtime.args == ["--platform-specific"]
@pytest.mark.parametrize(
("definition", "expected"),
[