From 86248929ed23437857196e216ad784597e6ec5f4 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 28 Sep 2023 19:32:18 -0400 Subject: [PATCH] fix: ensure 2+ items in each override in schema (#1628) Signed-off-by: Henry Schreiner --- bin/generate_schema.py | 1 + cibuildwheel/resources/cibuildwheel.schema.json | 1 + unit_test/validate_schema_test.py | 13 +++++++++++++ 3 files changed, 15 insertions(+) diff --git a/bin/generate_schema.py b/bin/generate_schema.py index 64245c013..b5c1c60af 100755 --- a/bin/generate_schema.py +++ b/bin/generate_schema.py @@ -200,6 +200,7 @@ items: type: object required: ["select"] + minProperties: 2 additionalProperties: false properties: select: {} diff --git a/cibuildwheel/resources/cibuildwheel.schema.json b/cibuildwheel/resources/cibuildwheel.schema.json index 5930b4972..b9427c3ef 100644 --- a/cibuildwheel/resources/cibuildwheel.schema.json +++ b/cibuildwheel/resources/cibuildwheel.schema.json @@ -406,6 +406,7 @@ "required": [ "select" ], + "minProperties": 2, "additionalProperties": false, "properties": { "select": { diff --git a/unit_test/validate_schema_test.py b/unit_test/validate_schema_test.py index 742049346..66c95f25a 100644 --- a/unit_test/validate_schema_test.py +++ b/unit_test/validate_schema_test.py @@ -59,6 +59,19 @@ def test_overrides_no_select(): validator(example) +def test_overrides_only_select(): + example = tomllib.loads( + """ + [[tool.cibuildwheel.overrides]] + select = "somestring" + """ + ) + + validator = validate_pyproject.api.Validator() + with pytest.raises(validate_pyproject.error_reporting.ValidationError): + validator(example) + + def test_docs_examples(): """ Parse out all the configuration examples, build valid TOML out of them, and