cargo-cov: Source coverage for Rust

cargo-cov is a cargo subcommand which performs source coverage collection and reporting for Rust crates

cargo-cov: Source coverage for Rust

cargo-cov is a cargo subcommand which performs source coverage collection and reporting for Rust crates. cargo-cov utilizes LLVM's gcov-compatible profile generation pass, and supports a lot of platforms.

  • ✓ FreeBSD, Linux, macOS, Windows (MSVC only)
  • ✓ x86_64, x86

Usage: for Local Testing on nightly Rust

You may install cargo-cov via cargo.

cargo install cargo-cov

The typical workflow is like this:

# clean up previous coverage result
cargo cov clean

# test the code
cargo cov test

# open the coverage report
cargo cov report --open

Usage: for Testing on stable Rust (1.19+)

We strongly recommend you use nightly Rust since only the nightly toolchain has built-in instrumented profiling support via -Zprofile.

If you must use a stable toolchain, you may try the following:

  1. Install the compiler-rt profile library.

    Target Instruction

    | Ubuntu, Debian | Install libclang-common-7-dev, or simply install clang | | Fedora | Install compiler-rt | | OpenSUSE | Install llvm-clang | | Windows (MSVC) | Install Clang for Windows Pre-Built Binary from LLVM | | macOS, iOS | Provided by the Xcode command line tools | | Android | Provided by Android NDK |

  2. Execute the doc-test separately from the normal tests. Run the doc-test before the normal tests.

    # Run --doc tests before other things before 1.19
    cargo cov test --doc
    cargo cov test --lib
    

We do not guarantee that a correct coverage profile will be generated using this method.

Issues

Collection of the latest Issues

AlbanMinassian

AlbanMinassian

0

How exclude coverage in /tests directory when i have this

src/lib.rs:

tests/ integration_test.rs:

Thanks Ami44

AlbanMinassian

AlbanMinassian

0

src/lib.rs:

tests/integration_test.rs:

src/lib => coverage 50% !

test

"cargo cov" not show "internal_adder" function .. strange rustc --version : rustc 1.30.0-nightly (1c2e17f4e 2018-09-04)

Ami44

asomers

asomers

0

"cargo cov report" intermittently fails on FreeBSD. Occasionally it will pass, but it usually fails with the following error:

Passing "-j1" to the test command, as in "cargo cov test -j1" greatly increases the pass rate. I've observed this problem on rust 1.20.0 and 1.21.1.

kennytm

kennytm

enhancement
0
  • (rustc) Make sure asan is supported on all relevant platforms (tracking)
  • (cargo-cov) Build sancov-enabled binaries (easy)
  • (cargo-cov) Run sancov-enabled binaries to get the *.sancov files (easy)
  • (cov) Construct Graph by analyzing the DWARF info (very hard)

https://clang.llvm.org/docs/SanitizerCoverage.html

kennytm

kennytm

enhancement
1
  • Change sortable.js to something smaller.
  • Allow hiding skipped lines
  • Support .scrollIntoViewIfNeeded() outside of Chrome
  • Test on IE
kennytm

kennytm

enhancement
0

Use lcov markers to remove a source line's statistics.

assert!, assert_eq!, debug_assert!, debug_assert_eq!, panic! should have the same effect as LCOV_EXCL_BR_LINE.

These strings should be configurable.

  • JaCoCo uses $COVERAGE-IGNORE$
  • coverage.py uses pragma: no cover
kennytm

kennytm

enhancement
6
  • Produce coveralls-compatible branch coverage JSON info
  • Upload from Travis CI to coveralls
  • Upload from AppVeyor to coveralls

API reference: #404

Maybe use https://crates.io/crates/coveralls-api

kennytm

kennytm

enhancement
0
  • Add test cases to verify cov can parse *.gcno/*.gcda generated from:

    • rustc
    • clang 4
    • gcc 7
  • Ensure the counts of *.gcno/*.gcda are consistent with output from llvm-cov/gcov-7.

  • Repeat above for the specimens.

  • Enable CIs

    • Travis CI (Linux, macOS)
    • AppVeyor (Windows-MSVC)

Information - Updated May 15, 2022

Stars: 119
Forks: 11
Issues: 15

Repositories & Extras

A fantasy deathcrawl in Rust

To run, with Rust compiler and Cargo package manager installed:

A fantasy deathcrawl in Rust

cargo-ndk - Build Rust code for Android

This cargo extension handles all the environment configuration needed for successfully building libraries

cargo-ndk - Build Rust code for Android

quest-hook-template

A template for writing mods for Quest il2cpp games in Rust using cargo generate to clone the template:

quest-hook-template

Command line json text parsing and processing utility

parsing json compliant with rust and cargo

Command line json text parsing and processing utility

Clone this repo: git clone

If you don't have Rust and cargo-make installed,

Clone this repo: git clone

Rustup: the Rust installer and version management tool

To test that you have Rust and Cargo installed, you can run this in your terminal of choice: cargo --version

Rustup: the Rust installer and version management tool

Address generator in Rust

If you have Rust: cargo install gemgen

Address generator in Rust

First, complete the basic Rust setup instructions

Use Rust's native cargo command to build and launch the template node:

First, complete the basic Rust setup instructions

Use one mouse on multiple computers

In France, we call that "flemme" (install cargo for rust)

Use one mouse on multiple computers

cargo rssc - Rust scripts for crates building

will copy the template_basic into scripts_rssc folder

cargo rssc - Rust scripts for crates building

NES Emulator in Rust-WASM

Requires Rust with cargo, nodejs, and wasm-pack

NES Emulator in Rust-WASM
Facebook Instagram Twitter GitHub Dribbble
Privacy