35 lines
1.4 KiB
Bash
Executable File
35 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
set -o xtrace
|
|
|
|
export CARGO_TARGET_DIR="coverage-target"
|
|
export ZEBRA_SKIP_NETWORK_TESTS=1
|
|
export LLVM_PROFILE_FILE="${PWD}/$CARGO_TARGET_DIR/coverage/test.%m.profraw"
|
|
export RUSTFLAGS="-Zinstrument-coverage -C link-dead-code -C debuginfo=2"
|
|
|
|
rm -rf ./"$CARGO_TARGET_DIR"/coverage
|
|
mkdir -p ./$CARGO_TARGET_DIR/coverage
|
|
cargo +nightly test
|
|
cargo +nightly test --no-run --message-format=json | jq -r "select(.profile.test == true) | .filenames[]" | grep -v dSYM - > ./$CARGO_TARGET_DIR/files.txt
|
|
$(rustc +nightly --print target-libdir)/../bin/llvm-profdata merge ./$CARGO_TARGET_DIR/coverage/test.*.profraw -o ./$CARGO_TARGET_DIR/coverage/test.profdata
|
|
|
|
rm -rf ./$CARGO_TARGET_DIR/coverage/html/
|
|
|
|
$(rustc +nightly --print target-libdir)/../bin/llvm-cov show \
|
|
-format=html \
|
|
-Xdemangler=rustfilt \
|
|
-show-instantiations \
|
|
-output-dir=./$CARGO_TARGET_DIR/coverage/html \
|
|
-ignore-filename-regex=".*/.cargo/registry/.*" \
|
|
-ignore-filename-regex=".*/.cargo/git/.*" \
|
|
-ignore-filename-regex=".*/.rustup/.*" \
|
|
-instr-profile=./$CARGO_TARGET_DIR/coverage/test.profdata \
|
|
$(printf -- "-object %s " $(cat ./$CARGO_TARGET_DIR/files.txt))
|
|
|
|
$(rustc +nightly --print target-libdir)/../bin/llvm-cov export \
|
|
-format=lcov \
|
|
-instr-profile=./$CARGO_TARGET_DIR/coverage/test.profdata \
|
|
$(printf -- "-object %s " $(cat ./$CARGO_TARGET_DIR/files.txt)) > "./$CARGO_TARGET_DIR/coverage/lcov.info"
|
|
|
|
xdg-open ./$CARGO_TARGET_DIR/coverage/html/index.html
|