Skip to content

Commit

Permalink
check patched tests coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
winsvega committed Jul 11, 2024
1 parent f5797b5 commit c06335d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 10 deletions.
58 changes: 50 additions & 8 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Evmone Coverage Report
on:
pull_request:
paths:
- 'converted-ethereum-tests.txt' # This triggers the workflow only for changes in file.txt
- 'tests/**' # This triggers the workflow for any changes in the tests folder

jobs:
evmone-coverage-diff:
Expand Down Expand Up @@ -74,14 +74,16 @@ jobs:
- name: Parse converted tests from converted-ethereum-tests.txt
run: |
echo "New lines introduced in converted-ethereum-tests.txt:"
lines=$(git diff origin/${{ github.base_ref }} HEAD -- converted-ethereum-tests.txt | grep "^+" | grep -v "^+++")
files=$(echo "$lines" | grep -oP '(?<=\+).+\.json')
if [ -z "$files" ]; then
echo "Error: No new JSON files found in converted-ethereum-tests.txt"
exit 1
lines=$(git diff origin/${{ github.base_ref }} HEAD -- converted-ethereum-tests.txt | grep "^+" | grep -v "^+++" || true)
if [ -z "$lines" ]; then
echo "No new lines in converted-ethereum-tests.txt, check updates instead:"
echo "converted_skip=true" >> $GITHUB_ENV
exit 0
else
echo "converted_skip=false" >> $GITHUB_ENV
fi
files=$(echo "$lines" | grep -oP '(?<=\+).+\.json')
for file in $files; do
echo $file
done
Expand Down Expand Up @@ -118,7 +120,7 @@ jobs:
exit 1
fi
done
# This command diffs the .py scripts introduced by a PR
- name: Parse and fill introduced test sources
Expand Down Expand Up @@ -182,6 +184,46 @@ jobs:
find fixtures/state_tests -type f -name "*.json" -exec cp {} $PATCH_TEST_PATH \;
find fixtures/eof_tests -type f -name "*.json" -exec cp {} $PATCH_TEST_PATH \;
if [ "${{ env.converted_skip }}" == 'true' ]; then
echo "--------------------"
echo "converted-ethereum-tests.txt seem untouched, try to fill pre-patched version of .py files:"
PREV_COMMIT=$(git log --before="$(git log -2 --pretty=format:%cd --date=iso)" -2 --pretty=format:%H)
echo "Checkout head $PREV_COMMIT"
git checkout $PREV_COMMIT
rm -r fixtures
rm filloutput.log
rm filloutputEOF.log
mkdir -p fixtures/state_tests
mkdir -p fixtures/eof_tests
echo "$files" | while read line; do
file=$(echo "$line" | cut -c 3-)
if [ ! -f "$file" ]; then
continue
fi
fill "$file" --until=Cancun --evm-bin evmone-t8n || true >> filloutput.log 2>&1
(fill "$file" --fork=CancunEIP7692 --evm-bin evmone-t8n -k eof_test || true) > >(tee -a filloutput.log filloutputEOF.log) 2>&1
done
if grep -q "FAILURES" filloutput.log; then
echo "Error: failed to generate .py tests from before the PR."
exit 1
fi
filesState=$(find fixtures/state_tests -type f -name "*.json")
filesEOF=$(find fixtures/eof_tests -type f -name "*.json")
if [ -z "$filesState" ] && [ -z "$filesEOF" ]; then
echo "Error: No filled JSON fixtures found in fixtures from before the PR."
exit 1
fi
BASE_TEST_PATH=${{ github.workspace }}/evmtest_coverage/coverage/BASE_TESTS
mkdir -p $BASE_TEST_PATH
find fixtures/state_tests -type f -name "*.json" -exec cp {} $BASE_TEST_PATH \;
find fixtures/eof_tests -type f -name "*.json" -exec cp {} $BASE_TEST_PATH \;
fi
- name: Print tests that will be covered
if: ${{ env.retesteth_skip == 'false' || matrix.driver == 'native' }}
run: |
Expand Down
2 changes: 0 additions & 2 deletions tests/homestead/coverage/test_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ def test_coverage(
+ Op.PUSH1(0x0D)
+ Op.PUSH1(0x0E)
+ Op.SWAP1()
+ Op.DUP1()
+ Op.DUP2()
+ Op.PUSH0()
+ Op.PUSH2(0x0102)
+ Op.PUSH3(0x010203)
Expand Down

0 comments on commit c06335d

Please sign in to comment.