From 23b05ddceceabfcbb006a4df912dda613ee96dfc Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Thu, 10 Aug 2017 23:33:47 -0400 Subject: [PATCH 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 2052f719d1..de6365cb4f 100644 --- a/.gitignore +++ b/.gitignore @@ -19,7 +19,7 @@ objfiles.txt .deps/ *.gcno *.gcda -lcov.info +lcov*.info coverage/ coverage-stamp *.vcproj diff --git a/src/Makefile.global.in b/src/Makefile.global.in index 9e162c40f0..70e92ee800 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -863,19 +863,32 @@ endif # enable_nls # (by gcc -ftest-coverage) # foo.gcda gcov data file, created when the program is run (for # programs compiled with gcc -fprofile-arcs) -# 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) +LCOV += --gcov-tool $(GCOV) +LCOVFLAGS = --no-external + +gcno_files = $(shell find . -name '*.gcno' -print) + +lcov_base.info: $(gcno_files) + $(LCOV) $(LCOVFLAGS) -c -i -d . -o $@ + gcda_files = $(shell find . -name '*.gcda' -print) -lcov.info: $(gcda_files) - $(LCOV) -d . -c -o $@ $(LCOVFLAGS) --gcov-tool $(GCOV) --no-external +lcov_test.info: $(gcda_files) + $(LCOV) $(LCOVFLAGS) -c -d . -o $@ -coverage-stamp: lcov.info +coverage-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 $@ .PHONY: coverage coverage-html @@ -888,7 +901,7 @@ clean distclean maintainer-clean: clean-coverage .PHONY: clean-coverage clean-coverage: rm -rf coverage/ coverage-stamp - rm -f *.gcda *.gcno lcov.info + rm -f *.gcda *.gcno lcov*.info # User-callable target to reset counts between test runs -- 2.14.0