Skip to content

Commit 10b0323

Browse files
committed
refactor(filler): rename flags for consistency with class names
Rename command-line flags to align with function and class naming: - --generate-grouped-pre-allocs → --generate-pre-alloc-groups - --use-grouped-pre-allocs → --use-pre-alloc-groups This improves consistency with PreAllocGroups class and related method names throughout the codebase. Updated all flag definitions, config.getoption() calls, property names, and documentation.
1 parent 7c510bc commit 10b0323

File tree

6 files changed

+81
-83
lines changed

6 files changed

+81
-83
lines changed

docs/running_tests/test_formats/blockchain_test_engine_x.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The Blockchain Engine X Test fixture format tests are included in the fixtures subdirectory `blockchain_tests_engine_x`, and use Engine API directives with optimized pre-allocation groups for improved execution performance.
44

5-
These are produced by the `StateTest` and `BlockchainTest` test specs when using the `--generate-grouped-pre-allocs` and `--use-grouped-pre-allocs` flags.
5+
These are produced by the `StateTest` and `BlockchainTest` test specs when using the `--generate-pre-alloc-groups` and `--use-pre-alloc-groups` flags.
66

77
## Description
88

@@ -138,7 +138,7 @@ Engine API payload structure identical to the one defined in [Blockchain Engine
138138

139139
## Usage Notes
140140

141-
- This format is only generated when using `--generate-grouped-pre-allocs` and `--use-grouped-pre-allocs` flags
141+
- This format is only generated when using `--generate-pre-alloc-groups` and `--use-pre-alloc-groups` flags
142142
- The `pre_alloc` folder is essential and must be distributed with the test fixtures
143143
- Tests are grouped by identical (fork + environment + pre-allocation) combinations
144144
- The format is optimized for Engine API testing (post-Paris forks)

src/cli/pytest_commands/fill.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ def create_executions(self, pytest_args: List[str]) -> List[PytestExecution]:
2626
Create execution plan that supports two-phase pre-allocation group generation.
2727
2828
Returns single execution for normal filling, or two-phase execution
29-
when --generate-grouped-pre-allocs is specified.
29+
when --generate-pre-alloc-groups is specified.
3030
"""
3131
processed_args = self.process_arguments(pytest_args)
3232

3333
# Check if we need two-phase execution
34-
if "--generate-grouped-pre-allocs" in processed_args:
34+
if "--generate-pre-alloc-groups" in processed_args:
3535
return self._create_two_phase_executions(processed_args)
36-
elif "--use-grouped-pre-allocs" in processed_args:
36+
elif "--use-pre-alloc-groups" in processed_args:
3737
# Only phase 2: using existing pre-allocation groups
38-
return self._create_single_phase_with_grouped_pre_allocs(processed_args)
38+
return self._create_single_phase_with_pre_alloc_groups(processed_args)
3939
else:
4040
# Normal single-phase execution
4141
return [
@@ -66,9 +66,7 @@ def _create_two_phase_executions(self, args: List[str]) -> List[PytestExecution]
6666
),
6767
]
6868

69-
def _create_single_phase_with_grouped_pre_allocs(
70-
self, args: List[str]
71-
) -> List[PytestExecution]:
69+
def _create_single_phase_with_pre_alloc_groups(self, args: List[str]) -> List[PytestExecution]:
7270
"""Create single execution using existing pre-allocation groups."""
7371
return [
7472
PytestExecution(
@@ -84,18 +82,18 @@ def _create_phase1_args(self, args: List[str]) -> List[str]:
8482

8583
# Add required phase 1 flags (with quiet output by default)
8684
phase1_args = [
87-
"--generate-grouped-pre-allocs",
85+
"--generate-pre-alloc-groups",
8886
"-qq", # Quiet pytest output by default (user -v/-vv/-vvv can override)
8987
] + filtered_args
9088

9189
return phase1_args
9290

9391
def _create_phase2_args(self, args: List[str]) -> List[str]:
9492
"""Create arguments for phase 2 (fixture filling)."""
95-
# Remove --generate-grouped-pre-allocs and --clean, then add --use-grouped-pre-allocs
96-
phase2_args = self._remove_generate_grouped_pre_allocs_flag(args)
93+
# Remove --generate-pre-alloc-groups and --clean, then add --use-pre-alloc-groups
94+
phase2_args = self._remove_generate_pre_alloc_groups_flag(args)
9795
phase2_args = self._remove_clean_flag(phase2_args)
98-
phase2_args = self._add_use_grouped_pre_allocs_flag(phase2_args)
96+
phase2_args = self._add_use_pre_alloc_groups_flag(phase2_args)
9997
return phase2_args
10098

10199
def _remove_unwanted_phase1_args(self, args: List[str]) -> List[str]:
@@ -109,8 +107,8 @@ def _remove_unwanted_phase1_args(self, args: List[str]) -> List[str]:
109107
"-qq",
110108
"--tb",
111109
# Pre-allocation group flags (we'll add our own)
112-
"--generate-grouped-pre-allocs",
113-
"--use-grouped-pre-allocs",
110+
"--generate-pre-alloc-groups",
111+
"--use-pre-alloc-groups",
114112
}
115113

116114
filtered_args = []
@@ -134,17 +132,17 @@ def _remove_unwanted_phase1_args(self, args: List[str]) -> List[str]:
134132

135133
return filtered_args
136134

137-
def _remove_generate_grouped_pre_allocs_flag(self, args: List[str]) -> List[str]:
138-
"""Remove --generate-grouped-pre-allocs flag from argument list."""
139-
return [arg for arg in args if arg != "--generate-grouped-pre-allocs"]
135+
def _remove_generate_pre_alloc_groups_flag(self, args: List[str]) -> List[str]:
136+
"""Remove --generate-pre-alloc-groups flag from argument list."""
137+
return [arg for arg in args if arg != "--generate-pre-alloc-groups"]
140138

141139
def _remove_clean_flag(self, args: List[str]) -> List[str]:
142140
"""Remove --clean flag from argument list."""
143141
return [arg for arg in args if arg != "--clean"]
144142

145-
def _add_use_grouped_pre_allocs_flag(self, args: List[str]) -> List[str]:
146-
"""Add --use-grouped-pre-allocs flag to argument list."""
147-
return args + ["--use-grouped-pre-allocs"]
143+
def _add_use_pre_alloc_groups_flag(self, args: List[str]) -> List[str]:
144+
"""Add --use-pre-alloc-groups flag to argument list."""
145+
return args + ["--use-pre-alloc-groups"]
148146

149147

150148
class PhilCommand(FillCommand):

src/cli/show_pre_alloc_group_stats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ def main(pre_alloc_folder: Path, verbose: int):
473473
- Number of groups and tests per test module (tabulated)
474474
475475
The pre_alloc file is generated when running tests with the
476-
--generate-grouped-pre-allocs and --use-grouped-pre-allocs flags to optimize
476+
--generate-pre-alloc-groups and --use-pre-alloc-groups flags to optimize
477477
test execution by grouping tests with identical pre-allocation state.
478478
479479
"""

src/pytest_plugins/filler/filler.py

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -242,16 +242,16 @@ def pytest_addoption(parser: pytest.Parser):
242242
),
243243
)
244244
test_group.addoption(
245-
"--generate-grouped-pre-allocs",
245+
"--generate-pre-alloc-groups",
246246
action="store_true",
247-
dest="generate_grouped_pre_allocs",
247+
dest="generate_pre_alloc_groups",
248248
default=False,
249249
help="Generate pre-allocation groups (phase 1 only).",
250250
)
251251
test_group.addoption(
252-
"--use-grouped-pre-allocs",
252+
"--use-pre-alloc-groups",
253253
action="store_true",
254-
dest="use_grouped_pre_allocs",
254+
dest="use_pre_alloc_groups",
255255
default=False,
256256
help="Fill tests using existing pre-allocation groups (phase 2 only).",
257257
)
@@ -286,20 +286,20 @@ def pytest_sessionstart(session: pytest.Session):
286286
load the pre-allocation groups for phase 2 execution.
287287
"""
288288
# Initialize empty pre-allocation groups container for phase 1
289-
if session.config.getoption("generate_grouped_pre_allocs"):
290-
session.config.grouped_pre_allocs = PreAllocGroups(root={}) # type: ignore[attr-defined]
289+
if session.config.getoption("generate_pre_alloc_groups"):
290+
session.config.pre_alloc_groups = PreAllocGroups(root={}) # type: ignore[attr-defined]
291291

292292
# Load the pre-allocation groups for phase 2
293-
if session.config.getoption("use_grouped_pre_allocs"):
294-
grouped_pre_allocs_folder = session.config.fixture_output.grouped_pre_allocs_folder_path # type: ignore[attr-defined]
295-
if grouped_pre_allocs_folder.exists():
296-
session.config.grouped_pre_allocs = PreAllocGroups.from_folder( # type: ignore[attr-defined]
297-
grouped_pre_allocs_folder
293+
if session.config.getoption("use_pre_alloc_groups"):
294+
pre_alloc_groups_folder = session.config.fixture_output.pre_alloc_groups_folder_path # type: ignore[attr-defined]
295+
if pre_alloc_groups_folder.exists():
296+
session.config.pre_alloc_groups = PreAllocGroups.from_folder( # type: ignore[attr-defined]
297+
pre_alloc_groups_folder
298298
)
299299
else:
300300
pytest.exit(
301-
f"Pre-allocation groups folder not found: {grouped_pre_allocs_folder}. "
302-
"Run phase 1 with --generate-grouped-pre-allocs first.",
301+
f"Pre-allocation groups folder not found: {pre_alloc_groups_folder}. "
302+
"Run phase 1 with --generate-pre-alloc-groups first.",
303303
returncode=pytest.ExitCode.USAGE_ERROR,
304304
)
305305

@@ -339,7 +339,7 @@ def pytest_configure(config):
339339
if (
340340
not config.getoption("disable_html")
341341
and config.getoption("htmlpath") is None
342-
and not config.getoption("generate_grouped_pre_allocs")
342+
and not config.getoption("generate_pre_alloc_groups")
343343
):
344344
config.option.htmlpath = config.fixture_output.directory / default_html_report_file_path()
345345

@@ -416,21 +416,21 @@ def pytest_terminal_summary(
416416
stats = terminalreporter.stats
417417
if "passed" in stats and stats["passed"]:
418418
# Custom message for Phase 1 (pre-allocation group generation)
419-
if config.getoption("generate_grouped_pre_allocs"):
419+
if config.getoption("generate_pre_alloc_groups"):
420420
# Generate summary stats
421-
grouped_pre_allocs: PreAllocGroups
421+
pre_alloc_groups: PreAllocGroups
422422
if config.pluginmanager.hasplugin("xdist"):
423423
# Load pre-allocation groups from disk
424-
grouped_pre_allocs = PreAllocGroups.from_folder(
425-
config.fixture_output.grouped_pre_allocs_folder_path # type: ignore[attr-defined]
424+
pre_alloc_groups = PreAllocGroups.from_folder(
425+
config.fixture_output.pre_alloc_groups_folder_path # type: ignore[attr-defined]
426426
)
427427
else:
428-
assert hasattr(config, "grouped_pre_allocs")
429-
grouped_pre_allocs = config.grouped_pre_allocs # type: ignore[attr-defined]
428+
assert hasattr(config, "pre_alloc_groups")
429+
pre_alloc_groups = config.pre_alloc_groups # type: ignore[attr-defined]
430430

431-
total_groups = len(grouped_pre_allocs.root)
431+
total_groups = len(pre_alloc_groups.root)
432432
total_accounts = sum(
433-
group.pre_account_count for group in grouped_pre_allocs.root.values()
433+
group.pre_account_count for group in pre_alloc_groups.root.values()
434434
)
435435

436436
terminalreporter.write_sep(
@@ -881,32 +881,32 @@ def __init__(self, *args, **kwargs):
881881

882882
# Phase 1: Generate pre-allocation groups
883883
if fixture_format is BlockchainEngineXFixture and request.config.getoption(
884-
"generate_grouped_pre_allocs"
884+
"generate_pre_alloc_groups"
885885
):
886886
self.update_pre_alloc_groups(
887-
request.config.grouped_pre_allocs, fork, request.node.nodeid
887+
request.config.pre_alloc_groups, fork, request.node.nodeid
888888
)
889889
return # Skip fixture generation in phase 1
890890

891891
# Phase 2: Use pre-allocation groups (only for BlockchainEngineXFixture)
892892
pre_alloc_hash = None
893893
if fixture_format is BlockchainEngineXFixture and request.config.getoption(
894-
"use_grouped_pre_allocs"
894+
"use_pre_alloc_groups"
895895
):
896896
pre_alloc_hash = self.compute_pre_alloc_group_hash(fork=fork)
897-
if pre_alloc_hash not in request.config.grouped_pre_allocs:
897+
if pre_alloc_hash not in request.config.pre_alloc_groups:
898898
pre_alloc_path = (
899-
request.config.fixture_output.grouped_pre_allocs_folder_path
899+
request.config.fixture_output.pre_alloc_groups_folder_path
900900
/ pre_alloc_hash
901901
)
902902
raise ValueError(
903903
f"Pre-allocation hash {pre_alloc_hash} not found in "
904904
f"pre-allocation groups. "
905905
f"Please check the pre-allocation groups file at: {pre_alloc_path}. "
906-
"Make sure phase 1 (--generate-grouped-pre-allocs) was run "
906+
"Make sure phase 1 (--generate-pre-alloc-groups) was run "
907907
"before phase 2."
908908
)
909-
group: PreAllocGroup = request.config.grouped_pre_allocs[pre_alloc_hash]
909+
group: PreAllocGroup = request.config.pre_alloc_groups[pre_alloc_hash]
910910
self.pre = group.pre
911911

912912
fixture = self.generate(
@@ -918,14 +918,14 @@ def __init__(self, *args, **kwargs):
918918
# Post-process for Engine X format (add pre_hash and state diff)
919919
if (
920920
fixture_format is BlockchainEngineXFixture
921-
and request.config.getoption("use_grouped_pre_allocs")
921+
and request.config.getoption("use_pre_alloc_groups")
922922
and pre_alloc_hash is not None
923923
):
924924
fixture.pre_hash = pre_alloc_hash
925925

926926
# Calculate state diff for efficiency
927927
if hasattr(fixture, "post_state") and fixture.post_state is not None:
928-
group = request.config.grouped_pre_allocs[pre_alloc_hash]
928+
group = request.config.pre_alloc_groups[pre_alloc_hash]
929929
fixture.post_state_diff = calculate_post_state_diff(
930930
fixture.post_state, group.pre
931931
)
@@ -968,12 +968,12 @@ def pytest_generate_tests(metafunc: pytest.Metafunc):
968968
"""
969969
for test_type in BaseTest.spec_types.values():
970970
if test_type.pytest_parameter_name() in metafunc.fixturenames:
971-
generate_grouped_pre_allocs = metafunc.config.getoption(
972-
"generate_grouped_pre_allocs", False
971+
generate_pre_alloc_groups = metafunc.config.getoption(
972+
"generate_pre_alloc_groups", False
973973
)
974-
use_grouped_pre_allocs = metafunc.config.getoption("use_grouped_pre_allocs", False)
974+
use_pre_alloc_groups = metafunc.config.getoption("use_pre_alloc_groups", False)
975975

976-
if generate_grouped_pre_allocs or use_grouped_pre_allocs:
976+
if generate_pre_alloc_groups or use_pre_alloc_groups:
977977
# When pre-allocation group flags are set, only generate BlockchainEngineXFixture
978978
supported_formats = [
979979
format_item
@@ -1080,12 +1080,12 @@ def pytest_sessionfinish(session: pytest.Session, exitstatus: int):
10801080
"""
10811081
# Save pre-allocation groups after phase 1
10821082
fixture_output = session.config.fixture_output # type: ignore[attr-defined]
1083-
if session.config.getoption("generate_grouped_pre_allocs") and hasattr(
1084-
session.config, "grouped_pre_allocs"
1083+
if session.config.getoption("generate_pre_alloc_groups") and hasattr(
1084+
session.config, "pre_alloc_groups"
10851085
):
1086-
grouped_pre_allocs_folder = fixture_output.grouped_pre_allocs_folder_path
1087-
grouped_pre_allocs_folder.mkdir(parents=True, exist_ok=True)
1088-
session.config.grouped_pre_allocs.to_folder(grouped_pre_allocs_folder)
1086+
pre_alloc_groups_folder = fixture_output.pre_alloc_groups_folder_path
1087+
pre_alloc_groups_folder.mkdir(parents=True, exist_ok=True)
1088+
session.config.pre_alloc_groups.to_folder(pre_alloc_groups_folder)
10891089
return
10901090

10911091
if xdist.is_xdist_worker(session):
@@ -1100,7 +1100,7 @@ def pytest_sessionfinish(session: pytest.Session, exitstatus: int):
11001100

11011101
# Generate index file for all produced fixtures.
11021102
if session.config.getoption("generate_index") and not session.config.getoption(
1103-
"generate_grouped_pre_allocs"
1103+
"generate_pre_alloc_groups"
11041104
):
11051105
generate_fixtures_index(
11061106
fixture_output.directory, quiet_mode=True, force_flag=False, disable_infer_format=False

0 commit comments

Comments
 (0)