* 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 0000000..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 b/lib/Automake/tests/Version3.pl new file mode 100644 index 0000000..ebac23f --- /dev/null +++ b/lib/Automake/tests/Version3.pl @@ -0,0 +1,5 @@ +# prog_error due to invalid $REQUIRED. + +use Automake::Version; + +Automake::Version::check ('1.2.3', ''); -- 1.6.5.1.31.gad12b