Skip to content

Instantly share code, notes, and snippets.

@VoQn
Created December 13, 2011 03:32
Show Gist options
  • Save VoQn/1470421 to your computer and use it in GitHub Desktop.
Save VoQn/1470421 to your computer and use it in GitHub Desktop.
Sample cabal configuration for HPC Test Coverage
-- example app.cabal file
Name: app
Version: 1.0
-- ...
Build-type: Simple
Cabal-version: >= 1.2
Tested-with: GHC >= 7.0.2
Library
default-language: Haskell2010
GHC-Options: -Wall -O2
hs-source-dirs: src/
Build-depends: base, mtl, random -- add dependency cabal library
Test-Suite unit-test
default-langurage: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: src/
Main-is: Test.hs
Build-depends: test-framework, test-framework-hunit,
test-framework-quickcheck2, HUnit, QuickCheck
GHC-Options: -fhpc -hpcdir dist/hpc/app-1.0
import Distribution.Simple
main = defaultMain
#! /bin/sh
CABAL_NAME=app
CABAL_VER=1.0
HPC_DIR=dist/hpc/${CABAL_NAME}-${CABAL_VER}
HPC_REPO_DIR=dist/test/unit-test
TEST_DIR=src/UnitTest
TIX=${HPC_REPO_DIR}/unit-test
TEST_MODULES=(`find ${TEST_DIR} -name "*.hs" | sed -e "s/\.hs$//g" | sed -e "s/^src\///g" | sed -e "s/\//\./g"`)
for ITEM in ${TEST_MODULES[@]}
do
EXCLUDES="${EXCLUDES} --exclude ${ITEM}"
done
hpc report ${TIX} ${EXCLUDES} --hpcdir=${HPC_DIR} --xml-output > ${HPC_REPO_DIR}/result.xml
hpc markup ${TIX} ${EXCLUDES} --hpcdir=${HPC_DIR} --destdir=${HPC_REPO_DIR}
open ${HPC_REPO_DIR}/hpc_index.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment