"make coverage" now generates a nice html report of test coverage

This commit is contained in:
Simon Michael 2009-06-04 01:33:31 +00:00
parent ce78ce8f3d
commit 7aaa2c5ad0
2 changed files with 53 additions and 36 deletions

View File

@ -5,11 +5,14 @@ OPTFLAGS=-DHAPPS -DVTY
# command to run during "make ci" # command to run during "make ci"
CICMD=test CICMD=test
#CICMD=web --debug -BE CICMD=web --debug -BE
# command to run during "make prof" # command to run during "make prof/heap"
PROFCMD=-f 1000x1000x10.ledger balance PROFCMD=-f 1000x1000x10.ledger balance
# command to run during "make coverage"
COVCMD=test
# executables to run during "make benchtest" (prepend ./ if not in $PATH) # executables to run during "make benchtest" (prepend ./ if not in $PATH)
BENCHEXES=hledger-0.5 hledger-0.6 ledger BENCHEXES=hledger-0.5 hledger-0.6 ledger
@ -28,7 +31,7 @@ TIME:=$(shell date +"%Y%m%d%H%M")
default: tag hledger default: tag hledger
###################################################################### ######################################################################
# BUILDING, DEBUGGING # BUILDING
# build the standard developer's binary, quickly # build the standard developer's binary, quickly
hledger: setversion hledger: setversion
@ -37,11 +40,11 @@ hledger: setversion
# build the profiling-enabled binary. You may need to cabal install # build the profiling-enabled binary. You may need to cabal install
# --reinstall -p some libs. # --reinstall -p some libs.
hledgerp: setversion hledgerp: setversion
ghc --make hledger.hs -prof -auto-all -o hledgerp #$(BUILDFLAGS) ghc --make hledger.hs -prof -auto-all -o hledgerp $(BUILDFLAGS)
# build the coverage-enabled binary (untested) # build the coverage-enabled binary. Warning, might need make clean
hledgercov: setversion hledgercov: setversion
ghc --make hledger.hs -hpc -o hledgercov $(BUILDFLAGS) ghc --make hledger.hs -fhpc -o hledgercov $(BUILDFLAGS)
# build the fastest binary we can # build the fastest binary we can
hledgeropt: setversion hledgeropt: setversion
@ -82,35 +85,6 @@ tools/doctest: tools/doctest.hs
tools/generateledger: tools/generateledger.hs tools/generateledger: tools/generateledger.hs
ghc --make tools/generateledger.hs ghc --make tools/generateledger.hs
# get a debug prompt
ghci:
ghci hledger.hs
# generate, save and display a standard profile
prof: sampleledgers hledgerp
@echo "Profiling $(PROFCMD)"
./hledgerp +RTS -p -RTS $(PROFCMD) >/dev/null
mv hledgerp.prof profs/$(TIME)-orig.prof
tools/simplifyprof.hs profs/$(TIME)-orig.prof >profs/$(TIME).prof
(cd profs; rm -f latest*.prof; ln -s $(TIME)-orig.prof latest-orig.prof; ln -s $(TIME).prof latest.prof)
echo; cat profs/latest.prof
# generate, save and display a graphical heap profile
heap: sampleledgers hledgerp
@echo "Profiling heap with $(PROFCMD)"
./hledgerp +RTS -hc -RTS $(PROFCMD) >/dev/null
mv hledgerp.hp profs/$(TIME).hp
(cd profs; rm -f latest.hp; ln -s $(TIME).hp latest.hp; \
hp2ps $(TIME).hp; rm -f latest.ps; ln -s $(TIME).ps latest.ps)
$(VIEWPSCMD) profs/latest.ps
# generate, save and display a code coverage report (untested)
coverage: sampleledgers hledgercov
@echo "Generating coverage report with $(PROFCMD)"
./hledgercov $(PROFCMD) >/dev/null
hpc report hledgercov
#hpc markup hledgercov
###################################################################### ######################################################################
# TESTING # TESTING
@ -137,6 +111,35 @@ benchtest: sampleledgers bench.tests tools/bench
@rm -f benchresults.* @rm -f benchresults.*
@(cd profs; rm -f latest.bench; ln -s $(TIME).bench latest.bench) @(cd profs; rm -f latest.bench; ln -s $(TIME).bench latest.bench)
# get a debug prompt
ghci:
ghci hledger.hs
# generate, save and display a standard profile
prof: sampleledgers hledgerp
@echo "Profiling $(PROFCMD)"
./hledgerp +RTS -p -RTS $(PROFCMD) >/dev/null
mv hledgerp.prof profs/$(TIME)-orig.prof
tools/simplifyprof.hs profs/$(TIME)-orig.prof >profs/$(TIME).prof
(cd profs; rm -f latest*.prof; ln -s $(TIME)-orig.prof latest-orig.prof; ln -s $(TIME).prof latest.prof)
echo; cat profs/latest.prof
# generate, save and display a graphical heap profile
heap: sampleledgers hledgerp
@echo "Profiling heap with $(PROFCMD)"
./hledgerp +RTS -hc -RTS $(PROFCMD) >/dev/null
mv hledgerp.hp profs/$(TIME).hp
(cd profs; rm -f latest.hp; ln -s $(TIME).hp latest.hp; \
hp2ps $(TIME).hp; rm -f latest.ps; ln -s $(TIME).ps latest.ps)
$(VIEWPSCMD) profs/latest.ps
# generate and display a code coverage report
coverage: sampleledgers hledgercov
@echo "Generating coverage report with $(COVCMD)"
tools/coverage "markup --destdir=profs/coverage" test
cd profs/coverage; rm -f index.html; ln -s hpc_index.html index.html
$(VIEWHTMLCMD) profs/coverage/index.html
# generate standard sample ledgers # generate standard sample ledgers
sampleledgers: sample.ledger 100x100x10.ledger 1000x1000x10.ledger 10000x1000x10.ledger 100000x1000x10.ledger sampleledgers: sample.ledger 100x100x10.ledger 1000x1000x10.ledger 10000x1000x10.ledger 100000x1000x10.ledger
@ -353,7 +356,7 @@ pushbinary:
rsync -aP $(BINARYFILENAME).gz joyful.com:/repos/hledger/website/binaries/ rsync -aP $(BINARYFILENAME).gz joyful.com:/repos/hledger/website/binaries/
# show project stats useful for release notes # show project stats useful for release notes
stats: showlastreleasedate showreleaseauthors showloc showerrors showlocalchanges showreleasechanges benchtest stats: showlastreleasedate showreleaseauthors showloc showcov showerrors showlocalchanges showreleasechanges benchtest
showreleaseauthors: showreleaseauthors:
@echo Patch authors since last release: @echo Patch authors since last release:
@ -367,6 +370,10 @@ showloc:
@sloccount Tests.hs | grep haskell: @sloccount Tests.hs | grep haskell:
@echo @echo
showcov:
@echo Test coverage:
@tools/coverage report test
showlastreleasedate: showlastreleasedate:
@echo Last release date: @echo Last release date:
@darcs changes --from-tag . | tail -2 @darcs changes --from-tag . | tail -2

10
tools/coverage Normal file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env python
# usage: hledger$ tools/coverage HPCCOMMAND HLEDGERARGS
# A front-end for hledgercov/hpc. Resets the tix count on each invocation.
import sys, os
cov="hledgercov"
cmd, args = sys.argv[1], ' '.join(sys.argv[2:])
os.system("rm -f %s.tix" % cov)
os.system("./%s %s >/dev/null" % (cov,args))
os.system("hpc %s %s" % (cmd,cov))