aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2017-08-10 23:33:47 -0400
committerPeter Eisentraut <peter_e@gmx.net>2017-09-29 08:54:34 -0400
commit4bb5a2536bcff5dfef9242818979faaa0659b1af (patch)
tree1c33379661fb4d0daca5760850352e8a234d4fcc
parent22d9764646d03ac7d3419c4fd0effd256568c922 (diff)
downloadpostgresql-4bb5a2536bcff5dfef9242818979faaa0659b1af.tar.gz
postgresql-4bb5a2536bcff5dfef9242818979faaa0659b1af.zip
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. Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
-rw-r--r--.gitignore2
-rw-r--r--src/Makefile.global.in25
2 files changed, 20 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore
index 94e2c582f51..a59e3da3bef 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 2b22f0de299..c0a88c91527 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