Skip to content

Commit 9aa6e89

Browse files
committed
removed solc dependency (#1759)
1 parent bb4289a commit 9aa6e89

File tree

11 files changed

+274
-222
lines changed

11 files changed

+274
-222
lines changed

pytest-check-eip-versions.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ addopts =
1111
-p pytest_plugins.spec_version_checker.spec_version_checker
1212
-p pytest_plugins.concurrency
1313
-p pytest_plugins.filler.pre_alloc
14-
-p pytest_plugins.solc.solc
1514
-p pytest_plugins.filler.filler
1615
-p pytest_plugins.shared.execute_fill
1716
-p pytest_plugins.forks.forks

pytest-execute-hive.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ addopts =
1111
-p pytest_plugins.concurrency
1212
-p pytest_plugins.execute.sender
1313
-p pytest_plugins.execute.pre_alloc
14-
-p pytest_plugins.solc.solc
1514
-p pytest_plugins.execute.rpc.hive
1615
-p pytest_plugins.execute.execute
1716
-p pytest_plugins.shared.execute_fill

pytest-execute.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ addopts =
1212
-p pytest_plugins.concurrency
1313
-p pytest_plugins.execute.sender
1414
-p pytest_plugins.execute.pre_alloc
15-
-p pytest_plugins.solc.solc
1615
-p pytest_plugins.execute.execute
1716
-p pytest_plugins.shared.execute_fill
1817
-p pytest_plugins.execute.rpc.remote_seed_sender

pytest.ini

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ markers =
1111
addopts =
1212
-p pytest_plugins.concurrency
1313
-p pytest_plugins.filler.pre_alloc
14-
-p pytest_plugins.solc.solc
1514
-p pytest_plugins.filler.filler
16-
-p pytest_plugins.filler.static_filler
1715
-p pytest_plugins.filler.ported_tests
1816
-p pytest_plugins.shared.execute_fill
1917
-p pytest_plugins.forks.forks

src/ethereum_test_tools/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@
8282
Initcode,
8383
Switch,
8484
While,
85-
Yul,
86-
YulCompiler,
8785
)
8886
from .utility.generators import (
8987
DeploymentTestType,
@@ -157,8 +155,6 @@
157155
"While",
158156
"Withdrawal",
159157
"WithdrawalRequest",
160-
"Yul",
161-
"YulCompiler",
162158
"add_kzg_version",
163159
"call_return_code",
164160
"ceiling_division",

src/pytest_plugins/filler/filler.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,11 @@ def fixture_collector(
764764
Return configured fixture collector instance used for all tests
765765
in one test module.
766766
"""
767+
# Dynamically load the 'static_filler' and 'solc' plugins if needed
768+
if request.config.getoption("fill_static_tests_enabled"):
769+
request.config.pluginmanager.import_plugin("pytest_plugins.filler.static_filler")
770+
request.config.pluginmanager.import_plugin("pytest_plugins.solc.solc")
771+
767772
fixture_collector = FixtureCollector(
768773
output_dir=fixture_output.directory,
769774
flat_output=fixture_output.flat_output,

src/pytest_plugins/filler/static_filler.py

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@
1717
from _pytest.python import Module
1818

1919
from ethereum_test_fixtures import BaseFixture, LabeledFixtureFormat
20-
from ethereum_test_forks import Fork
20+
from ethereum_test_forks import (
21+
Fork,
22+
get_closest_fork_with_solc_support,
23+
get_forks_with_solc_support,
24+
)
2125
from ethereum_test_specs import BaseStaticTest, BaseTest
26+
from ethereum_test_tools.code.yul import Yul
2227

2328
from ..forks.forks import ValidityMarker, get_intersection_set
2429
from ..shared.helpers import labeled_format_parameter_set
@@ -109,18 +114,6 @@ def get_all_combinations_from_parametrize_marks(
109114
return all_argument_names, all_value_combinations
110115

111116

112-
def pytest_addoption(parser: pytest.Parser):
113-
"""Add command-line options to pytest."""
114-
static_filler_group = parser.getgroup("static", "Arguments defining static filler behavior")
115-
static_filler_group.addoption(
116-
"--fill-static-tests",
117-
action="store_true",
118-
dest="fill_static_tests_enabled",
119-
default=None,
120-
help=("Enable reading and filling from static test files."),
121-
)
122-
123-
124117
def pytest_collect_file(file_path: Path, parent) -> pytest.Collector | None:
125118
"""Pytest hook that collects test cases from static files and fills them into test fixtures."""
126119
fill_static_tests_enabled = parent.config.getoption("fill_static_tests_enabled")
@@ -334,3 +327,46 @@ def runtest(self):
334327
def reportinfo(self):
335328
"""Provide information for test reporting."""
336329
return self.fspath, 0, f"Static file test: {self.name}"
330+
331+
332+
@pytest.fixture
333+
def yul(fork: Fork, request: pytest.FixtureRequest):
334+
"""
335+
Fixture that allows contract code to be defined with Yul code.
336+
337+
This fixture defines a class that wraps the ::ethereum_test_tools.Yul
338+
class so that upon instantiation within the test case, it provides the
339+
test case's current fork parameter. The forks is then available for use
340+
in solc's arguments for the Yul code compilation.
341+
342+
Test cases can override the default value by specifying a fixed version
343+
with the @pytest.mark.compile_yul_with(FORK) marker.
344+
"""
345+
solc_target_fork: Fork | None
346+
marker = request.node.get_closest_marker("compile_yul_with")
347+
assert hasattr(request.config, "solc_version"), "solc_version not set in pytest config."
348+
if marker:
349+
if not marker.args[0]:
350+
pytest.fail(
351+
f"{request.node.name}: Expected one argument in 'compile_yul_with' marker."
352+
)
353+
for fork in request.config.all_forks: # type: ignore
354+
if fork.name() == marker.args[0]:
355+
solc_target_fork = fork
356+
break
357+
else:
358+
pytest.fail(f"{request.node.name}: Fork {marker.args[0]} not found in forks list.")
359+
assert solc_target_fork in get_forks_with_solc_support(request.config.solc_version)
360+
else:
361+
solc_target_fork = get_closest_fork_with_solc_support(fork, request.config.solc_version)
362+
assert solc_target_fork is not None, "No fork supports provided solc version."
363+
if solc_target_fork != fork and request.config.getoption("verbose") >= 1:
364+
warnings.warn(
365+
f"Compiling Yul for {solc_target_fork.name()}, not {fork.name()}.", stacklevel=2
366+
)
367+
368+
class YulWrapper(Yul):
369+
def __new__(cls, *args, **kwargs):
370+
return super(YulWrapper, cls).__new__(cls, *args, **kwargs, fork=solc_target_fork)
371+
372+
return YulWrapper

src/pytest_plugins/shared/execute_fill.py

Lines changed: 12 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
"""Shared pytest fixtures and hooks for EEST generation modes (fill and execute)."""
22

3-
import warnings
43
from typing import List
54

65
import pytest
76

87
from ethereum_test_execution import BaseExecute, LabeledExecuteFormat
98
from ethereum_test_fixtures import BaseFixture, LabeledFixtureFormat
10-
from ethereum_test_forks import (
11-
Fork,
12-
get_closest_fork_with_solc_support,
13-
get_forks_with_solc_support,
14-
)
159
from ethereum_test_specs import BaseTest
16-
from ethereum_test_tools import Yul
1710
from pytest_plugins.spec_version_checker.spec_version_checker import EIPSpecTestItem
1811

1912

@@ -102,49 +95,6 @@ def pytest_configure(config: pytest.Config):
10295
)
10396

10497

105-
@pytest.fixture
106-
def yul(fork: Fork, request: pytest.FixtureRequest):
107-
"""
108-
Fixture that allows contract code to be defined with Yul code.
109-
110-
This fixture defines a class that wraps the ::ethereum_test_tools.Yul
111-
class so that upon instantiation within the test case, it provides the
112-
test case's current fork parameter. The forks is then available for use
113-
in solc's arguments for the Yul code compilation.
114-
115-
Test cases can override the default value by specifying a fixed version
116-
with the @pytest.mark.compile_yul_with(FORK) marker.
117-
"""
118-
solc_target_fork: Fork | None
119-
marker = request.node.get_closest_marker("compile_yul_with")
120-
assert hasattr(request.config, "solc_version"), "solc_version not set in pytest config."
121-
if marker:
122-
if not marker.args[0]:
123-
pytest.fail(
124-
f"{request.node.name}: Expected one argument in 'compile_yul_with' marker."
125-
)
126-
for fork in request.config.all_forks: # type: ignore
127-
if fork.name() == marker.args[0]:
128-
solc_target_fork = fork
129-
break
130-
else:
131-
pytest.fail(f"{request.node.name}: Fork {marker.args[0]} not found in forks list.")
132-
assert solc_target_fork in get_forks_with_solc_support(request.config.solc_version)
133-
else:
134-
solc_target_fork = get_closest_fork_with_solc_support(fork, request.config.solc_version)
135-
assert solc_target_fork is not None, "No fork supports provided solc version."
136-
if solc_target_fork != fork and request.config.getoption("verbose") >= 1:
137-
warnings.warn(
138-
f"Compiling Yul for {solc_target_fork.name()}, not {fork.name()}.", stacklevel=2
139-
)
140-
141-
class YulWrapper(Yul):
142-
def __new__(cls, *args, **kwargs):
143-
return super(YulWrapper, cls).__new__(cls, *args, **kwargs, fork=solc_target_fork)
144-
145-
return YulWrapper
146-
147-
14898
@pytest.fixture(scope="function")
14999
def test_case_description(request: pytest.FixtureRequest) -> str:
150100
"""Fixture to extract and combine docstrings from the test class and the test function."""
@@ -198,3 +148,15 @@ def __init__(self, message):
198148
+ "properly generate a test: "
199149
+ ", ".join(SPEC_TYPES_PARAMETERS)
200150
)
151+
152+
153+
def pytest_addoption(parser: pytest.Parser):
154+
"""Add command-line options to pytest."""
155+
static_filler_group = parser.getgroup("static", "Arguments defining static filler behavior")
156+
static_filler_group.addoption(
157+
"--fill-static-tests",
158+
action="store_true",
159+
dest="fill_static_tests_enabled",
160+
default=None,
161+
help=("Enable reading and filling from static test files."),
162+
)

0 commit comments

Comments
 (0)