#!/bin/bash

# To use hpc (Haskell Program Coverage) with darcs you need at least
# ghc 6.8.3.

# You can build darcs with hpc support using --enable-hpc

# Then create a directory and set it as HPCTIXDIR.
# Note that simply building darcs will begin populating
# this directory before you ever run any tests.
# Therefore, clean the directory after building.

mkdir -p hpctixdir
export HPCTIXDIR=${PWD}/hpctixdir

rm -rf ./.hpc

make clean &&
./configure --enable-hpc &&
make darcs &&
#make unit &&
rm -f hpctixdir/*.tix || exit 1

echo "hpc.README: running tests."
make test_network 
#make test_unit
make test_shell_hashed 
make test_shell 
make test_shell_format2
make test_perl 
make test_perl_hashed 
make test_perl_format2
make bugs_shell_hashed
make bugs_shell 
make bugs_shell_format2
make bugs_perl 
make bugs_perl_hashed 
make bugs_perl_format2

echo "hpc.README: summing results."
hpc sum --union --exclude=Main --exclude=Context --exclude=Autoconf --exclude=Workaround hpctixdir/*.tix > darcs-hpc-summed.tix &&

mkdir -p darcs-hpc &&

echo "hpc.README: generating report." &&
hpc markup darcs-hpc-summed.tix --destdir=darcs-hpc
