diff --git a/compute-coverage.sh b/compute-coverage.sh index bd1e12a0d..d86f3fc5a 100755 --- a/compute-coverage.sh +++ b/compute-coverage.sh @@ -14,13 +14,41 @@ set -Eeuxo pipefail # directory containing this script. # Combine .tix files +# Avoid tripping on an existing all.tix from a prior run SUM_TIX="all.tix" -hpc sum --output=$SUM_TIX --union --exclude=Main --exclude=GitRev $(find . -name "*.tix") +hpc sum --output=$SUM_TIX --union --exclude=Main --exclude=GitRev \ + $(find . ! -path ./all.tix -name "*.tix" -print) -# Generate report -HPC_ROOT=$(find dist-newstyle -name "hpc") +# Find the HPC dir, and don't trip on old versions after a version bump. +# See saw-script #2114. +# +# There is no direct way to do this. Instead, fetch the name of the +# SAW executable. This gives us a path into the build directory for +# the current version: +# dist-newstyle/build/$TARGET/ghc-$GHC/saw-script-$VERSION/build/saw/saw +# +# where we don't want to have to try to figure out $TARGET, $GHC, or $VERSION. +# +# The hpc dir we want lives under the saw-script-$VERSION dir, but can be in +# different places with different versions of the tooling. So start there and +# then use find. +# +# -v0 (verbosity 0) prevents cabal from accidentally including extraneous +# data (see saw-script #2103) +SAW=$(cabal list-bin -v0 exe:saw) +SAWSCRIPT=$(echo "$SAW" | sed 's,/build/saw/saw$,,') +HPC_ROOT=$(find "$SAWSCRIPT" -name "hpc" -print) + +# Check if it actually exists, in case it doesn't, and bail with an error +# message instead of generating hpc's usage message. +if ! [ -d "$HPC_ROOT" ]; then + echo "$0: no HPC dir found" 1>&2 + exit 1 +fi + +# Now generate the report HPC_ARGS="" -for dir in ${HPC_ROOT}/vanilla/mix/*; do +for dir in "$HPC_ROOT"/vanilla/mix/*; do HPC_ARGS="${HPC_ARGS} --hpcdir=${dir}" done hpc markup --destdir=hpc-html ${HPC_ARGS} ${SUM_TIX}