Skip to content

Commit 1c38fac

Browse files
authored
fix: invalid warning on test-skip = ["*-macosx_universal2:arm64"] (#2522)
1 parent 140bc1a commit 1c38fac

2 files changed

Lines changed: 44 additions & 4 deletions

File tree

cibuildwheel/__main__.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -460,17 +460,31 @@ def check_for_invalid_selectors(
460460
warnings = []
461461

462462
for selector in selector_value.split():
463-
if not any(selector_matches(selector, i) for i in all_enabled_identifiers):
463+
selector_ = selector
464+
if selector_name == "test_skip":
465+
# macosx_universal2 uses an additional identifier for tests which ends with ":{arch}"
466+
values = selector.split(":")
467+
universal2_identifiers = filter(
468+
lambda x: x.endswith("-macosx_universal2"), all_valid_identifiers
469+
)
470+
if len(values) == 2 and any(
471+
selector_matches(selector_, f"{i}:{arch}")
472+
for i in universal2_identifiers
473+
for arch in ["arm64", "x86_64"]
474+
):
475+
# just ignore the arch part in the rest of the check
476+
selector_ = values[0]
477+
if not any(selector_matches(selector_, i) for i in all_enabled_identifiers):
464478
msg = f"Invalid {selector_name} selector: {selector!r}. "
465479
error_type: type = errors.ConfigurationError
466480

467-
if any(selector_matches(selector, i) for i in all_valid_identifiers):
481+
if any(selector_matches(selector_, i) for i in all_valid_identifiers):
468482
msg += "This selector matches a group that wasn't enabled. Enable it using the `enable` option or remove this selector. "
469483

470-
if "p2" in selector or "p35" in selector:
484+
if "p2" in selector_ or "p35" in selector_:
471485
msg += f"cibuildwheel 3.x no longer supports Python < 3.8. Please use the 1.x series or update `{selector_name}`. "
472486
error_type = errors.DeprecationError
473-
if "p36" in selector or "p37" in selector:
487+
if "p36" in selector_ or "p37" in selector_:
474488
msg += f"cibuildwheel 3.x no longer supports Python < 3.8. Please use the 2.x series or update `{selector_name}`. "
475489
error_type = errors.DeprecationError
476490

unit_test/main_tests/main_options_test.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,32 @@ def test_invalid_skip_selector(monkeypatch, capsys, option_name, option_env_var)
105105
assert f"Invalid {option_name} selector" in err
106106

107107

108+
@pytest.mark.parametrize(
109+
"selector", ["*-macosx_universal2:arm64", "*-macosx_universal2:x86_64", "*-macosx_arm64"]
110+
)
111+
@pytest.mark.usefixtures("platform", "intercepted_build_args")
112+
def test_valid_test_skip_selector(monkeypatch, capsys, selector):
113+
monkeypatch.setenv("CIBW_TEST_SKIP", selector)
114+
115+
main()
116+
117+
_, err = capsys.readouterr()
118+
print(err)
119+
assert "Invalid test_skip selector" not in err
120+
121+
122+
@pytest.mark.parametrize("selector", ["*-macosx_universal2:invalid", "*-macosx_arm64:arm64"])
123+
@pytest.mark.usefixtures("platform", "intercepted_build_args")
124+
def test_invalid_test_skip_selector(monkeypatch, capsys, selector):
125+
monkeypatch.setenv("CIBW_TEST_SKIP", selector)
126+
127+
main()
128+
129+
_, err = capsys.readouterr()
130+
print(err)
131+
assert "Invalid test_skip selector" in err
132+
133+
108134
@pytest.mark.usefixtures("platform", "intercepted_build_args")
109135
def test_empty_selector(monkeypatch):
110136
monkeypatch.setenv("CIBW_SKIP", "*")

0 commit comments

Comments
 (0)