Statistics
| Branch: | Tag: | Revision:

root / autotools / gen-coverage @ 387863a5

History | View | Annotate | Download (1.5 kB)

1 27e336af Michael Hanselmann
#!/bin/bash
2 27e336af Michael Hanselmann
#
3 27e336af Michael Hanselmann
4 df69e0a0 Bernardo Dal Seno
# Copyright (C) 2010, 2011 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 da775218 Michael Hanselmann
set -u
23 27e336af Michael Hanselmann
24 27e336af Michael Hanselmann
: ${COVERAGE:=coverage}
25 27e336af Michael Hanselmann
: ${PYTHON:=python}
26 27e336af Michael Hanselmann
: ${COVERAGE_FILE:?}
27 27e336af Michael Hanselmann
: ${TEXT_COVERAGE:?}
28 577b170b Iustin Pop
: ${GANETI_TEMP_DIR:?}
29 27e336af Michael Hanselmann
30 da775218 Michael Hanselmann
reportargs=(
31 da775218 Michael Hanselmann
  '--include=*'
32 da775218 Michael Hanselmann
  '--omit=test/*'
33 da775218 Michael Hanselmann
  )
34 27e336af Michael Hanselmann
35 27e336af Michael Hanselmann
$COVERAGE erase
36 27e336af Michael Hanselmann
37 27e336af Michael Hanselmann
for script; do
38 df69e0a0 Bernardo Dal Seno
  if [[ "$script" == *-runasroot.py ]]; then
39 df69e0a0 Bernardo Dal Seno
    if [[ -z "$FAKEROOT" ]]; then
40 df69e0a0 Bernardo Dal Seno
      echo "FAKEROOT variable not set and needed for $script" >&2
41 df69e0a0 Bernardo Dal Seno
      exit 1
42 df69e0a0 Bernardo Dal Seno
    fi
43 df69e0a0 Bernardo Dal Seno
    cmdprefix="$FAKEROOT"
44 df69e0a0 Bernardo Dal Seno
  else
45 df69e0a0 Bernardo Dal Seno
    cmdprefix=
46 df69e0a0 Bernardo Dal Seno
  fi
47 da775218 Michael Hanselmann
  $cmdprefix $COVERAGE run --branch --append "${reportargs[@]}" $script
48 27e336af Michael Hanselmann
done
49 27e336af Michael Hanselmann
50 27e336af Michael Hanselmann
echo "Writing text report to $TEXT_COVERAGE ..." >&2
51 da775218 Michael Hanselmann
$COVERAGE report "${reportargs[@]}" | tee "$TEXT_COVERAGE"
52 27e336af Michael Hanselmann
53 27e336af Michael Hanselmann
if [[ -n "$HTML_COVERAGE" ]]; then
54 27e336af Michael Hanselmann
  echo "Generating HTML report in $HTML_COVERAGE ..." >&2
55 da775218 Michael Hanselmann
  $COVERAGE html "${reportargs[@]}" -d "$HTML_COVERAGE"
56 27e336af Michael Hanselmann
fi