-
Notifications
You must be signed in to change notification settings - Fork 6
/
coverage.sh
executable file
·28 lines (18 loc) · 1014 Bytes
/
coverage.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Copyright Zhenbo Li. MIT License
rustup default nightly
cargo install grcov
rustup component add llvm-tools-preview
rm -rf ./target *.prof*
# Export the flags needed to instrument the program to collect code coverage.
export RUSTFLAGS="-Zinstrument-coverage"
# Ensure each test runs gets its own profile information by defining the LLVM_PROFILE_FILE environment variable (%p will be replaced by the process ID, and %m by the binary signature):
export LLVM_PROFILE_FILE="text_io-%p-%m.profraw"
# Build the program
cargo build
# Run the program (you can replace this with `cargo test` if you want to collect code coverage for your tests).
cargo test
# Generate a HTML report in the coverage/ directory.
grcov . --binary-path ./target/debug/ -s . -t html --branch --ignore-not-existing -o ./coverage/
# Generate a LCOV report and upload it to codecov.io.
grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing -o ./lcov.info
bash <(curl -s https://codecov.io/bash) -f lcov.info