]> git.lizzy.rs Git - rust.git/blob - util/cov.sh
Merge #3353
[rust.git] / util / cov.sh
1 #!/usr/bin/bash
2
3 # Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
4 # file at the top-level directory of this distribution and at
5 # http://rust-lang.org/COPYRIGHT.
6 #
7 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
8 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
9 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
10 # option. This file may not be copied, modified, or distributed
11 # except according to those terms.
12
13
14 # This run `kcov` on Clippy. The coverage report will be at
15 # `./target/cov/index.html`.
16 # `compile-test` is special. `kcov` does not work directly on it so these files
17 # are compiled manually.
18
19 tests=$(find tests/ -maxdepth 1 -name '*.rs' ! -name compile-test.rs -exec basename {} .rs \;)
20 tmpdir=$(mktemp -d)
21
22 cargo test --no-run --verbose
23
24 for t in $tests; do
25   kcov \
26     --verify \
27     --include-path="$(pwd)/src,$(pwd)/clippy_lints/src" \
28     "$tmpdir/$t" \
29     cargo test --test "$t"
30 done
31
32 for t in ./tests/compile-fail/*.rs; do
33   kcov \
34     --verify \
35     --include-path="$(pwd)/src,$(pwd)/clippy_lints/src" \
36     "$tmpdir/compile-fail-$(basename "$t")" \
37     cargo run -- -L target/debug -L target/debug/deps -Z no-trans "$t"
38 done
39
40 for t in ./tests/run-pass/*.rs; do
41   kcov \
42     --verify \
43     --include-path="$(pwd)/src,$(pwd)/clippy_lints/src" \
44     "$tmpdir/run-pass-$(basename "$t")" \
45     cargo run -- -L target/debug -L target/debug/deps -Z no-trans "$t"
46 done
47
48 kcov --verify --merge target/cov "$tmpdir"/*