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

fix: update source coverage script #122

Merged
merged 1 commit into from
Mar 5, 2024
Merged
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
30 changes: 18 additions & 12 deletions test_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
# $ sudo apt install lcov

RUSTFLAGS="-C instrument-coverage"
RUSTUP_TOOLCHAIN=${RUSTUP_TOOLCHAIN:-nightly}
echo "Using ${RUSTUP_TOOLCHAIN} toolchain"
LLVM_PROFILE_FILE="./cov_raw/bulletproofs-plus-%m.profraw"

get_binaries() {
files=$( RUSTFLAGS=$RUSTFLAGS cargo +nightly test --tests --no-run --message-format=json \
files=$( RUSTFLAGS=$RUSTFLAGS cargo +${RUSTUP_TOOLCHAIN} test --tests --no-run --message-format=json \
| jq -r "select(.profile.test == true) | .filenames[]" \
| grep -v dSYM - \
);
Expand All @@ -23,38 +25,42 @@ get_binaries() {

get_binaries

echo "** Generating ..."
echo ${files}
# Remove old coverage files
rm cov_raw/*profraw cov_raw/bulletproofs-plus.profdata cov_raw/bulletproofs-plus.lcov cov_raw/bulletproofs-plus.txt
rm -fr cov_raw coverage_report default*.profraw

RUSTFLAGS=$RUSTFLAGS LLVM_PROFILE_FILE=$LLVM_PROFILE_FILE cargo +nightly test --tests
RUSTFLAGS=$RUSTFLAGS LLVM_PROFILE_FILE=${LLVM_PROFILE_FILE} cargo +${RUSTUP_TOOLCHAIN} test --tests

cargo +nightly profdata -- \
cargo profdata -- \
merge -sparse ./cov_raw/bulletproofs-plus-*.profraw -o ./cov_raw/bulletproofs-plus.profdata

cargo +nightly cov -- \
cargo cov -- \
export \
--Xdemangler=rustfilt \
--format=lcov \
--show-branch-summary \
--show-instantiation-summary \
--show-region-summary \
--ignore-filename-regex='/.cargo/registry' \
--ignore-filename-regex="^/rustc" \
--ignore-filename-regex='\.cargo' \
--ignore-filename-regex="rustc" \
--ignore-filename-regex="\.git" \
--ignore-filename-regex="curve25519-dalek" \
--instr-profile=cov_raw/bulletproofs-plus.profdata \
$files \
> cov_raw/bulletproofs-plus.lcov

cargo +nightly cov -- \
cargo cov -- \
show \
--Xdemangler=rustfilt \
--show-branch-summary \
--show-instantiation-summary \
--show-region-summary \
--ignore-filename-regex='/.cargo/registry' \
--ignore-filename-regex="^/rustc" \
--ignore-filename-regex='\.cargo' \
--ignore-filename-regex="rustc" \
--ignore-filename-regex="\.git" \
--ignore-filename-regex="curve25519-dalek" \
--instr-profile=cov_raw/bulletproofs-plus.profdata \
--instr-profile=cov_raw/bulletproofs-plus.profdata \
$files \
> cov_raw/bulletproofs-plus.txt

Expand All @@ -63,4 +69,4 @@ if [ -z ${SKIP_HTML+x} ]; then
else
echo "Skipping html generation"
fi
# open coverage_report/src/index.html
# open coverage_report/src/index.html