From 7b2f5087a2d0710e6a5c7ffa946dcfabd163f987 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Thu, 10 Aug 2017 23:33:47 -0400 Subject: [PATCH v2 1/9] Run only top-level recursive lcov This is the way lcov was intended to be used. It is much faster and more robust and makes the makefiles simpler than running it in each subdirectory. This also removes the direct gcov calls and lets lcov do it instead. The direct gcov calls are useless because lcov/geninfo call gcov internally and use that information. --- .gitignore | 3 +-- GNUmakefile.in | 2 +- doc/src/sgml/regress.sgml | 2 +- src/Makefile.global.in | 33 +++++++++++---------------------- 4 files changed, 14 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index 4976fd9119..2052f719d1 100644 --- a/.gitignore +++ b/.gitignore @@ -19,10 +19,9 @@ objfiles.txt .deps/ *.gcno *.gcda -*.gcov -*.gcov.out lcov.info coverage/ +coverage-stamp *.vcproj *.vcxproj win32ver.rc diff --git a/GNUmakefile.in b/GNUmakefile.in index dc76a5d11d..8d77b01eea 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -41,7 +41,7 @@ install-world-contrib-recurse: install-world-src-recurse $(call recurse,installdirs uninstall init-po update-po,doc src config) -$(call recurse,distprep coverage,doc src config contrib) +$(call recurse,distprep,doc src config contrib) # clean, distclean, etc should apply to contrib too, even though # it's not built by default diff --git a/doc/src/sgml/regress.sgml b/doc/src/sgml/regress.sgml index 7c2b1029c2..796cdc26ff 100644 --- a/doc/src/sgml/regress.sgml +++ b/doc/src/sgml/regress.sgml @@ -699,7 +699,7 @@ Test Coverage Examination ./configure --enable-coverage ... OTHER OPTIONS ... make make check # or other test suite -make coverage-html +make coverage Then point your HTML browser to coverage/index.html. diff --git a/src/Makefile.global.in b/src/Makefile.global.in index e8b3a519cb..e39ed884e7 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -19,7 +19,7 @@ # # Meta configuration -standard_targets = all install installdirs uninstall distprep clean distclean maintainer-clean coverage check installcheck init-po update-po +standard_targets = all install installdirs uninstall distprep clean distclean maintainer-clean check installcheck init-po update-po # these targets should recurse even into subdirectories not being built: standard_always_targets = distprep clean distclean maintainer-clean @@ -863,34 +863,23 @@ 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) -# foo.c.gcov gcov output file with coverage information, created by -# 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, # later collected by "make coverage-html" ifeq ($(enable_coverage), yes) -# There is a strange interaction between lcov and existing .gcov -# output files. Hence the rm command and the ordering dependency. - -gcda_files := $(wildcard *.gcda) +gcda_files = $(shell find . -name '*.gcda' -print) lcov.info: $(gcda_files) - rm -f *.gcov .*.gcov - $(if $^,$(LCOV) -d . -c -o $@ $(LCOVFLAGS) --gcov-tool $(GCOV)) - -%.c.gcov: %.gcda | lcov.info - $(GCOV) -b -f -p -o . $(GCOVFLAGS) $*.c >$*.c.gcov.out - -coverage: $(gcda_files:.gcda=.c.gcov) lcov.info + $(LCOV) -d . -c -o $@ $(LCOVFLAGS) --gcov-tool $(GCOV) -.PHONY: coverage-html -coverage-html: coverage +coverage-stamp: lcov.info rm -rf coverage - mkdir coverage - $(GENHTML) --show-details --legend --output-directory=coverage --title=PostgreSQL --num-spaces=4 --prefix=$(abs_top_srcdir) `find . -name lcov.info -print` + $(GENHTML) --show-details --legend --output-directory=coverage --title=PostgreSQL --num-spaces=4 --prefix=$(abs_top_srcdir) $< + touch $@ + +.PHONY: coverage coverage-html +coverage coverage-html: coverage-stamp # hook for clean-up @@ -898,8 +887,8 @@ clean distclean maintainer-clean: clean-coverage .PHONY: clean-coverage clean-coverage: - rm -rf coverage - rm -f *.gcda *.gcno lcov.info *.gcov .*.gcov *.gcov.out + rm -rf coverage/ coverage-stamp + rm -f *.gcda *.gcno lcov.info # User-callable target to reset counts between test runs base-commit: 2bfd1b1ee562c4e4fd065c7f7d1beaa9b9852070 -- 2.14.1