From 1520daf8aecb6af4d0472d1773f02d76a83bfafe Mon Sep 17 00:00:00 2001 From: Yashas Gunderia <68075205+ychampion@users.noreply.github.com> Date: Wed, 22 Jul 2026 06:42:40 +0530 Subject: [PATCH] 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 --- cibuildwheel/options.py | 1 - unit_test/options_test.py | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/cibuildwheel/options.py b/cibuildwheel/options.py index f983c65b..77189dab 100644 --- a/cibuildwheel/options.py +++ b/cibuildwheel/options.py @@ -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: diff --git a/unit_test/options_test.py b/unit_test/options_test.py index f8c7b643..596ad27d 100644 --- a/unit_test/options_test.py +++ b/unit_test/options_test.py @@ -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"), [