|
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,12 @@ 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 = 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 | + |
66 | 74 | if config.getoption("verbose") > 0: |
67 | 75 | print(f"Setting solc version {solc_version} via solc-select...") |
68 | 76 | try: |
@@ -90,6 +98,20 @@ def pytest_configure(config: pytest.Config): |
90 | 98 | ) |
91 | 99 | config.solc_version = solc_version_semver # type: ignore |
92 | 100 |
|
| 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 | + |
93 | 115 |
|
94 | 116 | @pytest.fixture(autouse=True, scope="session") |
95 | 117 | def solc_bin(request: pytest.FixtureRequest): |
|
0 commit comments