diff --git a/test/test_macos_archs.py b/test/test_macos_archs.py index 0e30abdf6..f03fea921 100644 --- a/test/test_macos_archs.py +++ b/test/test_macos_archs.py @@ -14,6 +14,8 @@ *utils.expected_wheels("spam", "0.1.0", machine_arch="arm64", include_universal2=True), } +DEPLOYMENT_TARGET_TOO_LOW_WARNING = "[WARNING] MACOSX_DEPLOYMENT_TARGET is set to a lower value" + def get_xcode_version() -> tuple[int, int]: output = subprocess.run( @@ -72,8 +74,7 @@ def test_cross_compiled_test(tmp_path, capfd, build_universal2): captured = capfd.readouterr() - assert "[WARNING] MACOSX_DEPLOYMENT_TARGET is set to a lower value" not in captured.out - assert "[WARNING] MACOSX_DEPLOYMENT_TARGET is set to a lower value" not in captured.err + assert DEPLOYMENT_TARGET_TOO_LOW_WARNING not in captured.err if platform.machine() == "x86_64": # ensure that tests were run on only x86_64 @@ -101,6 +102,28 @@ def test_cross_compiled_test(tmp_path, capfd, build_universal2): assert set(actual_wheels) == set(expected_wheels) +def test_deployment_target_warning_is_firing(tmp_path, capfd): + # force the warning to check that we can detect it if it happens + if utils.platform != "macos": + pytest.skip("this test is only relevant to macos") + + project_dir = tmp_path / "project" + basic_project.generate(project_dir) + + utils.cibuildwheel_run( + project_dir, + add_env={ + "CIBW_BUILD": "cp39-*", + "CIBW_ARCHS": "x86_64", + "MACOSX_DEPLOYMENT_TARGET": "10.8", + "CIBW_BUILD_VERBOSITY": "3", + }, + ) + + captured = capfd.readouterr() + assert DEPLOYMENT_TARGET_TOO_LOW_WARNING in captured.err + + @pytest.mark.parametrize("skip_arm64_test", [False, True]) def test_universal2_testing(tmp_path, capfd, skip_arm64_test): if utils.platform != "macos":