Closed 3esmit closed 1 week ago
Hi @3esmit I think this issue can be resolved if forge test --gas-report --json
yields a predictable and correct JSON serialized representation of the table layout. This would allow you to just pipe to file using builtins.
@zerosnacks yes, if that command outputed the data in the table it would fix the issue.
I need something to keep track of all gas changes.. Ideally, gas-snapshot and gas-report become one single file, and both in json, so we can have some tool (maybe a plugin in coverage stuff) that would follow the gas cost of operations.
Closed by #9063
Component
Forge
Describe the feature you would like
I would like that
forge test --gas-report
to be saved in a file, similar to whatforge snapshot
does.This could be either a different flag in
forge test --gas-report
likeforge-test --gas-report-file
or probably the better would beforge snapshot --gas-report
, so the gas report also generates a file called .gas-report with the table output offorge-test --gas-report
Additional context
forge test --gas-report
seems more complete thanforge snapshot
, because it actually tests the gas costs for different scenarios, for example when storage is loaded, or empty, etc, or different call stacks, and create a very useful report to see how the changes impact in gas usage.Currently I am using a custom commands on package.json to achieve this functionality:
Recently, forge changed a word in the test report, from "Test result" to "Suite result" that broke that command entirely in many repositories I am working. See https://github.com/vacp2p/foundry-template/pull/31
This feature would avoid having to tweak with awk, and give peace of mind on both sides.