OLD | NEW |
---|---|
(Empty) | |
1 #!/bin/sh | |
2 # Copyright 2016 Google Inc. | |
3 # | |
4 # Use of this source code is governed by a BSD-style license that can be | |
5 # found in the LICENSE file. | |
6 | |
7 # Run something like this: | |
8 # $ bin/coverage dm --src tests | |
9 # or | |
10 # $ bin/coverage dm --src gm skp | |
11 | |
12 set -x | |
13 set -e | |
14 | |
15 cd "$(dirname "$0")/.." | |
16 | |
17 EXECUTABLE="$1" | |
18 shift | |
19 GCOV="$(realpath tools/gcov_shim)" | |
mtklein
2016/09/20 22:38:53
When you read this code as it's grouped here, do y
hal.canary
2016/09/26 17:06:22
Done.
| |
20 | |
21 QUIET=-q | |
mtklein
2016/09/20 22:38:53
Why don't we fold this through now?
hal.canary
2016/09/26 17:06:22
Done.
| |
22 | |
23 DIR="$(mktemp -d "${TMPDIR:-/tmp}/skia_coverage_XXXXXXXXXX")" | |
24 BUILD=out/coverage | |
25 | |
26 # Build $EXECUTABLE | |
27 bin/sync | |
28 bin/fetch-gn | |
29 | |
30 #TODO: make this work with Clang. | |
31 CC="gcc" | |
32 CXX="g++" | |
33 FLAGS="--coverage" | |
34 gn gen --args="cc=\"${CC} ${FLAGS}\" cxx=\"${CXX} ${FLAGS}\"" "$BUILD" | |
mtklein
2016/09/20 22:38:53
Might be clearer if you set cc, cxx, extra_cflags,
hal.canary
2016/09/26 17:06:22
Done.
| |
35 | |
36 ninja -C "$BUILD" "$EXECUTABLE" | |
37 | |
38 # Generate a zero-baseline so files not covered by $EXECUTABLE $@ will | |
39 # still show up in the report. This reads the .gcno files that are | |
40 # created at compile time. | |
41 lcov $QUIET --gcov-tool="$GCOV" -c -b "$BUILD" -d "$BUILD" -o "$DIR"/baseline -i | |
42 | |
43 # Running the binary generates the real coverage information, the .gcda files. | |
44 "$BUILD"/"$EXECUTABLE" "$@" | |
45 | |
46 lcov $QUIET --gcov-tool="$GCOV" -c -b "$BUILD" -d "$BUILD" -o "$DIR"/coverage | |
47 | |
48 lcov $QUIET -a "$DIR"/baseline -a "$DIR"/coverage -o "$DIR"/merged | |
49 | |
50 genhtml $QUIET "$DIR"/merged --legend -o "$DIR"/coverage_report --ignore-errors source | |
51 | |
52 xdg-open "$DIR"/coverage_report/index.html | |
53 | |
mtklein
2016/09/20 22:38:53
Might wanna kill off a blank line or two at the en
hal.canary
2016/09/26 17:06:22
Done.
| |
54 | |
OLD | NEW |