fix: invalid warning on test-skip = ["*-macosx_universal2:arm64"] (#2522)

This commit is contained in:
Matthieu Darbois
2025-07-27 09:13:38 -04:00
committed by GitHub
parent 140bc1a96a
commit 1c38fac9c8
2 changed files with 44 additions and 4 deletions
+18 -4
View File
@@ -460,17 +460,31 @@ def check_for_invalid_selectors(
warnings = []
for selector in selector_value.split():
if not any(selector_matches(selector, i) for i in all_enabled_identifiers):
selector_ = selector
if selector_name == "test_skip":
# macosx_universal2 uses an additional identifier for tests which ends with ":{arch}"
values = selector.split(":")
universal2_identifiers = filter(
lambda x: x.endswith("-macosx_universal2"), all_valid_identifiers
)
if len(values) == 2 and any(
selector_matches(selector_, f"{i}:{arch}")
for i in universal2_identifiers
for arch in ["arm64", "x86_64"]
):
# just ignore the arch part in the rest of the check
selector_ = values[0]
if not any(selector_matches(selector_, i) for i in all_enabled_identifiers):
msg = f"Invalid {selector_name} selector: {selector!r}. "
error_type: type = errors.ConfigurationError
if any(selector_matches(selector, i) for i in all_valid_identifiers):
if any(selector_matches(selector_, i) for i in all_valid_identifiers):
msg += "This selector matches a group that wasn't enabled. Enable it using the `enable` option or remove this selector. "
if "p2" in selector or "p35" in selector:
if "p2" in selector_ or "p35" in selector_:
msg += f"cibuildwheel 3.x no longer supports Python < 3.8. Please use the 1.x series or update `{selector_name}`. "
error_type = errors.DeprecationError
if "p36" in selector or "p37" in selector:
if "p36" in selector_ or "p37" in selector_:
msg += f"cibuildwheel 3.x no longer supports Python < 3.8. Please use the 2.x series or update `{selector_name}`. "
error_type = errors.DeprecationError
+26
View File
@@ -105,6 +105,32 @@ def test_invalid_skip_selector(monkeypatch, capsys, option_name, option_env_var)
assert f"Invalid {option_name} selector" in err
@pytest.mark.parametrize(
"selector", ["*-macosx_universal2:arm64", "*-macosx_universal2:x86_64", "*-macosx_arm64"]
)
@pytest.mark.usefixtures("platform", "intercepted_build_args")
def test_valid_test_skip_selector(monkeypatch, capsys, selector):
monkeypatch.setenv("CIBW_TEST_SKIP", selector)
main()
_, err = capsys.readouterr()
print(err)
assert "Invalid test_skip selector" not in err
@pytest.mark.parametrize("selector", ["*-macosx_universal2:invalid", "*-macosx_arm64:arm64"])
@pytest.mark.usefixtures("platform", "intercepted_build_args")
def test_invalid_test_skip_selector(monkeypatch, capsys, selector):
monkeypatch.setenv("CIBW_TEST_SKIP", selector)
main()
_, err = capsys.readouterr()
print(err)
assert "Invalid test_skip selector" in err
@pytest.mark.usefixtures("platform", "intercepted_build_args")
def test_empty_selector(monkeypatch):
monkeypatch.setenv("CIBW_SKIP", "*")