-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
bug: forge coverage
doesn't respect filters when sparse mode is active
#9330
Comments
forge coverage
doesn't respect filters when sparse mode is active
hey! filters are applied, what you see there is the initial phase when the entire project is built for analyzing contracts, for example: forge coverage --mt test_Increment --skip script
[⠒] Compiling...
[⠃] Compiling 25 files with Solc 0.8.28
[⠘] Solc 0.8.28 finished in 3.72s
Compiler run successful!
Analysing contracts...
Running tests...
Ran 1 test for test/Counter.t.sol:CounterTest
[PASS] test_Increment() (gas: 31874)
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 5.58ms (1.47ms CPU time)
Ran 1 test suite in 42.90ms (5.58ms CPU time): 1 tests passed, 0 failed, 0 skipped (1 total tests)
| File | % Lines | % Statements | % Branches | % Funcs |
|-----------------|---------------|---------------|---------------|---------------|
| src/Counter.sol | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) |
| Total | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) |
while without any test match forge coverage --skip script
[⠒] Compiling...
[⠃] Compiling 25 files with Solc 0.8.28
[⠃] Solc 0.8.28 finished in 3.78s
Compiler run successful!
Analysing contracts...
Running tests...
Ran 2 tests for test/Counter.t.sol:CounterTest
[PASS] testFuzz_SetNumber(uint256) (runs: 256, μ: 32074, ~: 32385)
[PASS] test_Increment() (gas: 31874)
Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in 404.82ms (402.47ms CPU time)
Ran 1 test suite in 407.08ms (404.82ms CPU time): 2 tests passed, 0 failed, 0 skipped (2 total tests)
| File | % Lines | % Statements | % Branches | % Funcs |
|-----------------|---------------|---------------|---------------|---------------|
| src/Counter.sol | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) |
| Total | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | We will be able to make coverage better when porting to solar, see #9317 |
Possibly useful here if you want to filter the results: foundry/crates/evm/coverage/src/lib.rs Lines 153 to 157 in fbee819
|
forge coverage
doesn't respect filters when sparse mode is activeforge coverage
doesn't respect filters when sparse mode is active
Does this mean that there isn’t a way to skip the compilation of certain files using filters when working with coverage? When I use the |
Correct, the filter applied in coverage can't be done earlier because there may be files dependent on the ignored ones, which will not be covered if we remove the ignored files earlier. Using For now marking as |
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (31c24b0 2024-11-14T00:20:56.222819000Z
What command(s) is the bug in?
forge coverage
Operating System
macOS (Apple Silicon)
Describe the bug
foundry.toml
the same filter when running
forge test
The text was updated successfully, but these errors were encountered: