From bca43e4dc3f439463a01e3d1458878cd0c45f7ce Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Thu, 10 Aug 2017 23:33:47 -0400 Subject: [PATCH v3 3/9] Add lcov --initial By just running lcov on the produced .gcda data files, we don't account for source files that are not touched by tests at all. To fix that, run lcov --initial to create a base line info file with all zero counters, and merge that with the actual counters when creating the final report. --- .gitignore | 2 +- src/Makefile.global.in | 25 +++++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 94e2c582f5..a59e3da3be 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,7 @@ objfiles.txt *.gcda *.gcov *.gcov.out -lcov.info +lcov*.info coverage/ coverage-html-stamp *.vcproj diff --git a/src/Makefile.global.in b/src/Makefile.global.in index 2b22f0de29..c0a88c9152 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -869,8 +869,13 @@ endif # enable_nls # gcov from foo.gcda (by "make coverage") # foo.c.gcov.out stdout captured when foo.c.gcov is created, mildly # interesting -# lcov.info lcov tracefile, built from gcda files in one directory, +# lcov_test.info +# lcov tracefile, built from gcda files in one directory, # later collected by "make coverage-html" +# lcov_base.info +# tracefile for zero counters for every file, so that +# even files that are not touched by tests are counted +# for the overall coverage rate ifeq ($(enable_coverage), yes) @@ -888,15 +893,23 @@ coverage: $(local_gcda_files:.gcda=.c.gcov) .PHONY: coverage-html coverage-html: coverage-html-stamp -coverage-html-stamp: lcov.info +coverage-html-stamp: lcov_base.info lcov_test.info rm -rf coverage - $(GENHTML) --show-details --legend --output-directory=coverage --title=PostgreSQL --num-spaces=4 --prefix=$(abs_top_srcdir) $< + $(GENHTML) --show-details --legend --output-directory=coverage --title=PostgreSQL --num-spaces=4 --prefix=$(abs_top_srcdir) $^ touch $@ +LCOV += --gcov-tool $(GCOV) +LCOVFLAGS = --no-external + +all_gcno_files = $(shell find . -name '*.gcno' -print) + +lcov_base.info: $(all_gcno_files) + $(LCOV) $(LCOVFLAGS) -c -i -d . -o $@ + all_gcda_files = $(shell find . -name '*.gcda' -print) -lcov.info: $(all_gcda_files) - $(LCOV) -d . -c -o $@ $(LCOVFLAGS) --gcov-tool $(GCOV) --no-external +lcov_test.info: $(all_gcda_files) + $(LCOV) $(LCOVFLAGS) -c -d . -o $@ # hook for clean-up @@ -905,7 +918,7 @@ clean distclean maintainer-clean: clean-coverage .PHONY: clean-coverage clean-coverage: rm -rf coverage coverage-html-stamp - rm -f *.gcda *.gcno lcov.info *.gcov .*.gcov *.gcov.out + rm -f *.gcda *.gcno lcov*.info *.gcov .*.gcov *.gcov.out # User-callable target to reset counts between test runs -- 2.14.1