foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.31k stars 1.75k forks source link

feat(forge test) option to list summary table only #9307

Open radeksvarz opened 2 days ago

radeksvarz commented 2 days ago

Component

Forge

Describe the feature you would like

Motivation: Many tests fail when migrating from OZ 4 to OZ 5, esp. when you have hundreds of tests. One needs to see and report on the volume to be fixed.

The forge test --summary --detailed gives a nice overview, but the table is burned within the rest of the output.

I propose to have the flag --summaryonly , which would act similarly to --summary --detailed, but would output only the table and the general stat Encountered a total of xxx failing tests, zzz tests succeeded

Current workaround is: forge test --summary --detailed | awk '/Test Summary:/,/----╯/'

But that loses coloring.

I assume there might be some other workaround, I welcome any comments on this.

Additional context

No response

zerosnacks commented 2 days ago

Hi @radeksvarz I would like to avoid introducing a new flag here.

Could you expand on the table is burned within the rest of the output?

The idea is that the summary should collect all test output and summarize it in one table like:

Test Summary:

╭--------------+--------+--------+---------+---------------------+----------╮
|  Test Suite  | Passed | Failed | Skipped |      File Path      | Duration |
+===========================================================================+
| CounterTest  |    2   |    0   |    0    | test/Counter.t.sol  | 2.57ms   |
|--------------+--------+--------+---------+---------------------+----------|
| Counter2Test |    2   |    0   |    0    | test/Counter2.t.sol | 2.33ms   |
╰--------------+--------+--------+---------+---------------------+----------╯
radeksvarz commented 2 days ago

When you have hundreds of tests the output is:

IMHO I fully agree that the case is not worth to introduce the new flag. Chaining the output and cutting should be the way to go.

The only issue there is losing the ANSI color information.