From 27df5caea210e9f3b01d5fe5496e318fc4c592a8 Mon Sep 17 00:00:00 2001 From: David Ribeiro Alves Date: Thu, 1 Aug 2024 17:34:54 +0100 Subject: [PATCH] Add how to obtain test coverage reports to the README (#60) Co-authored-by: Supernovahs.eth <91280922+supernovahs@users.noreply.github.com> --- .gitignore | 2 +- README.md | 29 ++++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 6af8aa4f..3961162c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ debug/ target/ - +coverage diff --git a/README.md b/README.md index f06d66fa..3033f5c9 100644 --- a/README.md +++ b/README.md @@ -18,14 +18,15 @@ List of crates in the repository :- - [eigen-services](https://github.com/supernovahs/eigen-rs/tree/main/crates/services) - Spawn tokio services for operators info , bls aggregation - [eigen-types](https://github.com/supernovahs/eigen-rs/tree/main/crates/types) - Common types - [eigen-utils](https://github.com/supernovahs/eigen-rs/tree/main/crates/utils) - Publicly exportable `m2-mainnet` compatible alloy bindings. -- [eigen-testing-utils](https://github.com/supernovahs/eigen-rs/tree/main/testing/testing-utils) - Contains publicly exportable anvil , holesky , mainnet addresses for eigen contracts . +- [eigen-testing-utils](https://github.com/supernovahs/eigen-rs/tree/main/testing/testing-utils) - Contains publicly exportable anvil , holesky , mainnet addresses for eigen contracts . + ## Examples You can run any [example](https://github.com/supernovahs/eigen-rs/tree/main/examples) using the command cargo run --example Example : - + ``` cargo run --example get_quorum_count ``` @@ -36,12 +37,34 @@ We are actively looking for contributors. Thank you for your interest. We have s To test locally and raise a PR :- -You need `foundry` , `docker` and `make` and `nightly rust` to successfully run it. Also, the `docker` engine has to be running for all the tests to execute correctly. +You need `foundry` , `docker` and `make` and `nightly rust` to successfully run it. Also, the `docker` engine has to be running for all the tests to execute correctly. ``` make pr ``` +Test coverage should aim to be around 80%. + +Here's how to generate test coverage reports: + +Install llvm tools: +``` +rustup component add llvm-tools-preview +``` + +Run the tests with coverage instrumentations: +``` +cargo clean && mkdir -p coverage/ && rm -r coverage/* +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='coverage/cargo-test-%p-%m.profraw' cargo test --no-fail-fast +``` + +Install coverage report tool and run it: +``` +cargo install grcov +grcov . --binary-path ./target/debug/deps/ -s . -t html --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/coverage/ + +``` + ## Supported Rust Version Rolling `MSRV` policy of 6 months. The current `MSRV` is 1.79