From: Ralf Wildenhues Date: Sun, 18 Oct 2009 09:46:14 +0000 (+0200) Subject: Coverage for Version.pm. X-Git-Tag: ng-0.5a~460^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39880d9d00baa3c8c2352aca688256816e84226c;p=thirdparty%2Fautomake.git 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 --- diff --git a/ChangeLog b/ChangeLog index 3cba9d5d8..c4841df7d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2009-10-18 Ralf Wildenhues + 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 b8fb76194..19d100fa6 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 e44898b60..2e38ba5e8 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 e49643519..bea91f0f0 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 000000000..038466deb --- /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 000000000..ebac23f91 --- /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', '');