Index: bin/coverage |
diff --git a/bin/coverage b/bin/coverage |
new file mode 100755 |
index 0000000000000000000000000000000000000000..724b0d32d3813a944acbace418b10a924d008bc7 |
--- /dev/null |
+++ b/bin/coverage |
@@ -0,0 +1,54 @@ |
+#!/bin/sh |
+# Copyright 2016 Google Inc. |
+# |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+# Run something like this: |
+# $ bin/coverage dm --src tests |
+# or |
+# $ bin/coverage dm --src gm skp |
+ |
+set -x |
+set -e |
+ |
+cd "$(dirname "$0")/.." |
+ |
+EXECUTABLE="$1" |
+shift |
+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.
|
+ |
+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.
|
+ |
+DIR="$(mktemp -d "${TMPDIR:-/tmp}/skia_coverage_XXXXXXXXXX")" |
+BUILD=out/coverage |
+ |
+# Build $EXECUTABLE |
+bin/sync |
+bin/fetch-gn |
+ |
+#TODO: make this work with Clang. |
+CC="gcc" |
+CXX="g++" |
+FLAGS="--coverage" |
+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.
|
+ |
+ninja -C "$BUILD" "$EXECUTABLE" |
+ |
+# Generate a zero-baseline so files not covered by $EXECUTABLE $@ will |
+# still show up in the report. This reads the .gcno files that are |
+# created at compile time. |
+lcov $QUIET --gcov-tool="$GCOV" -c -b "$BUILD" -d "$BUILD" -o "$DIR"/baseline -i |
+ |
+# Running the binary generates the real coverage information, the .gcda files. |
+"$BUILD"/"$EXECUTABLE" "$@" |
+ |
+lcov $QUIET --gcov-tool="$GCOV" -c -b "$BUILD" -d "$BUILD" -o "$DIR"/coverage |
+ |
+lcov $QUIET -a "$DIR"/baseline -a "$DIR"/coverage -o "$DIR"/merged |
+ |
+genhtml $QUIET "$DIR"/merged --legend -o "$DIR"/coverage_report --ignore-errors source |
+ |
+xdg-open "$DIR"/coverage_report/index.html |
+ |
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.
|
+ |