Skip to content

Commit bf37362

Browse files
authored
pytest: compile Yul with --target-version shanghai when fork is cancun (#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
1 parent 8636cf6 commit bf37362

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

docs/gen_test_case_reference.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ def run_collect_only(test_path: Path = source_directory) -> Tuple[str, str]:
190190
collect_only_command = f"fill --collect-only -q --until {DEV_FORKS[-1]} {test_path}"
191191
# strip out the test module
192192
output_lines = [
193-
line.split("::")[1] for line in output.split("\n") if line.startswith("tests/")
193+
line.split("::")[1]
194+
for line in output.split("\n")
195+
if line.startswith("tests/") and "::" in line
194196
]
195197
# prefix with required indent for admonition in MARKDOWN_TEST_CASES_TEMPLATE
196198
collect_only_output = "\n".join(" " + line for line in output_lines)

tests/conftest.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
Pytest definitions applied to all tests.
3+
"""
4+
import warnings
5+
6+
import pytest
7+
8+
9+
def pytest_collection_modifyitems(items, config):
10+
"""
11+
Modify tests post collection.
12+
13+
Here we override the default behavior of the `yul` fixture so that
14+
solc compiles with shanghai instead of cancun (which is unavailable
15+
in solc 0.8.20).
16+
"""
17+
for item in items:
18+
if "Cancun" in item.name and "yul" in item.fixturenames:
19+
if config.getoption("verbose") >= 2:
20+
warnings.warn(f"Compiling Yul source for f{item.name} with Shanghai, not Cancun.")
21+
else:
22+
warnings.warn("Compiling Yul source with Shanghai, not Cancun.")
23+
item.add_marker(pytest.mark.compile_yul_with("Shanghai"))

0 commit comments

Comments
 (0)