Skip to content
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

lcov version 2.1 breaks coverage report #8281

Closed
2 tasks done
0xernesto opened this issue Jun 27, 2024 · 5 comments
Closed
2 tasks done

lcov version 2.1 breaks coverage report #8281

0xernesto opened this issue Jun 27, 2024 · 5 comments
Labels
C-forge Command: forge Cmd-forge-coverage Command: forge coverage T-bug Type: bug

Comments

@0xernesto
Copy link

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (c8db1e4 2024-06-27T00:18:32.026850000Z)

What command(s) is the bug in?

forge coverage --report lcov && genhtml lcov.info -o report --branch-coverage

Operating System

macOS (Apple Silicon)

Describe the bug

When trying to generate an HTML coverage report based on the lcov.info that forge coverage --report lcov outputs, the following error occurs:

Wrote LCOV report.
lcov: ERROR: (inconsistent) "src/MyContract.sol":49:  function MyContract. found on line but no corresponding 'line' coverage data point.  Cannot derive function end line.  See lcovrc man entry for 'derive_function_end_line'.
 (use "lcov --ignore-errors inconsistent ..." to bypass this error)

This problem happens if you install lcov using Homebrew on MacOS, which currently installs lcov version 2.1.

When downgrading to lcov version 1.16, this problem goes away.

To reproduce error:

brew install lcov
forge coverage --report lcov && genhtml lcov.info -o report --branch-coverage

To get around the error:
Downgrade lcov to version 1.16.

@0xernesto 0xernesto added the T-bug Type: bug label Jun 27, 2024
@zerosnacks zerosnacks added C-forge Command: forge Cmd-forge-coverage Command: forge coverage labels Jun 28, 2024
@grandizzy
Copy link
Collaborator

I think you can just forge coverage --report lcov && genhtml lcov.info -o report --rc lcov_branch_coverage=1 derive_function_end_line=0 as derive_function_end_line is enabled by default in lcov 2.1

@PierrickGT
Copy link
Contributor

I've fixed the issue with the following command:
forge coverage --no-match-path 'test/invariant/**/*.sol' --report lcov && lcov --extract lcov.info --rc lcov_branch_coverage=1 --rc derive_function_end_line=0 -o lcov.info 'src/*' && genhtml lcov.info --rc branch_coverage=1 --rc derive_function_end_line=0 -o coverage

Locally I'm running:

  • lcov: LCOV version 2.1-1
  • genhtml: LCOV version 2.1-1

@grandizzy
Copy link
Collaborator

awesome, thanks for confirming, not sure if there's any code change we should do here or only document options to run coverage using LCOV versions > 1.16 (as lcov did for their tests backward compatibility linux-test-project/lcov@2bfaf3d#diff-bc9ca225569a229568d59f0551dc13b2fb4aa27b6815d0903adac1c17ba0899eR6-R8) @mattsse @DaniPopes @klkvr wdyt? thanks

@mattsse
Copy link
Member

mattsse commented Jul 8, 2024

makes sense to me!

@grandizzy
Copy link
Collaborator

Docs updated with foundry-rs/book#1237

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge Cmd-forge-coverage Command: forge coverage T-bug Type: bug
Projects
None yet
Development

No branches or pull requests

5 participants