Commit b91e9518 authored by Iustin Pop's avatar Iustin Pop

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: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent d5506465
...@@ -53,7 +53,8 @@ ...@@ -53,7 +53,8 @@
# doc # doc
/doc/api /doc/api
/doc/build /doc/build
/doc/coverage /doc/py-coverage/
/doc/hs-coverage/
/doc/html /doc/html
/doc/install-quick.rst /doc/install-quick.rst
/doc/news.rst /doc/news.rst
...@@ -105,5 +106,6 @@ ...@@ -105,5 +106,6 @@
/htools/*.prof* /htools/*.prof*
/htools/*.stat /htools/*.stat
/htools/*.tix /htools/*.tix
/.hpc/
/htools/Ganeti/HTools/Version.hs /htools/Ganeti/HTools/Version.hs
...@@ -75,7 +75,9 @@ DIRS = \ ...@@ -75,7 +75,9 @@ DIRS = \
BUILDTIME_DIR_AUTOCREATE = \ BUILDTIME_DIR_AUTOCREATE = \
scripts \ scripts \
doc/api \ doc/api \
doc/coverage doc/py-coverage \
doc/hs-coverage \
.hpc
BUILDTIME_DIRS = \ BUILDTIME_DIRS = \
$(BUILDTIME_DIR_AUTOCREATE) \ $(BUILDTIME_DIR_AUTOCREATE) \
...@@ -122,7 +124,8 @@ CLEANFILES = \ ...@@ -122,7 +124,8 @@ CLEANFILES = \
tools/kvm-ifup \ tools/kvm-ifup \
stamp-srclinks \ stamp-srclinks \
$(nodist_pkgpython_PYTHON) \ $(nodist_pkgpython_PYTHON) \
$(HALLPROGS) $(HSRCS2) $(HALLPROGS) $(HSRCS2) \
.hpc/*.mix htools/*.tix
# BUILT_SOURCES should only be used as a dependency on phony targets. Otherwise # BUILT_SOURCES should only be used as a dependency on phony targets. Otherwise
# it'll cause the target to rebuild every time. # it'll cause the target to rebuild every time.
...@@ -283,7 +286,10 @@ HALLPROGS = $(HPROGS) htools/test ...@@ -283,7 +286,10 @@ HALLPROGS = $(HPROGS) htools/test
HSRCPROGS = $(patsubst %,%.hs,$(HALLPROGS)) HSRCPROGS = $(patsubst %,%.hs,$(HALLPROGS))
# we don't add -Werror by default # we don't add -Werror by default
HFLAGS = -O -Wall -fwarn-monomorphism-restriction -fwarn-tabs -ihtools HFLAGS = -O -Wall -fwarn-monomorphism-restriction -fwarn-tabs -ihtools
# extra flags that can be overriden on the command line
HEXTRA = HEXTRA =
# exclude options for coverage reports
HPCEXCL = --exclude Main --exclude Ganeti.HTools.QC
HSRCS = \ HSRCS = \
htools/Ganeti/HTools/CLI.hs \ htools/Ganeti/HTools/CLI.hs \
...@@ -418,6 +424,11 @@ $(HALLPROGS): %: %.hs $(HSRCS) $(HSRCS2) Makefile ...@@ -418,6 +424,11 @@ $(HALLPROGS): %: %.hs $(HSRCS) $(HSRCS2) Makefile
-osuf $$BINARY.o -hisuf $$BINARY.hi \ -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 = \ dist_sbin_SCRIPTS = \
tools/ganeti-listrunner tools/ganeti-listrunner
...@@ -600,6 +611,8 @@ python_tests = \ ...@@ -600,6 +611,8 @@ python_tests = \
test/docs_unittest.py \ test/docs_unittest.py \
test/tempfile_fork_unittest.py test/tempfile_fork_unittest.py
haskell_tests = htools/test
dist_TESTS = \ dist_TESTS = \
test/check-cert-expired_unittest.bash \ test/check-cert-expired_unittest.bash \
test/daemon-util_unittest.bash \ test/daemon-util_unittest.bash \
...@@ -608,6 +621,9 @@ dist_TESTS = \ ...@@ -608,6 +621,9 @@ dist_TESTS = \
$(python_tests) $(python_tests)
nodist_TESTS = nodist_TESTS =
if WANT_HTOOLS
nodist_TESTS += $(haskell_tests)
endif
TESTS = $(dist_TESTS) $(nodist_TESTS) TESTS = $(dist_TESTS) $(nodist_TESTS)
...@@ -997,14 +1013,29 @@ TAGS: $(BUILT_SOURCES) ...@@ -997,14 +1013,29 @@ TAGS: $(BUILT_SOURCES)
etags -l python - etags -l python -
.PHONY: coverage .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; \ set -e; \
COVERAGE_FILE=$(CURDIR)/doc/coverage/data \ COVERAGE_FILE=$(CURDIR)/doc/py-coverage/data \
TEXT_COVERAGE=$(CURDIR)/doc/coverage/report.txt \ TEXT_COVERAGE=$(CURDIR)/doc/py-coverage/report.txt \
HTML_COVERAGE=$(CURDIR)/doc/coverage \ HTML_COVERAGE=$(CURDIR)/doc/py-coverage \
$(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \ $(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
$(python_tests) $(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 commit-check: distcheck lint apidoc
-include ./Makefile.local -include ./Makefile.local
......
#!/bin/bash #!/bin/bash
# Helper for running things in a temporary directory; used for docs
# building, unittests, etc.
set -e set -e
tmpdir=$(mktemp -d -t gntbuild.XXXXXXXX) tmpdir=$(mktemp -d -t gntbuild.XXXXXXXX)
...@@ -7,5 +10,9 @@ trap "rm -rf $tmpdir" EXIT ...@@ -7,5 +10,9 @@ trap "rm -rf $tmpdir" EXIT
cp -r autotools daemons scripts lib tools test $tmpdir cp -r autotools daemons scripts lib tools test $tmpdir
mv $tmpdir/lib $tmpdir/ganeti 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" "$@" cd $tmpdir && GANETI_TEMP_DIR="$tmpdir" "$@"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment