root / autotools / gen-coverage @ 20571a26
History | View | Annotate | Download (1.3 kB)
1 | 27e336af | Michael Hanselmann | #!/bin/bash |
---|---|---|---|
2 | 27e336af | Michael Hanselmann | # |
3 | 27e336af | Michael Hanselmann | |
4 | 27e336af | Michael Hanselmann | # Copyright (C) 2010 Google Inc. |
5 | 27e336af | Michael Hanselmann | # |
6 | 27e336af | Michael Hanselmann | # This program is free software; you can redistribute it and/or modify |
7 | 27e336af | Michael Hanselmann | # it under the terms of the GNU General Public License as published by |
8 | 27e336af | Michael Hanselmann | # the Free Software Foundation; either version 2 of the License, or |
9 | 27e336af | Michael Hanselmann | # (at your option) any later version. |
10 | 27e336af | Michael Hanselmann | # |
11 | 27e336af | Michael Hanselmann | # This program is distributed in the hope that it will be useful, but |
12 | 27e336af | Michael Hanselmann | # WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | 27e336af | Michael Hanselmann | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | 27e336af | Michael Hanselmann | # General Public License for more details. |
15 | 27e336af | Michael Hanselmann | # |
16 | 27e336af | Michael Hanselmann | # You should have received a copy of the GNU General Public License |
17 | 27e336af | Michael Hanselmann | # along with this program; if not, write to the Free Software |
18 | 27e336af | Michael Hanselmann | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
19 | 27e336af | Michael Hanselmann | # 02110-1301, USA. |
20 | 27e336af | Michael Hanselmann | |
21 | 27e336af | Michael Hanselmann | set -e |
22 | 27e336af | Michael Hanselmann | |
23 | 27e336af | Michael Hanselmann | : ${COVERAGE:=coverage} |
24 | 27e336af | Michael Hanselmann | : ${PYTHON:=python} |
25 | 27e336af | Michael Hanselmann | : ${COVERAGE_FILE:?} |
26 | 27e336af | Michael Hanselmann | : ${TEXT_COVERAGE:?} |
27 | 27e336af | Michael Hanselmann | |
28 | 27e336af | Michael Hanselmann | omit=$($PYTHON -c 'import sys; |
29 | 27e336af | Michael Hanselmann | print " ".join(["--omit=%s/" % i for i in |
30 | 27e336af | Michael Hanselmann | set([sys.prefix, sys.exec_prefix])])') |
31 | 27e336af | Michael Hanselmann | |
32 | 27e336af | Michael Hanselmann | $COVERAGE erase |
33 | 27e336af | Michael Hanselmann | |
34 | 27e336af | Michael Hanselmann | for script; do |
35 | 27e336af | Michael Hanselmann | $COVERAGE run --branch --append $script |
36 | 27e336af | Michael Hanselmann | done |
37 | 27e336af | Michael Hanselmann | |
38 | 27e336af | Michael Hanselmann | echo "Writing text report to $TEXT_COVERAGE ..." >&2 |
39 | 27e336af | Michael Hanselmann | $COVERAGE report $omit | tee "$TEXT_COVERAGE" |
40 | 27e336af | Michael Hanselmann | |
41 | 27e336af | Michael Hanselmann | if [[ -n "$HTML_COVERAGE" ]]; then |
42 | 27e336af | Michael Hanselmann | echo "Generating HTML report in $HTML_COVERAGE ..." >&2 |
43 | 27e336af | Michael Hanselmann | $COVERAGE html $omit -d "$HTML_COVERAGE" |
44 | 27e336af | Michael Hanselmann | fi |