]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
Perl coverage support using Devel::Cover.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 17 Oct 2009 16:14:33 +0000 (18:14 +0200)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sun, 18 Oct 2009 09:17:48 +0000 (11:17 +0200)
This introduces makefile rules to run the testsuite with Perl
coverage enabled.  It skips tests that use perl ithreads, by
unsetting AUTOMAKE_JOBS and setting WANT_NO_THREADS to make the
threaded tests skip.

* Makefile.am (PERL_COVERAGE_DB, PERL_COVERAGE_FLAGS)
(PERL_COVER): New variables.
(check-coverage, recheck-coverage, clean-coverage): New phony
targets.
(check-coverage-run, recheck-coverage-run): New phony helper
targets.
(clean-local): New, depend on clean-coverage.
* lib/Automake/tests/Condition-t.pl: Skip if WANT_NO_THREADS is
set.
* lib/Automake/tests/DisjConditions-t.pl: Likewise.
* tests/defs.in: New required entry 'perl-threads'.
* tests/parallel-am.test: Use it to skip if WANT_NO_THREADS is
set.
* tests/parallel-am2.test: Likewise.
* tests/parallel-am3.test: Likewise.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
ChangeLog
HACKING
Makefile.am
Makefile.in
lib/Automake/tests/Condition-t.pl
lib/Automake/tests/DisjConditions-t.pl
tests/defs.in
tests/parallel-am.test
tests/parallel-am2.test
tests/parallel-am3.test

index 23cba8ed6afe9c97df21c1161106e77a924b8d31..7eabdb5894ffb223befaa4c06373ff34e8bf2b81 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,26 @@
 2009-10-17  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
+       Perl coverage support using Devel::Cover.
+       This introduces makefile rules to run the testsuite with Perl
+       coverage enabled.  It skips tests that use perl ithreads, by
+       unsetting AUTOMAKE_JOBS and setting WANT_NO_THREADS to make the
+       threaded tests skip.
+       * Makefile.am (PERL_COVERAGE_DB, PERL_COVERAGE_FLAGS)
+       (PERL_COVER): New variables.
+       (check-coverage, recheck-coverage, clean-coverage): New phony
+       targets.
+       (check-coverage-run, recheck-coverage-run): New phony helper
+       targets.
+       (clean-local): New, depend on clean-coverage.
+       * lib/Automake/tests/Condition-t.pl: Skip if WANT_NO_THREADS is
+       set.
+       * lib/Automake/tests/DisjConditions-t.pl: Likewise.
+       * tests/defs.in: New required entry 'perl-threads'.
+       * tests/parallel-am.test: Use it to skip if WANT_NO_THREADS is
+       set.
+       * tests/parallel-am2.test: Likewise.
+       * tests/parallel-am3.test: Likewise.
+
        Add convenience `recheck' target to our toplevel Makefile.am.
        * Makefile.am (recheck): New convenience target.
        * tests/README: Give examples for running only failed or
diff --git a/HACKING b/HACKING
index 64d55f90e848008c4cf10fd11e3ef6d4052e528a..c8ae47ef42995639274aedf5b06aec64685b8ec5 100644 (file)
--- a/HACKING
+++ b/HACKING
 * Use `keep_testdirs=yes' to keep test directories for successful
   tests also.
 
+* Use perl coverage information to ensure your new code is thoroughly
+  tested by your new tests.
+
 ================================================================
 = Release procedure
 
index 66d8315cb054c695a0c87da083186b6dd0bb3203..fc16b7a38abdffd149beb9edcfa64c0bf8059ce4 100644 (file)
@@ -121,6 +121,41 @@ recheck:
 dist-hook:
        cd $(distdir)/tests && chmod a+rx *.test
 
+
+# Perl coverage statistics.
+PERL_COVERAGE_DB = $(abs_top_builddir)/cover_db
+PERL_COVERAGE_FLAGS = -MDevel::Cover=-db,$(PERL_COVERAGE_DB),-silent,on,-summary,off
+PERL_COVER = cover
+
+check-coverage-run recheck-coverage-run: all
+       $(mkinstalldirs) $(PERL_COVERAGE_DB)
+       PERL5OPT="$$PERL5OPT $(PERL_COVERAGE_FLAGS)"; export PERL5OPT; \
+       WANT_NO_THREADS=yes; export WANT_NO_THREADS; unset AUTOMAKE_JOBS; \
+       $(MAKE) $(AM_MAKEFLAGS) `echo $@ | sed 's/-coverage-run//'`
+
+check-coverage-report:
+       @if test ! -d "$(PERL_COVERAGE_DB)"; then \
+         echo "No coverage database found in \`$(PERL_COVERAGE_DB)'." >&2; \
+         echo "Please run \`make check-coverage' first" >&2; \
+         exit 1; \
+       fi
+       $(PERL_COVER) $(PERL_COVER_FLAGS) "$(PERL_COVERAGE_DB)"
+
+# We don't use direct dependencies here because we'd like to be able
+# to invoke the report even after interrupted check-coverage.
+check-coverage: check-coverage-run
+       $(MAKE) $(AM_MAKEFLAGS) check-coverage-report
+
+recheck-coverage: recheck-coverage-run
+       $(MAKE) $(AM_MAKEFLAGS) check-coverage-report
+
+clean-coverage:
+       rm -rf "$(PERL_COVERAGE_DB)"
+clean-local: clean-coverage
+
+.PHONY: check-coverage recheck-coverage check-coverage-run \
+       recheck-coverage-run check-coverage-report clean-coverage
+
 # Some simple checks, and then ordinary check.  These are only really
 # guaranteed to work on my machine.
 syntax_check_rules = \
index f06e655d2daee5de4a98f7a7cf4bb386d6d28e77..c6956a948453c7980260e8acf3b9581f650716bf 100644 (file)
@@ -247,6 +247,11 @@ do_subst = sed \
 
 TEST_SUBDIRS = lib/Automake/tests tests
 
+# Perl coverage statistics.
+PERL_COVERAGE_DB = $(abs_top_builddir)/cover_db
+PERL_COVERAGE_FLAGS = -MDevel::Cover=-db,$(PERL_COVERAGE_DB),-silent,on,-summary,off
+PERL_COVER = cover
+
 # Some simple checks, and then ordinary check.  These are only really
 # guaranteed to work on my machine.
 syntax_check_rules = \
@@ -724,7 +729,7 @@ maintainer-clean-generic:
        @echo "it deletes files that may require special tools to rebuild."
 clean: clean-recursive
 
-clean-am: clean-generic mostlyclean-am
+clean-am: clean-generic clean-local mostlyclean-am
 
 distclean: distclean-recursive
        -rm -f $(am__CONFIG_DISTCLEAN_FILES)
@@ -799,9 +804,9 @@ uninstall-am: uninstall-binSCRIPTS
 
 .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
        all all-am am--refresh check check-am clean clean-generic \
-       ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \
-       dist-hook dist-lzma dist-shar dist-tarZ dist-xz dist-zip \
-       distcheck distclean distclean-generic distclean-tags \
+       clean-local ctags ctags-recursive dist dist-all dist-bzip2 \
+       dist-gzip dist-hook dist-lzma dist-shar dist-tarZ dist-xz \
+       dist-zip distcheck distclean distclean-generic distclean-tags \
        distcleancheck distdir distuninstallcheck dvi dvi-am html \
        html-am info info-am install install-am install-binSCRIPTS \
        install-data install-data-am install-dvi install-dvi-am \
@@ -864,6 +869,35 @@ recheck:
 dist-hook:
        cd $(distdir)/tests && chmod a+rx *.test
 
+check-coverage-run recheck-coverage-run: all
+       $(mkinstalldirs) $(PERL_COVERAGE_DB)
+       PERL5OPT="$$PERL5OPT $(PERL_COVERAGE_FLAGS)"; export PERL5OPT; \
+       WANT_NO_THREADS=yes; export WANT_NO_THREADS; unset AUTOMAKE_JOBS; \
+       $(MAKE) $(AM_MAKEFLAGS) `echo $@ | sed 's/-coverage-run//'`
+
+check-coverage-report:
+       @if test ! -d "$(PERL_COVERAGE_DB)"; then \
+         echo "No coverage database found in \`$(PERL_COVERAGE_DB)'." >&2; \
+         echo "Please run \`make check-coverage' first" >&2; \
+         exit 1; \
+       fi
+       $(PERL_COVER) $(PERL_COVER_FLAGS) "$(PERL_COVERAGE_DB)"
+
+# We don't use direct dependencies here because we'd like to be able
+# to invoke the report even after interrupted check-coverage.
+check-coverage: check-coverage-run
+       $(MAKE) $(AM_MAKEFLAGS) check-coverage-report
+
+recheck-coverage: recheck-coverage-run
+       $(MAKE) $(AM_MAKEFLAGS) check-coverage-report
+
+clean-coverage:
+       rm -rf "$(PERL_COVERAGE_DB)"
+clean-local: clean-coverage
+
+.PHONY: check-coverage recheck-coverage check-coverage-run \
+       recheck-coverage-run check-coverage-report clean-coverage
+
 .PHONY: $(syntax_check_rules)
 $(syntax_check_rules): automake aclocal
 maintainer-check: $(syntax_check_rules)
index 06eb34e929427bd2fabe910b107999bff8785adb..0f1dde8151a84527f07b45e1f385a276a2e943ef 100644 (file)
@@ -1,4 +1,5 @@
-# Copyright (C) 2001, 2002, 2003, 2008  Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2003, 2008, 2009  Free Software Foundation,
+# Inc.
 #
 # This file is part of GNU Automake.
 #
@@ -18,7 +19,8 @@
 BEGIN {
   use Config;
   if (eval { require 5.007_002; }      # for CLONE support
-      && $Config{useithreads})
+      && $Config{useithreads}
+      && !$ENV{WANT_NO_THREADS})
     {
       require threads;
       import threads;
index 2fe275beba22754c98b99c005ca65b74b67b5c61..eccdcd69eb7f63b6d832f42dcec37f81759f83ca 100644 (file)
@@ -1,4 +1,5 @@
-# Copyright (C) 2001, 2002, 2003, 2008  Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2003, 2008, 2009  Free Software Foundation,
+# Inc.
 #
 # This file is part of GNU Automake.
 #
@@ -18,7 +19,8 @@
 BEGIN {
   use Config;
   if (eval { require 5.007_002; }      # for CLONE support
-      && $Config{useithreads})
+      && $Config{useithreads}
+      && !$ENV{WANT_NO_THREADS})
     {
       require threads;
       import threads;
index ecdf069cce331a293f6ed9cfef35a62192d7e6f8..6eec344702d3a2baaba6bd99a6212cca23914859 100644 (file)
@@ -170,6 +170,10 @@ do
       rm -f $priv_check_temp
       test $overwrite_status = 0 && exit 77
       ;;
+    perl-threads)
+      # Skip with Devel::Cover: it cannot cope with threads.
+      test "$WANT_NO_THREADS" = yes && exit 77
+      ;;
     python)
       # Python doesn't support --version, it has -V
       echo "$me: running python -V"
index 4aef62896dbe4646822d6e8c57e98af628711b46..c46377bee61c9fdf6a17c11b9759c62b18578e22 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2008  Free Software Foundation, Inc.
+# Copyright (C) 2008, 2009  Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -35,6 +35,7 @@
 #
 # This test checks (0), (1), and (2).  See sister tests for further coverage.
 
+required=perl-threads
 . ./defs || Exit 1
 
 set -e
index 20225a076411fc7d9e65d4e6f31dd2e47609ff8b..d92974071690898734c7f4fdabc7304e5e3d59f0 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2008  Free Software Foundation, Inc.
+# Copyright (C) 2008, 2009  Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
 # 4) warning and normal error output should be identical, in that duplicate
 #    warnings should be omitted in the same way as without threads,
 
+required=perl-threads
 . ./defs || Exit 1
 
 set -e
index 5db9c67259856ad4278f8ed11729dbb9553a9f68..104376ae165b3681664ed7c5925b758f940c57f8 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2008  Free Software Foundation, Inc.
+# Copyright (C) 2008, 2009  Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -21,6 +21,7 @@
 #    with --add-missing, even with concurrent file requirements, and the
 #    installation of aux files should be race-free,
 
+required=perl-threads
 . ./defs || Exit 1
 
 set -e