From: Ralf Wildenhues Date: Sat, 17 Oct 2009 16:14:33 +0000 (+0200) Subject: Perl coverage support using Devel::Cover. X-Git-Tag: ng-0.5a~461^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6a7834f03248dc3b1da1d70b40fcaf37967b4ab;p=thirdparty%2Fautomake.git 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. Signed-off-by: Ralf Wildenhues --- diff --git a/ChangeLog b/ChangeLog index 23cba8ed6..7eabdb589 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,26 @@ 2009-10-17 Ralf Wildenhues + 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 64d55f90e..c8ae47ef4 100644 --- a/HACKING +++ b/HACKING @@ -125,6 +125,9 @@ * 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 diff --git a/Makefile.am b/Makefile.am index 66d8315cb..fc16b7a38 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 = \ diff --git a/Makefile.in b/Makefile.in index f06e655d2..c6956a948 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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) diff --git a/lib/Automake/tests/Condition-t.pl b/lib/Automake/tests/Condition-t.pl index 06eb34e92..0f1dde815 100644 --- a/lib/Automake/tests/Condition-t.pl +++ b/lib/Automake/tests/Condition-t.pl @@ -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; diff --git a/lib/Automake/tests/DisjConditions-t.pl b/lib/Automake/tests/DisjConditions-t.pl index 2fe275beb..eccdcd69e 100644 --- a/lib/Automake/tests/DisjConditions-t.pl +++ b/lib/Automake/tests/DisjConditions-t.pl @@ -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; diff --git a/tests/defs.in b/tests/defs.in index ecdf069cc..6eec34470 100644 --- a/tests/defs.in +++ b/tests/defs.in @@ -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" diff --git a/tests/parallel-am.test b/tests/parallel-am.test index 4aef62896..c46377bee 100755 --- a/tests/parallel-am.test +++ b/tests/parallel-am.test @@ -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 diff --git a/tests/parallel-am2.test b/tests/parallel-am2.test index 20225a076..d92974071 100755 --- a/tests/parallel-am2.test +++ b/tests/parallel-am2.test @@ -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 diff --git a/tests/parallel-am3.test b/tests/parallel-am3.test index 5db9c6725..104376ae1 100755 --- a/tests/parallel-am3.test +++ b/tests/parallel-am3.test @@ -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