Skip to content

Commit 644bfc8

Browse files
committed
test: make bench optional, add targets in makefiles for test types
1 parent fa08118 commit 644bfc8

3 files changed

Lines changed: 48 additions & 4 deletions

File tree

‎Makefile‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
.PHONY: default install format fix ruff-check mypy-check check test doc publish clean
1+
.PHONY: default install format fix ruff-check mypy-check check benchmark-test integration-test property-test unit-test test doc publish clean
22

33
UV := $(shell command -v uv 2>/dev/null || true)
44
ifeq ($(UV),)
55
$(warning uv not found. Install uv (curl -LsSf https://astral.sh/uv/install.sh | sh) to use Makefile targets)
66
endif
77

88
default:
9-
@echo "Usage: make [install|format|fix|ruff-check|mypy-check|check|test|doc|publish|clean]"
9+
@echo "Usage: make [install|format|fix|ruff-check|mypy-check|check|benchmark-test|integration-test|property-test|unit-test|test|doc|publish|clean]"
1010
@exit 1
1111

1212
install:
@@ -29,6 +29,18 @@ check:
2929
make ruff-check
3030
make mypy-check
3131

32+
benchmark-test:
33+
uv run --group tests --locked pytest -m perf
34+
35+
integration-test:
36+
uv run --group tests --locked pytest -m integration
37+
38+
property-test:
39+
uv run --group tests --locked pytest -m property
40+
41+
unit-test:
42+
uv run --group tests --locked pytest -m unit
43+
3244
test:
3345
uv run --group tests --locked pytest
3446

‎make.bat‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ if "%1"=="fix" goto fix
1313
if "%1"=="ruff-check" goto ruff-check
1414
if "%1"=="mypy-check" goto mypy-check
1515
if "%1"=="check" goto check
16+
if "%1"=="benchmark-test" goto benchmark-test
17+
if "%1"=="integration-test" goto integration-test
18+
if "%1"=="property-test" goto property-test
19+
if "%1"=="unit-test" goto unit-test
1620
if "%1"=="test" goto test
1721
if "%1"=="doc" goto doc
1822
if "%1"=="publish" goto publish
1923
if "%1"=="clean" goto clean
2024

21-
echo Usage: make.bat [install^|format^|fix^|ruff-check^|mypy-check^|check^|test^|doc^|publish^|clean]
25+
echo Usage: make.bat [install^|format^|fix^|ruff-check^|mypy-check^|check^|benchmark-test^|integration-test^|property-test^|unit-test^|test^|doc^|publish^|clean]
2226
exit /b 1
2327

2428
:install
@@ -50,6 +54,22 @@ if errorlevel 1 exit /b %errorlevel%
5054
call :mypy-check
5155
exit /b %errorlevel%
5256

57+
:benchmark-test
58+
uv run --group tests --locked pytest -m perf
59+
exit /b %errorlevel%
60+
61+
:integration-test
62+
uv run --group tests --locked pytest -m integration
63+
exit /b %errorlevel%
64+
65+
:property-test
66+
uv run --group tests --locked pytest -m property
67+
exit /b %errorlevel%
68+
69+
:unit-test
70+
uv run --group tests --locked pytest -m unit
71+
exit /b %errorlevel%
72+
5373
:test
5474
uv run --group tests --locked pytest
5575
exit /b %errorlevel%

‎tests/benchmarks/conftest.py‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,22 @@
88

99

1010
def pytest_collection_modifyitems(
11+
config: pytest.Config,
1112
items: list[pytest.Item],
1213
) -> None:
13-
"""Apply the 'perf' marker to all tests collected from this directory."""
14+
"""Apply the 'perf' marker to all tests collected from this directory.
15+
16+
Benchmarks require a running JVM and are slow, so they're opt-in: skipped
17+
unless explicitly selected with ``-m perf`` (or a markexpr referencing it).
18+
"""
1419
benchmarks_dir = Path(__file__).parent
20+
markexpr: str = config.getoption("markexpr")
21+
run_perf = "perf" in markexpr
22+
skip_perf = pytest.mark.skip(
23+
reason="Benchmarks are opt-in, run with -m perf to include them."
24+
)
1525
for item in items:
1626
if item.path.is_relative_to(benchmarks_dir):
1727
item.add_marker(pytest.mark.perf)
28+
if not run_perf:
29+
item.add_marker(skip_perf)

0 commit comments

Comments
 (0)