diff --git a/packages/testing/src/execution_testing/cli/pytest_commands/plugins/shared/benchmarking.py b/packages/testing/src/execution_testing/cli/pytest_commands/plugins/shared/benchmarking.py index f7f071d488..cf73f72e1b 100644 --- a/packages/testing/src/execution_testing/cli/pytest_commands/plugins/shared/benchmarking.py +++ b/packages/testing/src/execution_testing/cli/pytest_commands/plugins/shared/benchmarking.py @@ -44,10 +44,19 @@ def pytest_configure(config: pytest.Config) -> None: def pytest_collection_modifyitems( config: pytest.Config, items: list[pytest.Item] ) -> None: - """Remove non-repricing tests when --fixed-opcode-count is specified.""" + """ + Filter tests based on repricing marker when both -m repricing and + benchmark flags are specified. + """ + gas_benchmark_value = config.getoption("gas_benchmark_value") fixed_opcode_count = config.getoption("fixed_opcode_count") - if not fixed_opcode_count: - # If --fixed-opcode-count is not specified, don't filter anything + + if not gas_benchmark_value and not fixed_opcode_count: + return + + # Check if -m repricing marker filter was specified + markexpr = config.getoption("markexpr", "") + if "repricing" not in markexpr: return filtered = [] diff --git a/packages/testing/src/execution_testing/specs/benchmark.py b/packages/testing/src/execution_testing/specs/benchmark.py index eac5bebbb3..e541a6a3ff 100644 --- a/packages/testing/src/execution_testing/specs/benchmark.py +++ b/packages/testing/src/execution_testing/specs/benchmark.py @@ -250,6 +250,11 @@ def model_post_init(self, __context: Any, /) -> None: blocks: List[Block] = self.setup_blocks + if self.fixed_opcode_count is not None and self.code_generator is None: + pytest.skip( + "Cannot run fixed opcode count tests without a code generator" + ) + if self.code_generator is not None: # Inject fixed_opcode_count into the code generator if provided self.code_generator.fixed_opcode_count = self.fixed_opcode_count diff --git a/tests/benchmark/conftest.py b/tests/benchmark/conftest.py index c4f711c362..462e65035a 100755 --- a/tests/benchmark/conftest.py +++ b/tests/benchmark/conftest.py @@ -49,11 +49,10 @@ def pytest_collection_modifyitems(config: Any, items: Any) -> None: return marker_expr = config.getoption("-m", default="") + run_benchmarks = ( - marker_expr - and "benchmark" in marker_expr - and "not benchmark" not in marker_expr - ) + "benchmark" in marker_expr and "not benchmark" not in marker_expr + ) or ("repricing" in marker_expr and "not repricing" not in marker_expr) run_stateful_tests = ( marker_expr and "stateful" in marker_expr