File tree Expand file tree Collapse file tree 2 files changed +27
-5
lines changed Expand file tree Collapse file tree 2 files changed +27
-5
lines changed Original file line number Diff line number Diff line change 7
7
8
8
def pytest_collection_modifyitems (config , items ):
9
9
"""Add the `benchmark` marker to all tests under `./tests/benchmark`."""
10
- for item in items :
11
- if Path (__file__ ).parent in Path (item .fspath ).parents :
12
- item .add_marker (pytest .mark .benchmark )
10
+ marker_expr = config .getoption ("-m" , default = "" )
11
+ gas_benchmark_values = config .getoption ("--gas-benchmark-values" , default = None )
12
+ run_benchmarks = marker_expr and (
13
+ "benchmark" in marker_expr and "not benchmark" not in marker_expr
14
+ )
15
+ if gas_benchmark_values :
16
+ run_benchmarks = True
17
+ items_for_removal = []
18
+ for i , item in enumerate (items ):
19
+ is_in_benchmark_dir = Path (__file__ ).parent in Path (item .fspath ).parents
20
+ has_benchmark_marker = item .get_closest_marker ("benchmark" ) is not None
21
+ is_benchmark_test = is_in_benchmark_dir or has_benchmark_marker
22
+ if is_benchmark_test :
23
+ if is_in_benchmark_dir and not has_benchmark_marker :
24
+ benchmark_marker = pytest .mark .benchmark
25
+
26
+ item .add_marker (benchmark_marker )
27
+ if not run_benchmarks :
28
+ items_for_removal .append (i )
29
+
30
+ elif run_benchmarks :
31
+ items_for_removal .append (i )
32
+
33
+ for i in reversed (items_for_removal ):
34
+ items .pop (i )
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ description = Fill test cases in ./tests/ for deployed mainnet forks, except for
83
83
setenv =
84
84
# Use custom EELS_RESOLUTIONS_FILE if it is set via the environment (eg, in CI)
85
85
EELS_RESOLUTIONS_FILE = {env:EELS_RESOLUTIONS_FILE:}
86
- commands = fill -n auto -m " not slow and not benchmark " --output =/tmp/fixtures-tox --clean
86
+ commands = fill -n auto -m " not slow" --output =/tmp/fixtures-tox --clean
87
87
88
88
[testenv:tests-deployed-benchmark]
89
89
description = Fill benchmarking test cases in ./tests/ for deployed mainnet forks, using evmone-t8n.
@@ -94,7 +94,7 @@ description = Fill test cases in ./tests/ for deployed and development mainnet f
94
94
setenv =
95
95
# Use custom EELS_RESOLUTIONS_FILE if it is set via the environment (eg, in CI)
96
96
EELS_RESOLUTIONS_FILE = {env:EELS_RESOLUTIONS_FILE:}
97
- commands = fill -n auto --until ={[forks]develop} -k " not slow and not benchmark " --output =/tmp/fixtures-tox --clean
97
+ commands = fill -n auto --until ={[forks]develop} -k " not slow" --output =/tmp/fixtures-tox --clean
98
98
99
99
# ----------------------------------------------------------------------------------------------
100
100
# ALIAS ENVIRONMENTS
You can’t perform that action at this time.
0 commit comments