Chromium Code Reviews| Index: bin/coverage |
| diff --git a/bin/coverage b/bin/coverage |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..3339c17ce9046127b517b58570de7404ca8c51cc |
| --- /dev/null |
| +++ b/bin/coverage |
| @@ -0,0 +1,47 @@ |
| +#!/bin/sh |
| +# Copyright 2013 Google Inc. |
|
mtklein_C
2016/09/16 19:21:43
:/
hal.canary
2016/09/20 18:19:01
It's based on a copy of a file from 2013.
Done.
|
| +# |
| +# 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" |
|
mtklein_C
2016/09/16 19:21:43
What's the deal with all the quoting? Is $1 or $@
hal.canary
2016/09/20 18:19:01
It's always good habit in shell scripting.
mtklein
2016/09/20 22:38:53
I'm not sure that that's true. If the simple opti
|
| +shift |
| +GCOV=$(realpath tools/gcov_shim) |
| + |
| +QUIET=-q |
| + |
| +DIR="$(mktemp -d "${TMPDIR:-/tmp}/skia_coverage_XXXXXXXXXX")" |
|
mtklein_C
2016/09/16 19:21:43
Why not out/Coverage or somewhere else that lets y
hal.canary
2016/09/20 18:19:01
I had issues with caching while testing. It's fi
|
| + |
| +# Build $EXECUTABLE |
| +bin/sync |
|
mtklein_C
2016/09/16 19:21:43
Are you sure you want this here? Syncing deps can
hal.canary
2016/09/20 18:19:01
Suprising how?
Not syncing deps before building c
mtklein
2016/09/20 22:38:53
It seems like an odd, but perhaps harmless, thing
|
| +bin/fetch-gn |
| +gn gen \ |
| + --args='cc="gcc -fprofile-arcs " cxx="g++ -fprofile-arcs" extra_cflags="-ftest-coverage"' \ |
|
mtklein_C
2016/09/16 19:21:43
We used to use --coverage. What's different here?
hal.canary
2016/09/20 18:19:01
not sure why I changed. `--coverage` works.
Done
|
| + "$DIR"/build |
| +ninja -C "$DIR"/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 "$DIR"/build -d "$DIR"/build -o "$DIR"/baseline -i |
| + |
| +# Running the binary generates the real coverage information, the .gcda files. |
| +"$DIR"/build/"$EXECUTABLE" "$@" |
| + |
| +lcov $QUIET --gcov-tool=$GCOV -c -b "$DIR"/build -d "$DIR"/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 |