forked from iotaledger/wallet.rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
coverage.sh
executable file
·44 lines (36 loc) · 1.47 KB
/
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
set -e
# Remove stale coverage report
rm -rf coverage
mkdir coverage
# Run tests with profiling instrumentation
echo "Running instrumented unit tests..."
RUSTFLAGS="-C instrument-coverage" LLVM_PROFILE_FILE="iota-wallet-%m.profraw" cargo +nightly test --tests --all-features --manifest-path wallet/Cargo.toml -- --include-ignored
# Merge all .profraw files into "iota-wallet.profdata"
echo "Merging coverage data..."
cargo +nightly profdata -- merge ./iota-wallet-*.profraw -o iota-wallet.profdata
# List the test binaries
echo "Locating test binaries..."
BINARIES=""
for file in \
$( \
RUSTFLAGS="-C instrument-coverage" \
cargo +nightly test --tests --all --all-features --no-run --message-format=json --manifest-path wallet/Cargo.toml -- --include-ignored \
| jq -r "select(.profile.test == true) | .filenames[]" \
| grep -v dSYM - \
); \
do
echo "Found $file"
BINARIES="${BINARIES} -object $file"
done
# Generate and export the coverage report to lcov format
echo "Generating lcov file..."
cargo +nightly cov -- export ${BINARIES} \
--instr-profile=iota-wallet.profdata \
--ignore-filename-regex="/.cargo|rustc|target|tests|/.rustup" \
--format=lcov --Xdemangler=rustfilt \
>> coverage/coverage.info
# Ensure intermediate coverage files are deleted, ignore errors
echo "Removing intermediate files..."
find . -name "*.profraw" -type f -delete &> /dev/null || true
find . -name "*.profdata" -type f -delete &> /dev/null || true