Skip to content

Commit 8a402f6

Browse files
winsvegadanceratopz
authored andcommitted
feat(coverage): coverage script parsing files from ported_from markers (ethereum#1634)
* add missing ported_from markers * adjust the coverage script to read from .py markers * remove converted-ethereum-tests.txt * fix empty ported list scenario * register diffPlaces in stSelfBalance for coverage * replace pyscript with fill plugin * chore(fill): exit early if in a help/collectonly mode * chore(fill): don't print ported_tests terminal summary with `-q` * address comments * docs: update changelog --------- Co-authored-by: danceratopz <danceratopz@gmail.com>
1 parent 5b15bd5 commit 8a402f6

File tree

11 files changed

+213
-278
lines changed

11 files changed

+213
-278
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
- [ ] All: Considered squashing commits to improve commit history.
1111
- [ ] All: Added an entry to [CHANGELOG.md](/ethereum/execution-spec-tests/blob/main/docs/CHANGELOG.md).
1212
- [ ] All: Considered updating the online docs in the [./docs/](/ethereum/execution-spec-tests/blob/main/docs/) directory.
13-
- [ ] Tests: All converted JSON/YML tests from [ethereum/tests](/ethereum/tests) have been added to [converted-ethereum-tests.txt](/ethereum/execution-spec-tests/blob/main/converted-ethereum-tests.txt).
14-
- [ ] Tests: A PR with removal of converted JSON/YML tests from [ethereum/tests](/ethereum/tests) have been opened.
13+
- [ ] Tests: All converted JSON/YML tests from [ethereum/tests](/ethereum/tests)/[tests/static](/ethereum/execution-spec-tests/blob/main/tests/static) have been assigned @ported_from marker.
14+
- [ ] Tests: A PR with removal of converted JSON/YML blockchain tests from [ethereum/tests](/ethereum/tests) have been opened.
1515
- [ ] Tests: Included the type and version of evm t8n tool used to locally execute test cases: e.g., ref with commit hash or geth 1.13.1-stable-3f40e65.
1616
- [ ] Tests: Ran `mkdocs serve` locally and verified the auto-generated docs for new tests in the [Test Case Reference](https://eest.ethereum.org/main/tests/) are correctly formatted.
1717
- [ ] Tests: For PRs implementing a missed test case, update the [post-mortem document](/ethereum/execution-spec-tests/blob/main/docs/writing_tests/post_mortems.md) to add an entry the list.

.github/workflows/coverage.yaml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ jobs:
3636
- tests/**/test_*.py
3737
- '!tests/prague/**'
3838
- '!tests/unscheduled/**'
39-
converted_tests:
40-
- converted-ethereum-tests.txt
4139
4240
- name: Exit workflow if there are no changed python files
4341
if: steps.changed-tests.outputs.tests_any_changed != 'true'
@@ -113,23 +111,22 @@ jobs:
113111
Cancun/BlockchainTests
114112
115113
# This command diffs the file and filters in new lines
116-
- name: Parse converted tests from converted-ethereum-tests.txt
114+
- name: Parse ported_from markers from introduced .py tests
117115
if: steps.changed-tests.outputs.tests_any_changed == 'true'
116+
env:
117+
CHANGED_TEST_FILES: ${{ steps.changed-tests.outputs.tests_all_changed_files }}
118118
run: |
119-
echo "New lines introduced in converted-ethereum-tests.txt:"
120-
lines=$(git diff origin/${{ github.base_ref }} HEAD -- converted-ethereum-tests.txt | grep "^+" | grep -v "^+++" || true)
121-
if [ -z "$lines" ]; then
122-
echo "No new lines in converted-ethereum-tests.txt, check updates instead:"
119+
source $GITHUB_ENV
120+
new_sources=$(echo "$CHANGED_TEST_FILES" | tr ',' '\n')
121+
files=$(uv run fill $new_sources --show-ported-from --clean --quiet --links-as-filled | grep .json)
122+
if [[ -z "$files" ]]; then
123+
echo "No ported fillers found, check updates instead:"
123124
echo "converted_skip=true" >> $GITHUB_ENV
124125
exit 0
125126
else
126127
echo "converted_skip=false" >> $GITHUB_ENV
127128
fi
128129
129-
files=$(echo "$lines" | grep -oP '(?<=\+).+\.json')
130-
for file in $files; do
131-
echo $file
132-
done
133130
echo "----------------"
134131
echo "Discovered existing json tests that will be BASE files:"
135132

converted-ethereum-tests.txt

Lines changed: 0 additions & 261 deletions
This file was deleted.

docs/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ The output behavior of `fill` has changed ([#1608](https://github.com/ethereum/e
1919

2020
#### `fill`
2121

22-
- ✨ Add `ported_from` test marker to track Python test cases that were converted from static fillers in [ethereum/tests](https://github.com/ethereum/tests) repository [#1590](https://github.com/ethereum/execution-spec-tests/pull/1590).
22+
- ✨ Add the `ported_from` test marker to track Python test cases that were converted from static fillers in [ethereum/tests](https://github.com/ethereum/tests) repository [#1590](https://github.com/ethereum/execution-spec-tests/pull/1590).
23+
- ✨ Add a new pytest plugin, `ported_tests`, that lists the static fillers and PRs from `ported_from` markers for use in the coverage Github Workflow [#1634](https://github.com/ethereum/execution-spec-tests/pull/1634).
2324
- 🔀 Refactor: Encapsulate `fill`'s fixture output options (`--output`, `--flat-output`, `--single-fixture-per-file`) into a `FixtureOutput` class ([#1471](https://github.com/ethereum/execution-spec-tests/pull/1471),[#1612](https://github.com/ethereum/execution-spec-tests/pull/1612)).
2425
- ✨ Don't warn about a "high Transaction gas_limit" for `zkevm` tests ([#1598](https://github.com/ethereum/execution-spec-tests/pull/1598)).
2526
- 🐞 `fill` no longer writes generated fixtures into an existing, non-empty output directory; it must now be empty or `--clean` must be used to delete it first ([#1608](https://github.com/ethereum/execution-spec-tests/pull/1608)).

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ addopts =
1313
-p pytest_plugins.solc.solc
1414
-p pytest_plugins.filler.filler
1515
-p pytest_plugins.filler.static_filler
16+
-p pytest_plugins.filler.ported_tests
1617
-p pytest_plugins.shared.execute_fill
1718
-p pytest_plugins.forks.forks
1819
-p pytest_plugins.eels_resolver

src/pytest_plugins/filler/filler.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,17 @@ def pytest_addoption(parser: pytest.Parser):
203203
)
204204

205205

206+
def is_help_or_collectonly_mode(config: pytest.Config) -> bool:
207+
"""Check if pytest is running in a help or collectonly mode."""
208+
return (
209+
config.getoption("markers")
210+
or config.getoption("collectonly")
211+
or config.getoption("markers")
212+
or config.getoption("show_ported_from")
213+
or config.getoption("links_as_filled")
214+
)
215+
216+
206217
@pytest.hookimpl(tryfirst=True)
207218
def pytest_configure(config):
208219
"""
@@ -226,7 +237,7 @@ def pytest_configure(config):
226237
# Initialize fixture output configuration
227238
config.fixture_output = FixtureOutput.from_config(config)
228239

229-
if config.option.collectonly:
240+
if is_help_or_collectonly_mode(config):
230241
return
231242

232243
try:
@@ -272,7 +283,7 @@ def pytest_configure(config):
272283
@pytest.hookimpl(trylast=True)
273284
def pytest_report_header(config: pytest.Config):
274285
"""Add lines to pytest's console output header."""
275-
if config.option.collectonly:
286+
if is_help_or_collectonly_mode(config):
276287
return
277288
t8n_version = config.stash[metadata_key]["Tools"]["t8n"]
278289
return [(f"{t8n_version}")]
@@ -866,7 +877,7 @@ def pytest_sessionfinish(session: pytest.Session, exitstatus: int):
866877
return
867878

868879
fixture_output = session.config.fixture_output # type: ignore[attr-defined]
869-
if fixture_output.is_stdout or session.config.option.collectonly:
880+
if fixture_output.is_stdout or is_help_or_collectonly_mode(session.config):
870881
return
871882

872883
# Remove any lock files that may have been created.

0 commit comments

Comments
 (0)