tools: clean up coverage report scripts

This commit is contained in:
Simon Michael 2011-04-22 18:47:12 +00:00
parent d0efde5429
commit c8e84b3a3a
3 changed files with 46 additions and 19 deletions

View File

@ -210,10 +210,10 @@ hledgernowarnings:
hledgerp:
ghc --make $(MAIN) -prof -auto-all -o bin/hledgerp $(BUILDFLAGS)
# build the coverage-enabled binary. coverage-enabled .o files are kept
# separate to avoid contamination.
hledgercov:
ghc --make $(MAIN) -fhpc -o bin/hledgercov -outputdir .coverageobjs $(BUILDFLAGS)
# build the -fhpc hledger binary used for coverage reports and heap profiles.
# The associated .o files are kept separate from the regular ones.
hledgerhpc:
ghc --make $(MAIN) -fhpc -o bin/hledgerhpc -outputdir .hledgerhpcobjs $(BUILDFLAGS)
# build the fastest binary we can
hledgeropt:
@ -375,13 +375,19 @@ quickheap: samplejournals hledgerp
hp2ps hledgerp.hp
$(VIEWPS) hledger.ps
# generate a code coverage report
coverage: samplejournals hledgercov
@echo "Generating coverage report with $(COVCMD)"
tools/coverage "markup --destdir=profs/coverage" test
# display a code coverage text report from running hledger COVCMD
quickcoverage:
@echo "Generating code coverage text report for hledger command: $(COVCMD)"
tools/runhledgerhpc "report" $(COVCMD)
# generate a code coverage html report from running hledger COVCMD
coverage: samplejournals hledgerhpc
@echo "Generating code coverage html report for hledger command: $(COVCMD)"
tools/runhledgerhpc "markup --destdir=profs/coverage" $(COVCMD)
cd profs/coverage; rm -f index.html; ln -s hpc_index.html index.html
viewcoverage: coverage
# view the last html code coverage report
viewcoverage:
$(VIEWHTML) profs/coverage/index.html
# get a debug prompt

View File

@ -1,10 +0,0 @@
#!/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("bin/%s %s >/dev/null" % (cov,args))
os.system("hpc %s %s" % (cmd,cov))

31
tools/runhledgerhpc Normal file
View File

@ -0,0 +1,31 @@
#!/usr/bin/env python
# runhledgerhpc "HPCCOMMAND [HPCARGS]" [HLEDGERARGS]
#
# A front-end that resets the tix count, runs hledgerhpc with the
# specified hledger args, and runs hpc with the specified hpc args.
# Should be run from hledger's top source directory.
#
# Eg:
# hledger$ tools/runhledgerhpc report test
# hledger$ tools/runhledgerhpc "markup --destdir=coverage" test 'some unit test'
hledgerhpc="hledgerhpc"
verbosity = 0 # 0=no output, 1=stderr only, 2=stdout+stderr
import sys, os
hpcargs, hledgerargs = sys.argv[1], ' '.join(sys.argv[2:])
# remove old tix files
os.system("rm -f %s.tix" % hledgerhpc)
# run the hpc-enabled binary with the specified hledger arguments to generate tix files
if verbosity<1:
os.system("bin/%s %s >/dev/null 2>&1" % (hledgerhpc,hledgerargs))
elif verbosity==1:
os.system("bin/%s %s >/dev/null" % (hledgerhpc,hledgerargs))
else:
os.system("bin/%s %s" % (hledgerhpc,hledgerargs))
# run the specified hpc command on the tix files
os.system("hpc %s %s" % (hpcargs,hledgerhpc))