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-report #38

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ docs/
.env

# OSX
.DS_Store
.DS_Store

.lcov
.lcov_filtered

Copy link
Member

@benjaminbollen benjaminbollen Aug 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should also include lcov.info and lcov_filtered.info

coverage-report/
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,53 @@ This Solidity project uses Foundry as a toolkit. If you don't have Foundry insta
forge snapshot
```

### Generating Code Coverage Report
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the readme, forge coverage works out of the box, and so I think this more detailed description is too much for the readme. I ll set it up in a script and we can run a hosted version of the coverage report and then just link the results to the readme


1. **Generate the `lcov` File:**
To generate the coverage data in `lcov` format, run the following command:
```sh
forge coverage --report lcov
```

2. **Install `lcov`:**
If you don't have `lcov` installed, you can install it using your package manager. Here are the instructions for different operating systems:

- **macOS (using Homebrew):**
```sh
brew install lcov
```

- **Linux (using apt for Debian/Ubuntu):**
```sh
sudo apt-get update
sudo apt-get install lcov
```

- **Linux (using yum for CentOS/Fedora):**
```sh
sudo yum install lcov
```

3. **Filter the Coverage Data:**
To ensure that only files from the `src` directory are included in the report, filter the coverage data:
```sh
lcov --remove lcov.info 'test/*' -o lcov_filtered.info --ignore-errors inconsistent
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same remark as below: you only want to address the actual error by instead calling

lcov --remove lcov.info 'test/*' -o lcov_filtered.info --rc derive_function_end_line=0      

this error is mentioned in the forge docs (see link below)

```

4. **Generate the HTML Report:**
To create an HTML report from the filtered `lcov` data, use:
```sh
genhtml lcov_filtered.info --output-directory coverage-report --ignore-errors inconsistent,corrupt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you want to instead address the specific error only::

genhtml lcov_filtered.info --output-directory coverage-report --rc derive_function_end_line=0

see the warning in the forge docs for explanation https://book.getfoundry.sh/reference/forge/forge-coverage#description

```

5. **Open the HTML Report:**
To view the HTML report, open the generated `index.html` file in your browser:
```sh
open coverage-report/index.html # macOS
xdg-open coverage-report/index.html # Linux
```


### Deploying the contracts
#### Chiado
To deploy the contracts to the Chiado testnet, run `./chiadoDeploy.sh` and supply a private key and API keys in `.env` file in the root directory (copy `.env.example` and set private information):
Expand Down
Loading
Loading