Skip to content

Commit

Permalink
Merge pull request #2116 from GaloisInc/2114-coverage-version-bump
Browse files Browse the repository at this point in the history
Fix the way compute-coverage finds the hpc dir in dist-newstyle
  • Loading branch information
sauclovian-g committed Sep 18, 2024
2 parents cfaba80 + d09ca22 commit 9251017
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions compute-coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}

0 comments on commit 9251017

Please sign in to comment.