Skip to content

Commit 12c2d6a

Browse files
committed
Add a script to run kcov
1 parent 7b92fe0 commit 12c2d6a

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

util/cov.sh

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/bash
2+
3+
# This run `kcov` on Clippy. The coverage report will be at
4+
# `./target/cov/index.html`.
5+
# `compile-test` is special. `kcov` does not work directly on it so these files
6+
# are compiled manually.
7+
8+
tests=(
9+
camel_case
10+
cc_seme
11+
consts
12+
dogfood
13+
issue_825
14+
matches
15+
trim_multiline
16+
used_underscore_binding_macro
17+
versioncheck
18+
)
19+
tmpdir=$(mktemp -d)
20+
21+
cargo test --no-run --verbose
22+
23+
for t in "${tests[@]}"; do
24+
kcov \
25+
--verify \
26+
--include-path="$(pwd)/src","$(pwd)/clippy_lints/src" \
27+
"$tmpdir/$t" \
28+
cargo test --test "$t"
29+
done
30+
31+
for t in ./tests/compile-fail/*.rs; do
32+
kcov \
33+
--verify \
34+
--include-path="$(pwd)/src","$(pwd)/clippy_lints/src" \
35+
"$tmpdir/compile-fail-$(basename $t)" \
36+
cargo run -- -L target/debug -L target/debug/deps -Z no-trans "$t"
37+
done
38+
39+
for t in ./tests/run-pass/*.rs; do
40+
kcov \
41+
--verify \
42+
--include-path="$(pwd)/src","$(pwd)/clippy_lints/src" \
43+
"$tmpdir/run-pass-$(basename $t)" \
44+
cargo run -- -L target/debug -L target/debug/deps -Z no-trans "$t"
45+
done
46+
47+
kcov --verify --merge target/cov "$tmpdir"/*

0 commit comments

Comments
 (0)