Skip to content

Commit 80f77dc

Browse files
authored
Merge pull request #13360 from ethereum/update-bugs-by-version-no-error-on-update
`update_bugs_by_version.py`: don't fail when the list gets updated
2 parents 6b60524 + 8874627 commit 80f77dc

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

scripts/update_bugs_by_version.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,19 @@
66
# This makes it possible to use this script as part of CI to check
77
# that the list is up to date.
88

9-
import os
109
import json
1110
import re
12-
import sys
11+
from pathlib import Path
1312

1413
def comp(version_string):
1514
return [int(c) for c in version_string.split('.')]
1615

17-
path = os.path.dirname(os.path.realpath(__file__))
18-
with open(path + '/../docs/bugs.json', encoding='utf8') as bugsFile:
19-
bugs = json.load(bugsFile)
16+
root_path = Path(__file__).resolve().parent.parent
17+
18+
bugs = json.loads((root_path / 'docs/bugs.json').read_text(encoding='utf8'))
2019

2120
versions = {}
22-
with open(path + '/../Changelog.md', encoding='utf8') as changelog:
21+
with (root_path / 'Changelog.md').open(encoding='utf8') as changelog:
2322
for line in changelog:
2423
m = re.search(r'^### (\S+) \((\d+-\d+-\d+)\)$', line)
2524
if m:
@@ -35,9 +34,9 @@ def comp(version_string):
3534
continue
3635
value['bugs'] += [bug['name']]
3736

38-
new_contents = json.dumps(versions, sort_keys=True, indent=4, separators=(',', ': '))
39-
with open(path + '/../docs/bugs_by_version.json', 'r', encoding='utf8') as bugs_by_version:
40-
old_contents = bugs_by_version.read()
41-
with open(path + '/../docs/bugs_by_version.json', 'w', encoding='utf8') as bugs_by_version:
42-
bugs_by_version.write(new_contents)
43-
sys.exit(old_contents != new_contents)
37+
(root_path / 'docs/bugs_by_version.json').write_text(json.dumps(
38+
versions,
39+
sort_keys=True,
40+
indent=4,
41+
separators=(',', ': ')
42+
), encoding='utf8')

test/cmdlineTests.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ function test_via_ir_equivalence()
355355

356356
for yul_file in $(find . -name "${output_file_prefix}*.yul" | sort -V); do
357357
bin_output_two_stage+=$(
358-
msg_on_error --no-stderr "$SOLC" --strict-assembly --bin "${optimizer_flags[@]}" "$yul_file" |
358+
msg_on_error --no-stderr "$SOLC" --strict-assembly --bin "${optimizer_flags[@]}" "$yul_file" |
359359
sed '/^Binary representation:$/d' |
360360
sed '/^=======/d'
361361
)
@@ -375,8 +375,13 @@ function test_via_ir_equivalence()
375375

376376
## RUN
377377

378-
echo "Checking that the bug list is up to date..."
379-
"$REPO_ROOT"/scripts/update_bugs_by_version.py
378+
SOLTMPDIR=$(mktemp -d)
379+
printTask "Checking that the bug list is up to date..."
380+
cp "${REPO_ROOT}/docs/bugs_by_version.json" "${SOLTMPDIR}/original_bugs_by_version.json"
381+
"${REPO_ROOT}/scripts/update_bugs_by_version.py"
382+
diff --unified "${SOLTMPDIR}/original_bugs_by_version.json" "${REPO_ROOT}/docs/bugs_by_version.json" || \
383+
fail "The bug list in bugs_by_version.json was out of date and has been updated. Please investigate and submit a bugfix if necessary."
384+
rm -r "$SOLTMPDIR"
380385

381386
printTask "Testing unknown options..."
382387
(

0 commit comments

Comments
 (0)