Skip to content

Commit

Permalink
pytest: compile Yul with --target-version shanghai when fork is cancun (
Browse files Browse the repository at this point in the history
#174)

* pytest: compile Yul with --target-version shanghai when fork is cancun

* pytest: add a more verbose warning for yul compilation if ran with -vv

* docs: fix gen_test_case_reference collect only when warnings are present
  • Loading branch information
danceratopz authored Jun 27, 2023
1 parent 8636cf6 commit bf37362
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/gen_test_case_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ def run_collect_only(test_path: Path = source_directory) -> Tuple[str, str]:
collect_only_command = f"fill --collect-only -q --until {DEV_FORKS[-1]} {test_path}"
# strip out the test module
output_lines = [
line.split("::")[1] for line in output.split("\n") if line.startswith("tests/")
line.split("::")[1]
for line in output.split("\n")
if line.startswith("tests/") and "::" in line
]
# prefix with required indent for admonition in MARKDOWN_TEST_CASES_TEMPLATE
collect_only_output = "\n".join(" " + line for line in output_lines)
Expand Down
23 changes: 23 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
Pytest definitions applied to all tests.
"""
import warnings

import pytest


def pytest_collection_modifyitems(items, config):
"""
Modify tests post collection.
Here we override the default behavior of the `yul` fixture so that
solc compiles with shanghai instead of cancun (which is unavailable
in solc 0.8.20).
"""
for item in items:
if "Cancun" in item.name and "yul" in item.fixturenames:
if config.getoption("verbose") >= 2:
warnings.warn(f"Compiling Yul source for f{item.name} with Shanghai, not Cancun.")
else:
warnings.warn("Compiling Yul source with Shanghai, not Cancun.")
item.add_marker(pytest.mark.compile_yul_with("Shanghai"))

0 comments on commit bf37362

Please sign in to comment.