Skip to content

Commit 7945e85

Browse files
refactor: update filter logic
1 parent 1e99293 commit 7945e85

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

packages/testing/src/execution_testing/cli/pytest_commands/plugins/shared/benchmarking.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,19 @@ def pytest_configure(config: pytest.Config) -> None:
4444
def pytest_collection_modifyitems(
4545
config: pytest.Config, items: list[pytest.Item]
4646
) -> None:
47-
"""Remove non-repricing tests when --fixed-opcode-count is specified."""
47+
"""
48+
Filter tests based on repricing marker when both -m repricing and
49+
benchmark flags are specified.
50+
"""
51+
gas_benchmark_value = config.getoption("gas_benchmark_value")
4852
fixed_opcode_count = config.getoption("fixed_opcode_count")
49-
if not fixed_opcode_count:
50-
# If --fixed-opcode-count is not specified, don't filter anything
53+
54+
if not gas_benchmark_value and not fixed_opcode_count:
55+
return
56+
57+
# Check if -m repricing marker filter was specified
58+
markexpr = config.getoption("markexpr", "")
59+
if "repricing" not in markexpr:
5160
return
5261

5362
filtered = []

packages/testing/src/execution_testing/specs/benchmark.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ def model_post_init(self, __context: Any, /) -> None:
250250

251251
blocks: List[Block] = self.setup_blocks
252252

253+
if self.fixed_opcode_count is not None and self.code_generator is None:
254+
pytest.skip(
255+
"Cannot run fixed opcode count tests without a code generator"
256+
)
257+
253258
if self.code_generator is not None:
254259
# Inject fixed_opcode_count into the code generator if provided
255260
self.code_generator.fixed_opcode_count = self.fixed_opcode_count

tests/benchmark/conftest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ def pytest_collection_modifyitems(config: Any, items: Any) -> None:
4949
return
5050

5151
marker_expr = config.getoption("-m", default="")
52+
5253
run_benchmarks = (
53-
marker_expr
54-
and "benchmark" in marker_expr
55-
and "not benchmark" not in marker_expr
54+
not marker_expr
55+
or ("benchmark" in marker_expr and "not benchmark" not in marker_expr)
56+
or ("repricing" in marker_expr and "not repricing" not in marker_expr)
5657
)
5758
run_stateful_tests = (
5859
marker_expr

0 commit comments

Comments
 (0)