Expand test coverage support to entire tree
authorPeter Eisentraut <peter_e@gmx.net>
Fri, 7 Aug 2009 20:50:22 +0000 (20:50 +0000)
committerPeter Eisentraut <peter_e@gmx.net>
Fri, 7 Aug 2009 20:50:22 +0000 (20:50 +0000)
Test coverage support now covers the entire source tree, including
contrib, instead of just src/backend.  In a related but independent
development, the commands make coverage and make coverage-html can be run
in any directory.

This turned out to be much easier than feared.  Besides a few ad hoc fixes
to pass the make target down the tree, change all affected makefiles to
list their directories in the SUBDIRS variable, changed from variants like
DIRS and WANTED_DIRS.  MSVC build fix was attempted as well.

12 files changed:
GNUmakefile.in
contrib/Makefile
doc/src/sgml/regress.sgml
src/Makefile
src/Makefile.global.in
src/backend/common.mk
src/backend/utils/mb/conversion_procs/Makefile
src/bin/Makefile
src/interfaces/Makefile
src/pl/Makefile
src/pl/plpgsql/Makefile
src/tools/msvc/Mkvcbuild.pm

index 3045a4e47e31b0fbc32643d3d2422a8851b1b50a..342ac1a203b04c0585845b3eeac47c62abc9e131 100644 (file)
@@ -20,7 +20,7 @@ install:
        $(MAKE) -C config $@
        @echo "PostgreSQL installation complete."
 
-installdirs uninstall:
+installdirs uninstall coverage:
        $(MAKE) -C doc $@
        $(MAKE) -C src $@
        $(MAKE) -C config $@
@@ -61,25 +61,6 @@ GNUmakefile: GNUmakefile.in $(top_builddir)/config.status
        ./config.status $@
 
 
-##########################################################################
-
-coverage:
-       $(MAKE) -C src/backend $@
-
-.PHONY: coverage-html
-coverage-html: coverage
-       rm -rf coverage
-       mkdir coverage
-       $(GENHTML) --show-details --legend --output-directory=coverage --title=PostgreSQL --num-spaces=4 --prefix=$(abs_top_srcdir)/src `find src/backend -name lcov.info -print`
-
-ifeq ($(enable_coverage),yes)
-clean distclean maintainer-clean: clean-coverage-local
-.PHONY: clean-coverage-local
-clean-coverage-local:
-       rm -rf coverage
-endif
-
-
 ##########################################################################
 
 distdir        = postgresql-$(VERSION)
index 738a28a63ade82ceed10d37c8eae1dba8a311fb5..247c4972f0da4690965f71d512118cd8f7617632 100644 (file)
@@ -4,7 +4,7 @@ subdir = contrib
 top_builddir = ..
 include $(top_builddir)/src/Makefile.global
 
-WANTED_DIRS = \
+SUBDIRS = \
                adminpack       \
                auto_explain    \
                btree_gin       \
@@ -42,15 +42,15 @@ WANTED_DIRS = \
                vacuumlo
 
 ifeq ($(with_openssl),yes)
-WANTED_DIRS += sslinfo
+SUBDIRS += sslinfo
 endif
 
 ifeq ($(with_ossp_uuid),yes)
-WANTED_DIRS += uuid-ossp
+SUBDIRS += uuid-ossp
 endif
 
 ifeq ($(with_libxml),yes)
-WANTED_DIRS += xml2
+SUBDIRS += xml2
 endif
 
 # Missing:
@@ -58,13 +58,13 @@ endif
 
 
 all install installdirs uninstall distprep clean distclean maintainer-clean:
-       @for dir in $(WANTED_DIRS); do \
+       @for dir in $(SUBDIRS); do \
                $(MAKE) -C $$dir $@ || exit; \
        done
 
 # We'd like check operations to run all the subtests before failing.
 check installcheck:
-       @CHECKERR=0; for dir in $(WANTED_DIRS); do \
+       @CHECKERR=0; for dir in $(SUBDIRS); do \
                $(MAKE) -C $$dir $@ || CHECKERR=$$?; \
        done; \
        exit $$CHECKERR
index 35e5564bc90113d54b9b8b340b12c88c2549fb89..3203384c6f44d8b20d4de72ae3a3d3375e53def9 100644 (file)
@@ -476,6 +476,7 @@ gmake coverage-html
 </screen>
     Then point your HTML browser
     to <filename>coverage/index.html</filename>.
+    The <command>gmake</command> commands also work in subdirectories.
    </para>
 
    <para>
index acefa7580b04457d2b9b71e7cd2eefa8e023c6a3..bc8eb95b1c804714c461d8474de2bcb941d7c0a1 100644 (file)
@@ -73,5 +73,14 @@ distclean maintainer-clean:
        $(MAKE) -C test/thread $@
        rm -f Makefile.port Makefile.global
 
+coverage:
+       $(MAKE) -C timezone $@
+       $(MAKE) -C backend $@
+       $(MAKE) -C backend/utils/mb/conversion_procs $@
+       $(MAKE) -C backend/snowball $@
+       $(MAKE) -C interfaces $@
+       $(MAKE) -C bin $@
+       $(MAKE) -C pl $@
+
 
 .PHONY: install-local installdirs-local uninstall-local
index 5dee4dda603a1208ab7ae6448c6ebfb95c121734..ab1f49332f01a6ac12e13df51bb203a6fb2fa989 100644 (file)
@@ -617,12 +617,22 @@ lcov.info: $(gcda_files)
 %.c.gcov: %.gcda | lcov.info
        $(GCOV) -b -f -p -o . $(GCOVFLAGS) $*.c >$*.c.gcov.out
 
+coverage: $(gcda_files:.gcda=.c.gcov) lcov.info
+       $(if $(SUBDIRS),for dir in $(SUBDIRS); do $(MAKE) -C $$dir coverage || exit; done)
+
+.PHONY: coverage-html
+coverage-html: coverage
+       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`
+
 
 # hook for clean-up
 clean distclean maintainer-clean: clean-coverage
 
 .PHONY: clean-coverage
 clean-coverage:
+       rm -rf coverage
        rm -f *.gcda *.gcno lcov.info *.gcov *.gcov.out
 
 
index 611a257b15e352be4b38222944dc6e724410b5c1..cf7ff0c583ae9d17b45a80b2ccf7080d1bfd12f4 100644 (file)
@@ -46,9 +46,3 @@ ifdef SUBDIRS
        for dir in $(SUBDIRS); do $(MAKE) -C $$dir clean || exit; done
 endif
        rm -f $(subsysfilename) $(OBJS)
-
-
-coverage: $(gcda_files:.gcda=.c.gcov) lcov.info
-ifdef SUBDIRS
-       for dir in $(SUBDIRS); do $(MAKE) -C $$dir coverage || exit; done
-endif
index 5cf57220df37916f0a07e572bcfcd53a1702c64d..d5ed087e9cd58274bda9e2a019d0b204898b9fc0 100644 (file)
@@ -17,7 +17,7 @@ SQLSCRIPT = conversion_create.sql
 # This file can be placed as src/test/regress/conversion.sql
 REGRESSION_SCRIPT = conversion.sql
 
-DIRS = \
+SUBDIRS = \
        ascii_and_mic cyrillic_and_mic euc_cn_and_mic euc_jp_and_sjis \
        euc_kr_and_mic euc_tw_and_big5 latin2_and_win1250 latin_and_mic \
        utf8_and_ascii utf8_and_big5 utf8_and_cyrillic utf8_and_euc_cn \
@@ -162,7 +162,7 @@ CONVERSIONS = \
                shift_jis_2004_to_euc_jis_2004 SHIFT_JIS_2004 EUC_JIS_2004 shift_jis_2004_to_euc_jis_2004 euc_jis_2004_and_shift_jis_2004
 
 all: $(SQLSCRIPT)
-       @for dir in $(DIRS); do $(MAKE) -C $$dir $@ || exit; done
+       @for dir in $(SUBDIRS); do $(MAKE) -C $$dir $@ || exit; done
 
 $(SQLSCRIPT): Makefile
 ifeq ($(enable_shared), yes)
@@ -205,16 +205,16 @@ $(REGRESSION_SCRIPT): Makefile
 
 install: $(SQLSCRIPT) installdirs
        $(INSTALL_DATA) $(SQLSCRIPT) '$(DESTDIR)$(datadir)'
-       @for dir in $(DIRS); do $(MAKE) -C $$dir $@ || exit; done
+       @for dir in $(SUBDIRS); do $(MAKE) -C $$dir $@ || exit; done
 
 installdirs:
        $(mkinstalldirs) '$(DESTDIR)$(datadir)' '$(DESTDIR)$(pkglibdir)'
 
 uninstall:
        rm -f '$(DESTDIR)$(datadir)/$(SQLSCRIPT)'
-       @for dir in $(DIRS); do $(MAKE) -C $$dir $@ || exit; done
+       @for dir in $(SUBDIRS); do $(MAKE) -C $$dir $@ || exit; done
 
 clean distclean maintainer-clean:
        rm -f $(SQLSCRIPT)
-       @for dir in $(DIRS); do $(MAKE) -C $$dir $@ || exit; done
+       @for dir in $(SUBDIRS); do $(MAKE) -C $$dir $@ || exit; done
 
index ec824942338827780b2a03910685b8719b300d5e..a01d1f93860d28835ae2bcb773e3adb60b91f9fe 100644 (file)
@@ -13,11 +13,11 @@ subdir = src/bin
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
-DIRS = initdb pg_ctl pg_dump \
+SUBDIRS = initdb pg_ctl pg_dump \
        psql scripts pg_config pg_controldata pg_resetxlog
 ifeq ($(PORTNAME), win32)
-DIRS+=pgevent
+SUBDIRS+=pgevent
 endif
 
 all install installdirs uninstall distprep clean distclean maintainer-clean:
-       @for dir in $(DIRS); do $(MAKE) -C $$dir $@ || exit; done
+       @for dir in $(SUBDIRS); do $(MAKE) -C $$dir $@ || exit; done
index 7a465793142e9990b81a0b181ea0415a815688b5..b63236c2e285fb5f2e71cfa26dce274d0f919165 100644 (file)
@@ -12,7 +12,7 @@ subdir = src/interfaces
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
-DIRS = libpq ecpg 
+SUBDIRS = libpq ecpg
 
 all install installdirs uninstall distprep clean distclean maintainer-clean:
-       @for dir in $(DIRS); do $(MAKE) -C $$dir $@ || exit; done
+       @for dir in $(SUBDIRS); do $(MAKE) -C $$dir $@ || exit; done
index 34614debbdda6660f88776fb5a794dcf50b84304..670cf1ec0d8926ce8dbddff57faef5e7601a76f2 100644 (file)
@@ -12,26 +12,26 @@ subdir = src/pl
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
-DIRS = plpgsql
+SUBDIRS = plpgsql
 
 ifeq ($(with_perl), yes)
-DIRS += plperl
+SUBDIRS += plperl
 endif
 
 ifeq ($(with_python), yes)
-DIRS += plpython
+SUBDIRS += plpython
 endif
 
 ifeq ($(with_tcl), yes)
-DIRS += tcl
+SUBDIRS += tcl
 endif
 
 all install installdirs uninstall distprep clean distclean maintainer-clean:
-       @for dir in $(DIRS); do $(MAKE) -C $$dir $@ || exit; done
+       @for dir in $(SUBDIRS); do $(MAKE) -C $$dir $@ || exit; done
 
 # We'd like check operations to run all the subtests before failing.
 check installcheck:
-       @CHECKERR=0; for dir in $(DIRS); do \
+       @CHECKERR=0; for dir in $(SUBDIRS); do \
                $(MAKE) -C $$dir $@ || CHECKERR=$$?; \
        done; \
        exit $$CHECKERR
index bb41207f98ad4e713de5b909c8fc6cd71dd04cc3..0ac908df1c51726ce582a2087424a8a348918d89 100644 (file)
@@ -12,5 +12,5 @@ subdir = src/pl/plpgsql
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
-all install installdirs uninstall distprep clean distclean maintainer-clean:
+all install installdirs uninstall distprep clean distclean maintainer-clean coverage:
        $(MAKE) -C src $@
index c4b9ed5462a9f5cfb358015d4b32f54d2f66bf74..f5a01b36fb65ba6ff84571b9136f5f68b78ca492 100644 (file)
@@ -321,7 +321,7 @@ sub mkvcbuild
 
     $mf = Project::read_file('src\backend\utils\mb\conversion_procs\Makefile');
     $mf =~ s{\\s*[\r\n]+}{}mg;
-    $mf =~ m{DIRS\s*=\s*(.*)$}m || die 'Could not match in conversion makefile' . "\n";
+    $mf =~ m{SUBDIRS\s*=\s*(.*)$}m || die 'Could not match in conversion makefile' . "\n";
     foreach my $sub (split /\s+/,$1)
     {
         my $mf = Project::read_file('src\backend\utils\mb\conversion_procs\\' . $sub . '\Makefile');