# HG changeset patch # User Mike Miller # Date 1468509242 25200 # Node ID 57ca47db75ec02243b1f621028d9594b074ff187 # Parent 783d5fb468924c11672023df2f9891352ec4a366 build: add 'make coverage' target to build code coverage report * test/module.mk (coverage): New target to build coverage report using gcc gcov, lcov, and genhtml. (COVERAGE_DIR, COVERAGE_INFO): New variables. (test-clean): Delete $(COVERAGE_DIR) on 'make clean'. diff -r 783d5fb46892 -r 57ca47db75ec test/module.mk --- a/test/module.mk Thu Jul 14 08:02:24 2016 -0700 +++ b/test/module.mk Thu Jul 14 08:14:02 2016 -0700 @@ -68,6 +68,30 @@ cd test && $(SHELL) ../run-octave $(RUN_OCTAVE_OPTIONS) --jit-compiler --norc --silent --no-history $(abs_top_srcdir)/test/fntests.m $(abs_top_srcdir)/test endif +COVERAGE_DIR = test/coverage +COVERAGE_INFO = $(COVERAGE_DIR)/$(PACKAGE).info + +## FIXME: To get something useful out of 'make coverage', you should use gcc +## and configure with compiler flags set to '-g --coverage'. Adding the +## --coverage option to either WARN_CXXFLAGS or XTRA_CXXFLAGS resulted in +## link errors, so some work still needed to get a '--enable-coverage-flags' +## option working. + +coverage: all + lcov --directory . --zerocounters + $(MAKE) $(AM_MAKEFLAGS) check + $(MKDIR_P) $(COVERAGE_DIR) + lcov --directory . --capture --output-file $(COVERAGE_INFO) + genhtml --output-directory $(COVERAGE_DIR) $(COVERAGE_INFO) + @echo "" + @echo "Code coverage report successfully built. Open the file" + @echo "" + @echo " $(abs_top_builddir)/$(COVERAGE_DIR)/index.html" + @echo "" + @echo "in a web browser to view the results." + @echo "" +.PHONY: coverage + test/sparse.tst: test/build-sparse-tests.sh | test/$(octave_dirstamp) $(AM_V_GEN)rm -f $@-t $@ && \ $(SHELL) $(srcdir)/test/build-sparse-tests.sh > $@-t && \ @@ -145,6 +169,7 @@ test-clean: rm -f $(test_CLEANFILES) rm -rf $(GENERATED_BC_OVERLOADS_DIRS) + rm -rf $(COVERAGE_DIR) test-distclean: test-clean rm -f $(test_DISTCLEANFILES)