Skip to content

Commit

Permalink
coverage: use kcov to get coverage for our cc script
Browse files Browse the repository at this point in the history
  • Loading branch information
tgamblin committed Dec 30, 2018
1 parent 51cbc27 commit 19b7b15
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
1 change: 0 additions & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ coverage:

ignore:
- lib/spack/spack/test/.*
- lib/spack/env/.*
- lib/spack/docs/.*
- lib/spack/external/.*

Expand Down
1 change: 0 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ branch = True
source = lib
omit =
lib/spack/spack/test/*
lib/spack/env/*
lib/spack/docs/*
lib/spack/external/*

Expand Down
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,19 @@ addons:
apt:
packages:
- ccache
- cmake
- gfortran
- mercurial
- graphviz
- gnupg2
- cmake
- kcov
- mercurial
- ninja-build
- perl
- perl-base
- realpath
- r-base
- r-base-core
- r-base-dev
- perl
- perl-base
# for Mac builds, we use Homebrew
homebrew:
packages:
Expand Down
12 changes: 12 additions & 0 deletions share/spack/qa/bashcov
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
#
# This script acts like bash but runs kcov on the input script. We use it
# to get coverage for Spack's bash scripts.
#

if [ -z "$SPACK_ROOT" ]; then
echo "ERROR: SPACK_ROOT was not set!"
exit 1
fi

kcov "$SPACK_ROOT/coverage" "$@"
15 changes: 14 additions & 1 deletion share/spack/qa/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,28 @@
#

QA_DIR="$(dirname ${BASH_SOURCE[0]})"
SPACK_ROOT="$QA_DIR/../../.."
export SPACK_ROOT=$(realpath "$QA_DIR/../../..")

# Source the setup script
. "$SPACK_ROOT/share/spack/setup-env.sh"

# Set up some variables for running coverage tests.
if [[ "$TEST_SUITE" == "unit" || "$TEST_SUITE" == "build" ]]; then
# these set up coverage for Python
coverage=coverage
coverage_run="coverage run"

# make a coverage directory for kcov, and patch cc to use our bashcov
# script instead of plain bash
if [[ $TEST_SUITE == unit && # kcov segfaults for the MPICH build test
$TRAVIS_OS_NAME == linux &&
$TRAVIS_PYTHON_VERSION != 2.6 ]];
then
mkdir -p coverage
cc_script="$SPACK_ROOT/lib/spack/env/cc"
bashcov=$(realpath ${QA_DIR}/bashcov)
sed -i~ "s@#\!/bin/bash@#\!${bashcov}@" "$cc_script"
fi
else
coverage=""
coverage_run=""
Expand Down

0 comments on commit 19b7b15

Please sign in to comment.