Skip to content

Commit f180ce6

Browse files
committed
avoid ever using different solc version than specified, also don't try to use solc-select to install solc on arm linux, issue ethereum#1512
1 parent 41c8ebd commit f180ce6

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/pytest_plugins/solc/solc.py

+22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Pytest plugin for configuring and installing the solc compiler."""
22

3+
import platform
4+
import subprocess
35
from argparse import ArgumentTypeError
46
from shutil import which
57

@@ -63,6 +65,12 @@ def pytest_configure(config: pytest.Config):
6365
except ArgumentTypeError:
6466
version = None
6567
if version != solc_version:
68+
# solc-select current does not support ARM linux
69+
if platform.system().lower() == "linux" and platform.machine().lower() == "aarch64":
70+
error_message = f"Version {version} does not match solc_version {solc_version}\
71+
and since solc-select currently does not support ARM linux we can not recover from this problem."
72+
pytest.exit(error_message, returncode=pytest.ExitCode.USAGE_ERROR)
73+
6674
if config.getoption("verbose") > 0:
6775
print(f"Setting solc version {solc_version} via solc-select...")
6876
try:
@@ -90,6 +98,20 @@ def pytest_configure(config: pytest.Config):
9098
)
9199
config.solc_version = solc_version_semver # type: ignore
92100

101+
# test whether solc_version matches actual one
102+
solc_version_check_result = subprocess.run(
103+
["solc", "--version"],
104+
stdout=subprocess.PIPE,
105+
stderr=subprocess.STDOUT,
106+
text=True,
107+
check=True,
108+
)
109+
solc_version_check_result_string = solc_version_check_result.stdout
110+
if str(solc_version_semver) not in solc_version_check_result_string:
111+
error_message = f"Expected solc version {solc_version_semver} but detected a\
112+
different solc version:\n{solc_version_check_result_string}\nCritical error, aborting.."
113+
pytest.exit(error_message, returncode=pytest.ExitCode.USAGE_ERROR)
114+
93115

94116
@pytest.fixture(autouse=True, scope="session")
95117
def solc_bin(request: pytest.FixtureRequest):

0 commit comments

Comments
 (0)