From b91e9518cd1ea30cd7ef57be8a2d8a341940d6b0 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Mon, 21 Mar 2011 16:14:49 +0100 Subject: [PATCH] Enable htools unittests and coverage reports Since we have two sets of coverage data, we make the naming consistent: - doc/py-coverage for Python coverage - doc/hs-coverage for Haskell coverage We also need to exclude some more dirs from the list of checked directories. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- .gitignore | 4 +++- Makefile.am | 43 ++++++++++++++++++++++++++++++++++------ autotools/run-in-tempdir | 7 +++++++ 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index e76d81da6..ce682e0dc 100644 --- a/.gitignore +++ b/.gitignore @@ -53,7 +53,8 @@ # doc /doc/api /doc/build -/doc/coverage +/doc/py-coverage/ +/doc/hs-coverage/ /doc/html /doc/install-quick.rst /doc/news.rst @@ -105,5 +106,6 @@ /htools/*.prof* /htools/*.stat /htools/*.tix +/.hpc/ /htools/Ganeti/HTools/Version.hs diff --git a/Makefile.am b/Makefile.am index deaebf7e4..17a52c151 100644 --- a/Makefile.am +++ b/Makefile.am @@ -75,7 +75,9 @@ DIRS = \ BUILDTIME_DIR_AUTOCREATE = \ scripts \ doc/api \ - doc/coverage + doc/py-coverage \ + doc/hs-coverage \ + .hpc BUILDTIME_DIRS = \ $(BUILDTIME_DIR_AUTOCREATE) \ @@ -122,7 +124,8 @@ CLEANFILES = \ tools/kvm-ifup \ stamp-srclinks \ $(nodist_pkgpython_PYTHON) \ - $(HALLPROGS) $(HSRCS2) + $(HALLPROGS) $(HSRCS2) \ + .hpc/*.mix htools/*.tix # BUILT_SOURCES should only be used as a dependency on phony targets. Otherwise # it'll cause the target to rebuild every time. @@ -283,7 +286,10 @@ HALLPROGS = $(HPROGS) htools/test HSRCPROGS = $(patsubst %,%.hs,$(HALLPROGS)) # we don't add -Werror by default HFLAGS = -O -Wall -fwarn-monomorphism-restriction -fwarn-tabs -ihtools +# extra flags that can be overriden on the command line HEXTRA = +# exclude options for coverage reports +HPCEXCL = --exclude Main --exclude Ganeti.HTools.QC HSRCS = \ htools/Ganeti/HTools/CLI.hs \ @@ -418,6 +424,11 @@ $(HALLPROGS): %: %.hs $(HSRCS) $(HSRCS2) Makefile -osuf $$BINARY.o -hisuf $$BINARY.hi \ $@ +# for the htools/test binary, we need to enable profiling/coverage +htools/test: HEXTRA=-fhpc -Wwarn -fno-warn-missing-signatures \ + -fno-warn-monomorphism-restriction -fno-warn-orphans \ + -fno-warn-missing-methods -fno-warn-unused-imports + dist_sbin_SCRIPTS = \ tools/ganeti-listrunner @@ -600,6 +611,8 @@ python_tests = \ test/docs_unittest.py \ test/tempfile_fork_unittest.py +haskell_tests = htools/test + dist_TESTS = \ test/check-cert-expired_unittest.bash \ test/daemon-util_unittest.bash \ @@ -608,6 +621,9 @@ dist_TESTS = \ $(python_tests) nodist_TESTS = +if WANT_HTOOLS +nodist_TESTS += $(haskell_tests) +endif TESTS = $(dist_TESTS) $(nodist_TESTS) @@ -997,14 +1013,29 @@ TAGS: $(BUILT_SOURCES) etags -l python - .PHONY: coverage -coverage: $(BUILT_SOURCES) $(python_tests) +if WANT_HTOOLS +coverage: py-coverage hs-coverage +else +coverage: py-coverage +endif + +.PHONY: py-coverage +py-coverage: $(BUILT_SOURCES) $(python_tests) set -e; \ - COVERAGE_FILE=$(CURDIR)/doc/coverage/data \ - TEXT_COVERAGE=$(CURDIR)/doc/coverage/report.txt \ - HTML_COVERAGE=$(CURDIR)/doc/coverage \ + COVERAGE_FILE=$(CURDIR)/doc/py-coverage/data \ + TEXT_COVERAGE=$(CURDIR)/doc/py-coverage/report.txt \ + HTML_COVERAGE=$(CURDIR)/doc/py-coverage \ $(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \ $(python_tests) +.PHONY: hs-coverage +hs-coverage: $(haskell_tests) + cd htools && rm -f *.tix *.mix && ./test + mkdir -p doc/hs-coverage + hpc markup --destdir=doc/hs-coverage htools/test $(HPCEXCL) + hpc report htools/test $(HPCEXCL) + + commit-check: distcheck lint apidoc -include ./Makefile.local diff --git a/autotools/run-in-tempdir b/autotools/run-in-tempdir index 31a696ccc..e32f86339 100755 --- a/autotools/run-in-tempdir +++ b/autotools/run-in-tempdir @@ -1,5 +1,8 @@ #!/bin/bash +# Helper for running things in a temporary directory; used for docs +# building, unittests, etc. + set -e tmpdir=$(mktemp -d -t gntbuild.XXXXXXXX) @@ -7,5 +10,9 @@ trap "rm -rf $tmpdir" EXIT cp -r autotools daemons scripts lib tools test $tmpdir mv $tmpdir/lib $tmpdir/ganeti +mkdir -p $tmpdir/htools +if [ -e htools/test ]; then + cp -p htools/test $tmpdir/htools/ +fi cd $tmpdir && GANETI_TEMP_DIR="$tmpdir" "$@" -- GitLab