-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor bytecode comparison scripts #10675
Conversation
bbc7c26
to
170e193
Compare
170e193
to
efe25ba
Compare
- Add argument parser - Add type annotations - Use pathlib - Split into functions - Use dataclasses to separate report data from presentation - Provide more information if the script is interrupted
efe25ba
to
085f88d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This generally looks good to me, but the tests depend on the compiler version string and the produced bytecode - won't that be annoying because it'll break every version and especially on every bytecode-altering compiler change?
@cameel just mentioned that the tests use hardcoded version and bytecode, I just didn't look closely enough, so nevermind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't really check the test cases added in the last commit, but the reports itself look good, so I'd trust it's fine.
The rest looks nice!
Yeah, tests added here never actually run And these tests don't really cover everything, just the most important parts. I'm assuming we don't want to go overboard with testing scripts, especially when it requires writing Python code. |
Fixes #10165.
This is a refactor of the
prepare_report.py
script used for generating a big bytecode+metadata dump from asolc
executable. For #10183 I need to expand the script a bit to make it backwards-compatible with old binaries, which requires making it work without--standard-json
(#4698) and a few other workarounds. The current structure was very minimalistic and also inconsistent with the equivalent JS snippet forsoljson.js
(formerly embedded instorebytecode.sh
; I extracted it intoprepare_report.js
). Here I'm only fixing the inconsistencies, making the script more modular and also updating it to use modern features of Python (type annotations, data classes, inline string formatting) and its standard library (argument parser, pathlib, unit testing).The PR also includes a simple setup for testing stuff from
scripts/
(at least the Python stuff). I'm including tests forprepare_report.py
and in the future we could add more for the rest. Ideally, our scripts would be so simple that they would not require separate testing but unfortunately that's not the case. We have some Bash stuff that could really be better off written in Python and tested.I'm currently running tests manually with:
Later, probably in a separate PR, I'm going to hook it up in the CI so that it can run automatically.