From 19b7b1592947c5a74fbb159c0a0820cc5013a077 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Sat, 29 Dec 2018 12:26:16 -0800 Subject: coverage: use kcov to get coverage for our cc script --- share/spack/qa/bashcov | 12 ++++++++++++ share/spack/qa/setup.sh | 15 ++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100755 share/spack/qa/bashcov (limited to 'share') diff --git a/share/spack/qa/bashcov b/share/spack/qa/bashcov new file mode 100755 index 0000000000..58fa4fe0d0 --- /dev/null +++ b/share/spack/qa/bashcov @@ -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" "$@" diff --git a/share/spack/qa/setup.sh b/share/spack/qa/setup.sh index 4f40904433..4592c7ea85 100755 --- a/share/spack/qa/setup.sh +++ b/share/spack/qa/setup.sh @@ -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="" -- cgit v1.2.3-60-g2f50