Skip to content

fix(unittests): arm workaround for running unit tests (Issue #1682) #1684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions src/ethereum_test_tools/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Common pytest fixtures for ethereum_test_tools tests."""

from pathlib import Path

import pytest
from semver import Version

Expand All @@ -10,10 +12,36 @@
SOLC_PADDING_VERSION = Version.parse("0.8.21")


def get_eest_root_folder(marker_files=("pyproject.toml", ".git", "tests", "src")) -> Path:
"""Search for a folder where all files/folders listed above exist (root of project)."""
current = Path(__file__).resolve()
for parent in current.parents:
if all((parent / marker).exists() for marker in marker_files):
return parent
raise RuntimeError("Project root folder of execution-spec-tests was not found")


@pytest.fixture(scope="session")
def solc_version() -> Version:
"""Return the version of solc being used for tests."""
solc_version = Solc("").version.finalize_version()
if solc_version < Frontier.solc_min_version():
raise Exception("Unsupported solc version: {}".format(solc_version))

solc_version_in_use = None

# on ARM systems that manually compiled solc this can be 0.0.0, so try to recover
if str(solc_version) == "0.0.0":
# determine solc version used by solc-select
# get eest root folder path
eest_root: Path = get_eest_root_folder()
# get path of solc-select global-version file (stores currently in use solc version)
solc_version_file_path = eest_root / ".venv" / ".solc-select" / "global-version"
# read this file if it exists
if solc_version_file_path.exists():
solc_version_in_use = Version.parse(solc_version_file_path.read_text())
Comment on lines +33 to +40
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you try to directly import solc-select and use the current_version method to see if it resolves to the global-version in this case?

from solc_select import solc_select
...
ss.current_version()

returns in my case:

('0.8.24', '/path/to/execution-spec-tests/.venv/.solc-select/global-version')


if solc_version < Frontier.solc_min_version() and solc_version_in_use is None:
raise Exception(f"Unsupported solc version: {solc_version}")

if solc_version_in_use is not None:
return solc_version_in_use
return solc_version
36 changes: 19 additions & 17 deletions src/pytest_plugins/solc/solc.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,25 @@ def pytest_configure(config: pytest.Config):
# test whether solc_version matches actual one
# using subprocess because that's how yul is compiled in
# ./src/ethereum_test_specs/static_state/common/compile_yul.py
expected_solc_version_string: str = str(solc_version_semver)
actual_solc_version = subprocess.run(
["solc", "--version"],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
check=True,
)
actual_solc_version_string = actual_solc_version.stdout
# use only look at first 10 chars to pass e.g.
# actual: 0.8.25+commit.b61c2a91.Linux.g++ should pass with expected: "0.8.25+commit.b61c2a91
if (
expected_solc_version_string[:10] not in actual_solc_version_string
) or expected_solc_version_string == "":
error_message = f"Expected solc version {solc_version_semver} but detected a\
different solc version:\n{actual_solc_version_string}\nCritical error, aborting.."
pytest.exit(error_message, returncode=pytest.ExitCode.USAGE_ERROR)


# expected_solc_version_string: str = str(solc_version_semver)
# actual_solc_version = subprocess.run(
# ["solc", "--version"],
# stdout=subprocess.PIPE,
# stderr=subprocess.STDOUT,
# text=True,
# check=True,
# )
# actual_solc_version_string = actual_solc_version.stdout
# # use only look at first 10 chars to pass e.g.
# # actual: 0.8.25+commit.b61c2a91.Linux.g++ should pass with expected: "0.8.25+commit.b61c2a91
# if (
# expected_solc_version_string[:10] not in actual_solc_version_string
# ) or expected_solc_version_string == "":
# error_message = f"Expected solc version {solc_version_semver} but detected a\
# different solc version:\n{actual_solc_version_string}\nCritical error, aborting.."
# pytest.exit(error_message, returncode=pytest.ExitCode.USAGE_ERROR)


@pytest.fixture(autouse=True, scope="session")
Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ setenv =
extras =
test
lint # Required `gentest` for formatting tests
commands_pre = solc-select use {[testenv]solc_version} --always-install
commands_pre = solc-select use {[testenv]solc_version}
commands =
pytest -c ./pytest-framework.ini -n auto -m "not run_in_serial"
pytest -c ./pytest-framework.ini -m run_in_serial
Expand All @@ -76,20 +76,20 @@ description = Fill test cases in ./tests/ for deployed mainnet forks, except for
setenv =
# Use custom EELS_RESOLUTIONS_FILE if it is set via the environment (eg, in CI)
EELS_RESOLUTIONS_FILE = {env:EELS_RESOLUTIONS_FILE:}
commands_pre = solc-select use {[testenv]solc_version} --always-install
commands_pre = solc-select use {[testenv]solc_version}
commands = pytest -n auto -m "not slow and not zkevm" --skip-evm-dump --output=/tmp/fixtures-tox --clean

[testenv:tests-deployed-zkevm]
description = Fill zkEVM test cases in ./tests/ for deployed mainnet forks, using evmone-t8n.
commands_pre = solc-select use {[testenv]solc_version} --always-install
commands_pre = solc-select use {[testenv]solc_version}
commands = pytest -n auto -m "zkevm" --skip-evm-dump --block-gas-limit 36000000 --output=/tmp/fixtures-tox --clean --evm-bin=evmone-t8n

[testenv:tests-develop]
description = Fill test cases in ./tests/ for deployed and development mainnet forks
setenv =
# Use custom EELS_RESOLUTIONS_FILE if it is set via the environment (eg, in CI)
EELS_RESOLUTIONS_FILE = {env:EELS_RESOLUTIONS_FILE:}
commands_pre = solc-select use {[testenv]solc_version} --always-install
commands_pre = solc-select use {[testenv]solc_version}
commands = pytest -n auto --until={[forks]develop} -k "not slow and not zkevm" --skip-evm-dump --output=/tmp/fixtures-tox --clean

# ----------------------------------------------------------------------------------------------
Expand Down
Loading