[PATCH 2/2] Perl coverage support using Devel::Cover.
With this, you can run make -k check-coverage and on the next day, you might have useful coverage data. :-) Well, if something failed, you might still need to follow up with make check-coverage-report Pausing for some coffee is still worthwhile at this point. For a reasonably sane edit-compile-cycle, use make -k recheck-coverage or limit the set of tests to be run make -k check-coverage TESTS=foo.test bar.test make check-coverage-report The environment variable WANT_NO_THREADS is used to skip those tests that required ithreads. I thought of hooking clean-coverage to maintainer-clean-local, but that doesn't help much, as Devel::Cover invalidates coverage data for changed scripts as well. Cheers, Ralf 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. diff --git a/HACKING b/HACKING index 64d55f9..c8ae47e 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 66d8315..fc16b7a 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/lib/Automake/tests/Condition-t.pl b/lib/Automake/tests/Condition-t.pl index 06eb34e..0f1dde8 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 2fe275b..eccdcd6 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
[PATCH 0/5] Perl module coverage
I'm applying this patch series to the perl-coverage branch and merging it into master. It improves coverage for Version.pm, Wrap.pm, Condition.pm, and DisjConditions.pm, where now, only statements aren't counted as covered which consist of code used with ithreads only. The last patch is a very small improvement for an unnecessary condition check that became obvious by looking at coverage results. Improves condition coverage by having one less unreachable condition. :-) Coverage results for lib/Automake/tests suite before/after the merge: -- -- -- -- -- -- -- File stmt bran condsubpod time total -- -- -- -- -- -- -- ...b/Automake/ChannelDefs.pm 29.63.6n/a 41.2 88.90.0 29.6 .../lib/Automake/Channels.pm 34.88.10.0 50.0 100.00.1 32.0 ...lib/Automake/Condition.pm 97.8 94.8 100.0 96.2 94.7 97.3 96.9 ...utomake/DisjConditions.pm 70.2 60.0n/a 68.4 100.01.8 70.5 ...e/lib/Automake/Version.pm 72.4 60.0 66.7 80.0 100.00.1 69.6 ...make/lib/Automake/Wrap.pm 84.8 50.0 100.0 80.0 66.70.0 78.9 [...] -- -- -- -- -- -- -- File stmt bran condsubpod time total -- -- -- -- -- -- -- ...b/Automake/ChannelDefs.pm 32.43.6n/a 47.1 100.00.0 32.8 .../lib/Automake/Channels.pm 52.5 27.4 19.0 60.5 100.00.2 48.4 ...lib/Automake/Condition.pm 100.0 100.0 100.0 100.0 100.0 97.0 100.0 ...utomake/DisjConditions.pm 94.7 100.0n/a 94.7 100.01.8 96.2 ...e/lib/Automake/Version.pm 100.0 100.0 100.0 100.0 100.00.4 100.0 ...make/lib/Automake/Wrap.pm 100.0 100.0 100.0 100.0 100.00.1 100.0 [...]
[PATCH 1/5] Coverage for Version.pm.
* lib/Automake/tests/Version.pl (test_version_compare): Also try Automake::Version::check for the version pairs, taking into account the special-case naming of code forks. (@tests): Add more test cases. (test_bad_versions, @bad_versions): New function, new test cases, to ensure bad version strings are rejected. * lib/Automake/tests/Version2.pl: New test. * lib/Automake/tests/Version3.pl: Likewise. * lib/Automake/tests/Makefile.am (TESTS): Add tests here ... (XFAIL_TESTS): ... and here, new. Signed-off-by: Ralf Wildenhues ralf.wildenh...@gmx.de --- One thing that's worthwhile mentioning here is that the new XFAILing tests are really supposed to be failing: they check that we error out upon seeing an invalid Automake Version string. Hope this won't be too confusing. ChangeLog | 12 lib/Automake/tests/Makefile.am |6 ++ lib/Automake/tests/Makefile.in |6 ++ lib/Automake/tests/Version.pl | 36 ++-- lib/Automake/tests/Version2.pl |5 + lib/Automake/tests/Version3.pl |5 + 6 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 lib/Automake/tests/Version2.pl create mode 100644 lib/Automake/tests/Version3.pl diff --git a/ChangeLog b/ChangeLog index 3cba9d5..c4841df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2009-10-18 Ralf Wildenhues ralf.wildenh...@gmx.de + Coverage for Version.pm. + * lib/Automake/tests/Version.pl (test_version_compare): Also + try Automake::Version::check for the version pairs, taking into + account the special-case naming of code forks. + (@tests): Add more test cases. + (test_bad_versions, @bad_versions): New function, new test cases, + to ensure bad version strings are rejected. + * lib/Automake/tests/Version2.pl: New test. + * lib/Automake/tests/Version3.pl: Likewise. + * lib/Automake/tests/Makefile.am (TESTS): Add tests here ... + (XFAIL_TESTS): ... and here, new. + Pod coverage for Perl modules. * lib/Automake/ChannelDefs.pm (parse_warnings): Fix typo in Pod documentation. diff --git a/lib/Automake/tests/Makefile.am b/lib/Automake/tests/Makefile.am index b8fb761..19d100f 100644 --- a/lib/Automake/tests/Makefile.am +++ b/lib/Automake/tests/Makefile.am @@ -25,6 +25,12 @@ Condition-t.pl \ DisjConditions.pl \ DisjConditions-t.pl \ Version.pl \ +Version2.pl \ +Version3.pl \ Wrap.pl +XFAIL_TESTS = \ +Version2.pl \ +Version3.pl + EXTRA_DIST = $(TESTS) diff --git a/lib/Automake/tests/Makefile.in b/lib/Automake/tests/Makefile.in index e44898b..2e38ba5 100644 --- a/lib/Automake/tests/Makefile.in +++ b/lib/Automake/tests/Makefile.in @@ -231,8 +231,14 @@ Condition-t.pl \ DisjConditions.pl \ DisjConditions-t.pl \ Version.pl \ +Version2.pl \ +Version3.pl \ Wrap.pl +XFAIL_TESTS = \ +Version2.pl \ +Version3.pl + EXTRA_DIST = $(TESTS) all: all-am diff --git a/lib/Automake/tests/Version.pl b/lib/Automake/tests/Version.pl index e496435..bea91f0 100644 --- a/lib/Automake/tests/Version.pl +++ b/lib/Automake/tests/Version.pl @@ -1,4 +1,4 @@ -# Copyright (C) 2002, 2003 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2009 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -42,6 +42,29 @@ sub test_version_compare print compare (\$left\, \$right\) = $res! (not $result?)\n; $failed = 1; } + + my $check_expected = ($result == 0 || $result == 1) ? 0 : 1; + # Exception for 'foo' fork. + $check_expected = 1 +if ($right =~ /foo/ !($left =~ /foo/)); + + my $check = Automake::Version::check ($left, $right); + if ($check != $check_expected) + { +print check (\$left\, \$right\) = $check! (not $check_expected?)\n; +$failed = 1; + } +} + +sub test_bad_versions +{ + my ($ver) = @_; + my @version = Automake::Version::split ($ver); + if ($#version != -1) + { +print shouldn't grok \$ver\\n; +$failed = 1; + } } my @tests = ( @@ -69,15 +92,24 @@ my @tests = ( ['1.5a', '1.5.1f', 1], ['1.5', '1.5.1a', -1], ['1.5.1a', '1.5.1f', -1], + ['1.5.1f', '1.5.1a', 1], + ['1.5.1f', '1.5.1f', 0], # special exceptions ['1.6-p5a', '1.6.5a', 0], ['1.6', '1.6-p5a', -1], ['1.6-p4b', '1.6-p5a', -1], ['1.6-p4b', '1.6-foo', 1], - ['1.6-p4b', '1.6a-foo', -1] + ['1.6-p4b', '1.6a-foo', -1], + ['1.6-p5', '1.6.5', 0], + ['1.6a-foo', '1.6a-foo', 0], +); + +my @bad_versions = ( + '', 'a', '1', '1a', '1.2.3.4', '-1.2' ); test_version_compare (@{$_}) foreach @tests; +test_bad_versions ($_) foreach @bad_versions; exit $failed; diff --git a/lib/Automake/tests/Version2.pl b/lib/Automake/tests/Version2.pl new file mode 100644 index 000..038466d --- /dev/null +++ b/lib/Automake/tests/Version2.pl @@ -0,0 +1,5 @@ +# prog_error due to invalid $VERSION. + +use Automake::Version; + +Automake::Version::check ('', '1.2.3'); diff --git a/lib/Automake/tests/Version3.pl
[PATCH 2/5] Coverage for Wrap.pm.
* lib/Automake/tests/Wrap.pl (@tests): Add test for word with trailing space. (test_makefile_wrap, @makefile_tests): New function, new list of tests, to test makefile_wrap. Signed-off-by: Ralf Wildenhues ralf.wildenh...@gmx.de --- ChangeLog |6 ++ lib/Automake/tests/Wrap.pl | 38 -- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c4841df..6ae4243 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2009-10-18 Ralf Wildenhues ralf.wildenh...@gmx.de + Coverage for Wrap.pm. + * lib/Automake/tests/Wrap.pl (@tests): Add test for word with + trailing space. + (test_makefile_wrap, @makefile_tests): New function, new list of + tests, to test makefile_wrap. + Coverage for Version.pm. * lib/Automake/tests/Version.pl (test_version_compare): Also try Automake::Version::check for the version pairs, taking into diff --git a/lib/Automake/tests/Wrap.pl b/lib/Automake/tests/Wrap.pl index 8d840fc..b415401 100644 --- a/lib/Automake/tests/Wrap.pl +++ b/lib/Automake/tests/Wrap.pl @@ -1,4 +1,4 @@ -# Copyright (C) 2003 Free Software Foundation, Inc. +# Copyright (C) 2003, 2009 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/. -use Automake::Wrap 'wrap'; +use Automake::Wrap qw/wrap makefile_wrap/; my $failed = 0; @@ -31,6 +31,18 @@ sub test_wrap } } +sub test_makefile_wrap +{ + my ($in, $exp_out) = @_; + + my $out = makefile_wrap (@$in); + if ($out ne $exp_out) +{ + print STDERR For: @$in\nGot:\n$out\nInstead of:\n$exp_out\n---\n; + ++$failed; +} +} + my @tests = ( [[HEAD:, NEXT:, CONT, 13, v ,a, l, ue, s, values], HEAD:v aCONT @@ -55,10 +67,32 @@ big continuation:diag3 big header: END cont: word1 END cont: word2 +], + [[big header:, , END, 16, w1, w2 , w3], +big header: END +w1 w2 w3 ]); +my @makefile_tests = ( + [[target:], +target: +], + [[target:, \t], +target: +], + [[target:, \t, prereq1, prereq2], +target: prereq1 prereq2 +], + [[target: , \t, this is a long list of prerequisites ending in space, +so that there is no need for another space before the backslash, +unlike in the second line], +target: this is a long list of prerequisites ending in space \\ +\tso that there is no need for another space before the backslash \\ +\tunlike in the second line +]); test_wrap (@{$_}) foreach @tests; +test_makefile_wrap (@{$_}) foreach @makefile_tests; exit $failed; -- 1.6.5.1.31.gad12b
[PATCH 3/5] Coverage and fixes for Condition.pm.
* lib/Automake/Condition.pm (new): Catch common programming errors better by checking type of passed argument before munging them to all be strings through split. * lib/Automake/tests/Condition.pl (test_basics): Also test -human. (test_merge): New function, test -merge, -merge_conds, -strip. * lib/Automake/tests/Condition-t.pl (test_basics, test_merge): Likewise changes, but including state copies across thread creation. * lib/Automake/tests/Cond2.pl: New test for programming error. * lib/Automake/tests/Cond3.pl: Likewise. * lib/Automake/tests/Makefile.am (TESTS, XFAIL_TESTS): Update. Signed-off-by: Ralf Wildenhues ralf.wildenh...@gmx.de --- This was interesting. I couldn't get the first 'confess' code branch to ever go off. Took a bit to notice that 'split' turns everything into a string. Cheers, Ralf ChangeLog | 15 lib/Automake/Condition.pm | 13 ++ lib/Automake/tests/Cond2.pl |6 + lib/Automake/tests/Cond3.pl |6 + lib/Automake/tests/Condition-t.pl | 45 +--- lib/Automake/tests/Condition.pl | 39 +++ lib/Automake/tests/Makefile.am|4 +++ lib/Automake/tests/Makefile.in|4 +++ 8 files changed, 108 insertions(+), 24 deletions(-) create mode 100644 lib/Automake/tests/Cond2.pl create mode 100644 lib/Automake/tests/Cond3.pl diff --git a/ChangeLog b/ChangeLog index 6ae4243..a0f6525 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,20 @@ 2009-10-18 Ralf Wildenhues ralf.wildenh...@gmx.de + Coverage and fixes for Condition.pm. + * lib/Automake/Condition.pm (new): Catch common programming + errors better by checking type of passed argument before + munging them to all be strings through split. + * lib/Automake/tests/Condition.pl (test_basics): Also test + -human. + (test_merge): New function, test -merge, -merge_conds, + -strip. + * lib/Automake/tests/Condition-t.pl (test_basics, test_merge): + Likewise changes, but including state copies across thread + creation. + * lib/Automake/tests/Cond2.pl: New test for programming error. + * lib/Automake/tests/Cond3.pl: Likewise. + * lib/Automake/tests/Makefile.am (TESTS, XFAIL_TESTS): Update. + Coverage for Wrap.pm. * lib/Automake/tests/Wrap.pl (@tests): Add test for word with trailing space. diff --git a/lib/Automake/Condition.pm b/lib/Automake/Condition.pm index 276c04a..5c54b8b 100644 --- a/lib/Automake/Condition.pm +++ b/lib/Automake/Condition.pm @@ -180,18 +180,21 @@ sub new ($;@) }; bless $self, $class; - # Accept strings like FOO BAR as shorthand for (FOO, BAR). - @conds = map { split (' ', $_) } @conds; - for my $cond (@conds) { - next if $cond eq 'TRUE'; - # Catch some common programming errors: # - A Condition passed to new confess `$cond' is a reference, expected a string if ref $cond; # - A Condition passed as a string to new confess `$cond' does not look like a condition if $cond =~ /::/; +} + + # Accept strings like FOO BAR as shorthand for (FOO, BAR). + @conds = map { split (' ', $_) } @conds; + + for my $cond (@conds) +{ + next if $cond eq 'TRUE'; # Detect cases when @conds can be simplified to FALSE. if (($cond eq 'FALSE' $#conds 0) diff --git a/lib/Automake/tests/Cond2.pl b/lib/Automake/tests/Cond2.pl new file mode 100644 index 000..4ad0e1c --- /dev/null +++ b/lib/Automake/tests/Cond2.pl @@ -0,0 +1,6 @@ +# Catch common programming error: +# A Condition passed as a string to 'new'. +use Automake::Condition; + +my $cond = new Automake::Condition ('TRUE'); +new Automake::Condition ($cond); diff --git a/lib/Automake/tests/Cond3.pl b/lib/Automake/tests/Cond3.pl new file mode 100644 index 000..dc957af --- /dev/null +++ b/lib/Automake/tests/Cond3.pl @@ -0,0 +1,6 @@ +# Catch common programming error: +# A Condition passed as a string to 'new'. +use Automake::Condition; + +my $cond = new Automake::Condition (COND1_TRUE); +new Automake::Condition ($cond); diff --git a/lib/Automake/tests/Condition-t.pl b/lib/Automake/tests/Condition-t.pl index 0f1dde8..99004ac 100644 --- a/lib/Automake/tests/Condition-t.pl +++ b/lib/Automake/tests/Condition-t.pl @@ -34,15 +34,15 @@ use Automake::Condition qw/TRUE FALSE/; sub test_basics () { - my @tests = (# [[Conditions], is_true?, is_false?, string, subst-string] - [[], 1, 0, 'TRUE', ''], - [['TRUE'], 1, 0, 'TRUE', ''], - [['FALSE'], 0, 1, 'FALSE', '#'], - [['A_TRUE'], 0, 0, 'A_TRUE', '@A_TRUE@'], + my @tests = (# [[Conditions], is_true?, is_false?, string, subst-string, human] + [[], 1, 0, 'TRUE', '', 'TRUE'], + [['TRUE'], 1, 0, 'TRUE', '', 'TRUE'], + [['FALSE'], 0, 1, 'FALSE', '#', 'FALSE'], + [['A_TRUE'], 0, 0, 'A_TRUE', '@A_TRUE@',
[PATCH 4/5] Coverage for DisjConditions.pm.
* lib/Automake/tests/DisjConditions.pl (test_basics): Increase test coverage: test -human, -merge, -simplify, -multiply. * lib/Automake/tests/DisjConditions-t.pl (test_basics): Likewise changes, but including state copies across thread creation. * lib/Automake/tests/DisjCon2.pl: New test. * lib/Automake/tests/DisjCon3.pl: Likewise. * lib/Automake/tests/Makefile.am (TESTS, XFAIL_TESTS): Adjust. Signed-off-by: Ralf Wildenhues ralf.wildenh...@gmx.de --- ChangeLog |9 + lib/Automake/tests/DisjCon2.pl |8 lib/Automake/tests/DisjCon3.pl |7 +++ lib/Automake/tests/DisjConditions-t.pl | 26 ++ lib/Automake/tests/DisjConditions.pl | 26 +- lib/Automake/tests/Makefile.am |4 lib/Automake/tests/Makefile.in |4 7 files changed, 83 insertions(+), 1 deletions(-) create mode 100644 lib/Automake/tests/DisjCon2.pl create mode 100644 lib/Automake/tests/DisjCon3.pl diff --git a/ChangeLog b/ChangeLog index a0f6525..96142b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2009-10-18 Ralf Wildenhues ralf.wildenh...@gmx.de + Coverage for DisjConditions.pm. + * lib/Automake/tests/DisjConditions.pl (test_basics): Increase + test coverage: test -human, -merge, -simplify, -multiply. + * lib/Automake/tests/DisjConditions-t.pl (test_basics): Likewise + changes, but including state copies across thread creation. + * lib/Automake/tests/DisjCon2.pl: New test. + * lib/Automake/tests/DisjCon3.pl: Likewise. + * lib/Automake/tests/Makefile.am (TESTS, XFAIL_TESTS): Adjust. + Coverage and fixes for Condition.pm. * lib/Automake/Condition.pm (new): Catch common programming errors better by checking type of passed argument before diff --git a/lib/Automake/tests/DisjCon2.pl b/lib/Automake/tests/DisjCon2.pl new file mode 100644 index 000..9edd8d5 --- /dev/null +++ b/lib/Automake/tests/DisjCon2.pl @@ -0,0 +1,8 @@ +# Catch common programming error: +# A non-Condition reference passed to new. +use Automake::Condition; +use Automake::DisjConditions; + +my $cond = new Automake::Condition ('TRUE'); +my $cond2 = new Automake::DisjConditions ($cond); +new Automake::DisjConditions ($cond2); diff --git a/lib/Automake/tests/DisjCon3.pl b/lib/Automake/tests/DisjCon3.pl new file mode 100644 index 000..8e69e2b --- /dev/null +++ b/lib/Automake/tests/DisjCon3.pl @@ -0,0 +1,7 @@ +# Catch common programming error: +# A non-reference passed to new. +use Automake::Condition qw/TRUE FALSE/; +use Automake::DisjConditions; + +my $cond = new Automake::Condition (COND1_TRUE); +new Automake::DisjConditions ($cond); diff --git a/lib/Automake/tests/DisjConditions-t.pl b/lib/Automake/tests/DisjConditions-t.pl index eccdcd6..4df5112 100644 --- a/lib/Automake/tests/DisjConditions-t.pl +++ b/lib/Automake/tests/DisjConditions-t.pl @@ -35,18 +35,44 @@ use Automake::DisjConditions; sub test_basics () { + my $true = new Automake::DisjConditions TRUE; + my $false = new Automake::DisjConditions FALSE; my $cond = new Automake::Condition COND1_TRUE, COND2_FALSE; return threads-new (sub { my $other = new Automake::Condition COND3_FALSE; +my $another = new Automake::Condition COND3_TRUE, COND4_FALSE; return threads-new (sub { my $set1 = new Automake::DisjConditions $cond, $other; return threads-new (sub { my $set2 = new Automake::DisjConditions $other, $cond; + my $set3 = new Automake::DisjConditions FALSE, $another; return 1 unless $set1 == $set2; return 1 if $set1-false; return 1 if $set1-true; return 1 unless (new Automake::DisjConditions)-false; return 1 if (new Automake::DisjConditions)-true; + return 1 unless $true-human eq 'TRUE'; + return 1 unless $false-human eq 'FALSE'; + return 1 unless $set1-human eq (COND1 and !COND2) or (!COND3); + return 1 unless $set2-human eq (COND1 and !COND2) or (!COND3); + my $one_cond_human = $set1-one_cond-human; + return 1 unless $one_cond_human eq !COND3 + || $one_cond_human eq COND1 and !COND2; + return 1 unless $set1-string eq COND1_TRUE COND2_FALSE | COND3_FALSE; + + my $merged1 = $set1-merge ($set2); + my $merged2 = $set1-merge ($cond); + my $mult1 = $set1-multiply ($set3); + return threads-new (sub { + my $mult2 = $set1-multiply ($another); + return threads-new (sub { + return 1 unless $merged1-simplify-string eq COND1_TRUE COND2_FALSE | COND3_FALSE; + return 1 unless $merged2-simplify-string eq COND1_TRUE COND2_FALSE | COND3_FALSE; + return 1 unless $mult1-string eq COND1_TRUE COND2_FALSE COND3_TRUE COND4_FALSE; + return 1 unless $mult1 == $mult2; + return 0; + })-join; + })-join; })-join; })-join; })-join;
[PATCH 5/5] Simplify Variable::_check_ambiguous_condition.
* lib/Automake/Variable.pm (_check_ambiguous_condition): No need to check for $def since ambiguous_p returns an empty $message if there is no other condition which is ambiguous to $cond. Signed-off-by: Ralf Wildenhues ralf.wildenh...@gmx.de --- ChangeLog|5 + lib/Automake/Variable.pm |2 +- 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/ChangeLog b/ChangeLog index 96142b1..de8d22e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2009-10-18 Ralf Wildenhues ralf.wildenh...@gmx.de + Simplify Variable::_check_ambiguous_condition. + * lib/Automake/Variable.pm (_check_ambiguous_condition): No need + to check for $def since ambiguous_p returns an empty $message if + there is no other condition which is ambiguous to $cond. + Coverage for DisjConditions.pm. * lib/Automake/tests/DisjConditions.pl (test_basics): Increase test coverage: test -human, -merge, -simplify, -multiply. diff --git a/lib/Automake/Variable.pm b/lib/Automake/Variable.pm index f0c867f..30dcc79 100644 --- a/lib/Automake/Variable.pm +++ b/lib/Automake/Variable.pm @@ -469,7 +469,7 @@ sub _check_ambiguous_condition ($$$) # We allow silent variables to be overridden silently, # by either silent or non-silent variables. my $def = $self-def ($ambig_cond); - if ($message !($def $def-pretty == VAR_SILENT)) + if ($message $def-pretty != VAR_SILENT) { msg 'syntax', $where, $message ..., partial = 1; msg_var ('syntax', $var, ... `$var' previously defined here); -- 1.6.5.1.31.gad12b
Re: Non-recursive automake
Hello, * Jan Engelhardt wrote on Sat, Oct 17, 2009 at 07:04:39PM CEST: when one decides to drive make in a non-recursive fashion, one has to write an Automake file like this: lib_LTLIBRARIES = foo/bar.la foo_bar_la_SOURCES = foo/one.c foo/two.c Usually I stuff that into a file called foo/Automakefile and include foo/Automakefile from the real Makefile.am. Despite being in a subdirectory, one may not omit foo/; that is ok. However, it is tiresome. Is there perhaps a way, or a planned development action, so that one can omit all foo/s inside foo/Automakefile and have automake automatically add foo/ upon seeing include (or a variant thereof) in the upper Makefile.am? Yes. The latest plan I couldn't get stabilized so left out for 1.11: http://thread.gmane.org/gmane.comp.sysutils.automake.general/9824/focus=9920 It would be a good idea to look at it again, though. Also, when subdir-objects is in effect, it will create odd long names such as foo/foo_bar_la-one.o where at least the foo_ prefix would be redundant in some cases. That might be worth thinking about, yes. Thanks. * Bob Friesenhahn wrote on Sun, Oct 18, 2009 at 03:09:08AM CEST: I complained about this perhaps five years ago since it is the most annoying issue related to non-recursive build. There was some discussion on this list at that time but nothing was done to make things better. Also, your pay check never made it to this side of the ocean. ;-) It seems that a problem is that much of the Makefile.am file is simply copied to the output Makefile.in and so these parts would need to be re-written rather than copied. The good news is that perl is good at re-writing text. The bad part is that whenever we rewrite, we introduce a chance to destroy. Experience tells me Automake should not rewrite arbitrary text, that has led to too many problems already. * Robert Collins wrote on Sun, Oct 18, 2009 at 03:34:20AM CEST: The way I tackled this in my proof of concept in 2001 was via a rewriting include: http://sources.redhat.com/ml/automake/2001-08/msg00112.html This added a new directive 'subdir_include' which does an include but adjusts all the paths in the make/automake rules in the included fragment to the relative path to the included rules. The devil is in the details. What about -I paths in *_CPPFLAGS? What with substituted variables? What about rewritten variable names, such as: libfoo_la_SOURCES becomes sub_libfoo_la_SOURCES, and what if the user references $(libfoo_la_SOURCES) elsewhere, say, in libbar_la_SOURCES? No. Search for several prior discussions on the Automake lists for why this cannot be done safely without highly altering the set of allowed semantics, and things the user can expect. Cheers, Ralf
Re: Non-recursive automake
On Sun, 2009-10-18 at 08:39 +0200, Ralf Wildenhues wrote: http://sources.redhat.com/ml/automake/2001-08/msg00112.html This added a new directive 'subdir_include' which does an include but adjusts all the paths in the make/automake rules in the included fragment to the relative path to the included rules. The devil is in the details. What about -I paths in *_CPPFLAGS? What with substituted variables? What about rewritten variable names, such as: libfoo_la_SOURCES becomes sub_libfoo_la_SOURCES, and what if the user references $(libfoo_la_SOURCES) elsewhere, say, in libbar_la_SOURCES? No. Search for several prior discussions on the Automake lists for why this cannot be done safely without highly altering the set of allowed semantics, and things the user can expect. I'll take it on faith; I must have missed those discussions (there was a period while I didn't receive forwarded mail from my old cygwin address before I resubscribed). Regardless, if something usable is added, +1. -Rob signature.asc Description: This is a digitally signed message part
Perl code coverage
I recently discovered Devel::Cover (Debian package libdevel-cover-perl). This rocks. Kudos to Paul Johnson for writing this module. To use Devel::Cover, I have started a branch perl-coverage (off of maint) which introduces a few helper targets, e.g., make check-coverage which is veeery slow, but also quite interesting. I will follow up on automake-patches with the patches in the branch, as far as I've merged it into master. (Please speak up if you'd like me to push the branch to savannah as well; otherwise, you can easily get at it with something like merge-point^2.) Up to now, I've tackled the trivial pod coverage, some Perl module coverage, and started on 'automake' script coverage, beginning at the end of the script. A big part of it is fairly trivial, but IMHO still worthwhile to add since it allows us to be more confident about correctness when changing the code later. I've found a few likely bugs with this already, too, and the peaks in the 'time' column below whisper 'missed-optimization'. Use of Devel::Cover causes a few test failures; notably, it doesn't work with ithreads, and it causes some output even with -silent. It might be necessary to not close STDOUT in General::END, not sure yet about that. In summary, running the Automake testsuite on a GNU/Linux x86 system shows roughly the following coverage (I've had a couple of minor, unfinished patches in the tree). For a description of the data, see: http://search.cpan.org/dist/Devel-Cover/lib/Devel/Cover/Tutorial.pod. Devel::Cover also exports very nice per-file, per-statement etc. HTML files, I'm not sure whether it is worthwhile to put them up somewhere. --- -- -- -- -- -- -- -- File stmt bran condsubpod time total --- -- -- -- -- -- -- -- ...make/lib/Automake/ChannelDefs.pm 93.0 92.9n/a 88.2 88.90.2 92.2 ...utomake/lib/Automake/Channels.pm 83.4 66.1 71.4 86.8 100.01.0 79.5 ...tomake/lib/Automake/Condition.pm 97.8 94.8 100.0 96.2 94.72.2 97.1 ...ake/lib/Automake/Configure_ac.pm 96.4 87.5 50.0 100.00.00.0 93.3 ...e/lib/Automake/DisjConditions.pm 78.7 70.0n/a 84.2 100.01.6 77.6 ...tomake/lib/Automake/FileUtils.pm 56.9 31.2 18.2 76.0 100.00.2 50.0 ...automake/lib/Automake/General.pm 100.0 100.0n/a 100.00.00.2 100.0 ...ke/automake/lib/Automake/Item.pm 100.0 50.0 66.7 100.0 100.01.7 94.1 ...automake/lib/Automake/ItemDef.pm 100.0n/an/a 100.0 100.00.4 100.0 ...utomake/lib/Automake/Location.pm 63.5n/a 25.0 80.00.00.9 63.6 ...automake/lib/Automake/Options.pm 94.8 92.5 92.3 96.0 100.00.1 93.7 ...ke/automake/lib/Automake/Rule.pm 93.6 90.0 81.2 89.2 100.01.5 91.1 ...automake/lib/Automake/RuleDef.pm 100.0n/an/a 100.0 33.30.1 100.0 .../automake/lib/Automake/Struct.pm 79.0 51.9 44.4 82.9 50.00.4 67.7 .../automake/lib/Automake/VarDef.pm 97.6 85.7 100.0 100.0 90.00.6 96.7 ...utomake/lib/Automake/Variable.pm 95.7 86.8 83.8 96.4 100.03.0 92.3 ...automake/lib/Automake/Version.pm 96.6 75.0 83.3 100.0 100.00.0 87.9 ...ke/automake/lib/Automake/Wrap.pm 100.0 100.0 100.0 100.0 66.70.4 100.0 ...e/automake/lib/Automake/XFile.pm 71.0 37.5 14.3 77.8 55.6 61.2 59.2 .../lib/Automake/tests/Condition.pl 87.9 50.0 33.3 100.0n/a0.0 75.5 ...Automake/tests/DisjConditions.pl 82.3 50.0 44.4 100.0n/a0.0 72.1 ...ke/lib/Automake/tests/Version.pl 66.7 50.0n/a 100.0n/a0.0 65.6 ...omake/lib/Automake/tests/Wrap.pl 85.7 50.0n/a 100.0n/a0.0 83.3 ...nload/cvs/automake/build/aclocal 97.9 93.7 72.3 97.5n/a 17.9 94.4 ...load/cvs/automake/build/automake 96.1 89.2 87.3 96.7n/a6.3 93.2 ...ake/build/lib/Automake/Config.pm 100.0n/an/a 100.0n/a0.0 100.0 Total 92.8 83.0 81.6 93.3 86.6 100.0 89.2 --- -- -- -- -- -- -- --
Omit dvi rule
Hi list! Is there a way to stop automake producing a rule for dvi docs? It just makes my 'distcheck' fail. kind regards, Stefan
Re: Omit dvi rule
* Stefan Bienert wrote on Mon, Oct 19, 2009 at 12:45:19AM CEST: Is there a way to stop automake producing a rule for dvi docs? It just makes my 'distcheck' fail. dvi: Cheers, Ralf