Skip to content

Commit e706370

Browse files
committed
Add tests for test-execution parsing.
1 parent 5c0940c commit e706370

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

bin/generate_schema.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@
227227
test-execution:
228228
description: Additional configuration for the test runner
229229
oneOf:
230+
- type: string
231+
pattern: '^$'
232+
- type: object
233+
additionalProperties: false
230234
- type: string
231235
pattern: 'args:'
232236
- type: object

cibuildwheel/options.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class TestExecutionConfig:
9898

9999
@classmethod
100100
def from_config_string(cls, config_string: str) -> Self:
101-
config_dict = parse_key_value_string(config_string, ["args"])
101+
config_dict = parse_key_value_string(config_string, [], ["args"])
102102
args = config_dict.get("args") or []
103103
return cls(args=args)
104104

@@ -781,7 +781,7 @@ def _compute_build_options(self, identifier: str | None) -> BuildOptions:
781781
env_plat=False,
782782
option_format=ShlexTableFormat(sep="; ", pair_sep=":", allow_merge=False),
783783
)
784-
if not test_execution_str or test_execution_str == "default":
784+
if not test_execution_str:
785785
test_execution = TestExecutionConfig()
786786
else:
787787
try:

cibuildwheel/resources/cibuildwheel.schema.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,14 @@
576576
"type": "string",
577577
"pattern": "args:"
578578
},
579+
{
580+
"type": "string",
581+
"pattern": "^$"
582+
},
583+
{
584+
"type": "object",
585+
"additionalProperties": false
586+
},
579587
{
580588
"type": "object",
581589
"additionalProperties": false,

unit_test/options_test.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import platform as platform_module
33
import textwrap
44
import unittest.mock
5+
from collections.abc import Sequence
56
from pathlib import Path
67
from typing import Literal
78

@@ -626,6 +627,38 @@ def test_get_build_frontend_extra_flags_warning(
626627
mock_warning.assert_called_once()
627628

628629

630+
@pytest.mark.parametrize(
631+
("definition", "expected"),
632+
[
633+
("", ()),
634+
("test-execution = {}", ()),
635+
('test-execution = {args = ""}', []),
636+
('test-execution = "args: --simulator foo"', ["--simulator", "foo"]),
637+
('test-execution = {args = ["--simulator", "foo"]}', ["--simulator", "foo"]),
638+
],
639+
)
640+
def test_test_execution_handling(
641+
tmp_path: Path, definition: str, expected_args: Sequence[str] | None
642+
) -> None:
643+
args = CommandLineArguments.defaults()
644+
args.package_dir = tmp_path
645+
646+
pyproject_toml: Path = tmp_path / "pyproject.toml"
647+
pyproject_toml.write_text(
648+
textwrap.dedent(
649+
f"""\
650+
[tool.cibuildwheel]
651+
{definition}
652+
"""
653+
)
654+
)
655+
656+
options = Options(platform="ios", command_line_arguments=args, env={})
657+
658+
local = options.build_options("cp313-ios_13_0_arm64_iphoneos")
659+
assert local.test_execution.args == expected_args
660+
661+
629662
@pytest.mark.parametrize(
630663
("definition", "expected"),
631664
[

0 commit comments

Comments
 (0)