|
1 | 1 | """Pytest plugin for configuring and installing the solc compiler."""
|
2 | 2 |
|
| 3 | +import platform |
| 4 | +import subprocess |
3 | 5 | from argparse import ArgumentTypeError
|
4 | 6 | from shutil import which
|
5 | 7 |
|
@@ -63,6 +65,18 @@ def pytest_configure(config: pytest.Config):
|
63 | 65 | except ArgumentTypeError:
|
64 | 66 | version = None
|
65 | 67 | 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 = ( |
| 71 | + f"Version {version} does not match solc_version {solc_version} " |
| 72 | + "and since solc-select currently does not support ARM linux you must " |
| 73 | + "manually do the following: " |
| 74 | + "Build solc from source, and manually move the binary to " |
| 75 | + ".venv/.solc-select/artifacts/solc-x.y.z/solc-x.y.z, then run " |
| 76 | + "'uv run solc-select use <x.y.z>'" |
| 77 | + ) |
| 78 | + pytest.exit(error_message, returncode=pytest.ExitCode.USAGE_ERROR) |
| 79 | + |
66 | 80 | if config.getoption("verbose") > 0:
|
67 | 81 | print(f"Setting solc version {solc_version} via solc-select...")
|
68 | 82 | try:
|
@@ -90,6 +104,27 @@ def pytest_configure(config: pytest.Config):
|
90 | 104 | )
|
91 | 105 | config.solc_version = solc_version_semver # type: ignore
|
92 | 106 |
|
| 107 | + # test whether solc_version matches actual one |
| 108 | + # using subprocess because that's how yul is compiled in |
| 109 | + # ./src/ethereum_test_specs/static_state/common/compile_yul.py |
| 110 | + expected_solc_version_string: str = str(solc_version_semver) |
| 111 | + actual_solc_version = subprocess.run( |
| 112 | + ["solc", "--version"], |
| 113 | + stdout=subprocess.PIPE, |
| 114 | + stderr=subprocess.STDOUT, |
| 115 | + text=True, |
| 116 | + check=True, |
| 117 | + ) |
| 118 | + actual_solc_version_string = actual_solc_version.stdout |
| 119 | + # use only look at first 10 chars to pass e.g. |
| 120 | + # actual: 0.8.25+commit.b61c2a91.Linux.g++ should pass with expected: "0.8.25+commit.b61c2a91 |
| 121 | + if ( |
| 122 | + expected_solc_version_string[:10] not in actual_solc_version_string |
| 123 | + ) or expected_solc_version_string == "": |
| 124 | + error_message = f"Expected solc version {solc_version_semver} but detected a\ |
| 125 | + different solc version:\n{actual_solc_version_string}\nCritical error, aborting.." |
| 126 | + pytest.exit(error_message, returncode=pytest.ExitCode.USAGE_ERROR) |
| 127 | + |
93 | 128 |
|
94 | 129 | @pytest.fixture(autouse=True, scope="session")
|
95 | 130 | def solc_bin(request: pytest.FixtureRequest):
|
|
0 commit comments