|
2 | 2 | set -e
|
3 | 3 | set -o xtrace
|
4 | 4 |
|
5 |
| -rm -rf ./target/ |
6 |
| -mkdir -p ./target/coverage |
7 |
| -ZEBRA_SKIP_NETWORK_TESTS=1 LLVM_PROFILE_FILE="${PWD}/target/coverage/test.%p.profraw" RUSTFLAGS="-Zinstrument-coverage" cargo test |
8 |
| -$(rustc --print target-libdir)/../bin/llvm-profdata merge --sparse ./target/coverage/test.*.profraw -o ./target/coverage/test.profdata |
| 5 | +export CARGO_TARGET_DIR="coverage-target" |
9 | 6 |
|
10 |
| -rm -rf ./target/coverage/html/ |
11 |
| -# This one works and shows all the details I want in the CLI |
12 |
| -$(rustc --print target-libdir)/../bin/llvm-cov show \ |
| 7 | +rm -rf ./"$CARGO_TARGET_DIR"/coverage |
| 8 | +mkdir -p ./$CARGO_TARGET_DIR/coverage |
| 9 | +export ZEBRA_SKIP_NETWORK_TESTS=1 |
| 10 | +export LLVM_PROFILE_FILE="${PWD}/$CARGO_TARGET_DIR/coverage/test.%m.profraw" |
| 11 | +export RUSTFLAGS="-Zinstrument-coverage -C link-dead-code -C debuginfo=2" |
| 12 | +cargo +nightly test --no-run --message-format=json | jq -r "select(.profile.test == true) | .filenames[]" | grep -v dSYM - > ./$CARGO_TARGET_DIR/files.txt |
| 13 | +cargo +nightly test |
| 14 | +$(rustc +nightly --print target-libdir)/../bin/llvm-profdata merge --sparse ./$CARGO_TARGET_DIR/coverage/test.*.profraw -o ./$CARGO_TARGET_DIR/coverage/test.profdata |
| 15 | + |
| 16 | +rm -rf ./$CARGO_TARGET_DIR/coverage/html/ |
| 17 | + |
| 18 | +$(rustc +nightly --print target-libdir)/../bin/llvm-cov show \ |
13 | 19 | -format=html \
|
14 | 20 | -Xdemangler=rustfilt \
|
15 | 21 | -show-instantiations \
|
16 |
| - -output-dir=./target/coverage/html \ |
| 22 | + -output-dir=./$CARGO_TARGET_DIR/coverage/html \ |
17 | 23 | -ignore-filename-regex=".*/.cargo/registry/.*" \
|
18 | 24 | -ignore-filename-regex=".*/.cargo/git/.*" \
|
19 | 25 | -ignore-filename-regex=".*/.rustup/.*" \
|
20 |
| - -instr-profile=./target/coverage/test.profdata \ |
21 |
| - $(find target/ -type f -perm -u+x ! -name '*.so') |
| 26 | + -instr-profile=./$CARGO_TARGET_DIR/coverage/test.profdata \ |
| 27 | + $(printf -- "-object %s " $(cat ./$CARGO_TARGET_DIR/files.txt)) |
22 | 28 |
|
23 |
| -xdg-open ./target/coverage/html/index.html |
| 29 | +xdg-open ./$CARGO_TARGET_DIR/coverage/html/index.html |
0 commit comments