Skip to content

Commit e3b6f3d

Browse files
committed
Speed up make check ~5x
Geometry constraint tests: replace full powerset (127 subsets of 7 geometry types) with singletons + pairs + full set (29 subsets). GeometryTypeConstraint is a set-membership check — combinatorial testing beyond pairs exercises no additional code paths. Makefile: run pytest, doctest, ruff, and mypy concurrently via make -j after a single upfront uv-sync. Added -only variants (no uv-sync dep) for the parallel invocation; standalone targets preserved with their original uv-sync dependencies.
1 parent bfaaf14 commit e3b6f3d

2 files changed

Lines changed: 30 additions & 17 deletions

File tree

Makefile

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: default uv-sync check test-all test docformat doctest mypy reset-baseline-schemas
1+
.PHONY: default uv-sync check test-all test test-only docformat doctest doctest-only mypy mypy-only lint-only reset-baseline-schemas
22

33
default: test-all
44

@@ -7,25 +7,28 @@ install: uv-sync
77
uv-sync:
88
@uv sync --all-packages 2> /dev/null
99

10-
check: test doctest
11-
@uv run ruff check -q packages/
12-
@$(MAKE) mypy
13-
@uv run ruff format --check packages/
10+
check: uv-sync
11+
@$(MAKE) -j test-only doctest-only lint-only mypy-only
1412

1513
test-all: uv-sync
1614
@uv run pytest -W error packages/
1715

1816
test: uv-sync
1917
@uv run pytest -W error packages/ -x -q --tb=short
2018

19+
test-only:
20+
@uv run pytest -W error packages/ -x -q --tb=short
21+
2122
coverage: uv-sync
2223
@uv run pytest packages/ --cov overture.schema --cov-report=term --cov-report=html && open htmlcov/index.html
2324

2425
docformat:
2526
@find packages/*/src -name "*.py" -type f -not -name "__*" \
2627
| xargs uv run pydocstyle --convention=numpy --add-ignore=D102,D105,D200,D205,D400
2728

28-
doctest: uv-sync
29+
doctest: uv-sync doctest-only
30+
31+
doctest-only:
2932
@# $$ escapes $ for make - sed needs literal $ for end-of-line anchor
3033
@find packages/*/src -name "*.py" -type f \
3134
| sed 's|^packages/[^/]*/src/||' \
@@ -37,7 +40,9 @@ doctest: uv-sync
3740
| xargs uv run python -c 'import doctest, importlib, sys; sys.exit(any(doctest.testmod(importlib.import_module(m)).failed for m in sys.argv[1:]))'
3841

3942
# mypy type checking with namespace package support
40-
mypy: uv-sync
43+
mypy: uv-sync mypy-only
44+
45+
mypy-only:
4146
@# $$ escapes $ for make - sed needs literal $ for end-of-line anchor
4247
@find packages -maxdepth 1 -type d -name "overture-schema*" \
4348
| sort \
@@ -47,5 +52,9 @@ mypy: uv-sync
4752
| xargs uv run mypy --no-error-summary
4853
@for d in packages/*/tests; do find "$$d" -name "*.py" | sort | xargs uv run mypy --no-error-summary || exit 1; done
4954

55+
lint-only:
56+
@uv run ruff check -q packages/
57+
@uv run ruff format --check packages/
58+
5059
reset-baseline-schemas:
5160
@find . -name \*_baseline_schema.json -delete

packages/overture-schema-system/tests/primitive/test_geom.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import re
2-
from collections.abc import Iterator
32
from dataclasses import dataclass
4-
from itertools import chain, combinations
3+
from itertools import combinations
54
from typing import Annotated, Any
65

76
import pytest
@@ -261,16 +260,21 @@ class GeometryTypeCase:
261260
)
262261

263262

264-
def powerset(
265-
iterable: tuple[GeometryTypeCase, ...],
266-
) -> Iterator[tuple[GeometryTypeCase, ...]]:
267-
s = list(iterable)
268-
return chain.from_iterable(combinations(s, r) for r in range(len(s) + 1))
263+
def _representative_subsets(
264+
cases: tuple[GeometryTypeCase, ...],
265+
) -> tuple[tuple[GeometryTypeCase, ...], ...]:
266+
"""Select subsets that cover the constraint behavior without combinatorial explosion.
269267
268+
Singletons test each type accepted/rejected individually. Pairs test
269+
composition. The full set tests unconstrained acceptance.
270+
"""
271+
singletons = [(c,) for c in cases]
272+
pairs = list(combinations(cases, 2))
273+
full = [cases]
274+
return tuple(singletons + pairs + full)
270275

271-
TEST_GEOMETRY_TYPE_CASE_SUBSETS = tuple(
272-
s for s in powerset(TEST_GEOMETRY_TYPE_CASES) if len(s) > 0
273-
)
276+
277+
TEST_GEOMETRY_TYPE_CASE_SUBSETS = _representative_subsets(TEST_GEOMETRY_TYPE_CASES)
274278

275279

276280
@pytest.mark.parametrize("geometry_type_case_subset", TEST_GEOMETRY_TYPE_CASE_SUBSETS)

0 commit comments

Comments
 (0)