]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
Coverage for Version.pm.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sun, 18 Oct 2009 09:46:14 +0000 (11:46 +0200)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sun, 18 Oct 2009 10:34:29 +0000 (12:34 +0200)
* 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.Wildenhues@gmx.de>
ChangeLog
lib/Automake/tests/Makefile.am
lib/Automake/tests/Makefile.in
lib/Automake/tests/Version.pl
lib/Automake/tests/Version2.pl [new file with mode: 0644]
lib/Automake/tests/Version3.pl [new file with mode: 0644]

index 3cba9d5d858005484a9d4cff2ff97adccf105bd5..c4841df7df14217fc503661f9b1d56f78ab83822 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2009-10-18  Ralf Wildenhues  <Ralf.Wildenhues@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.
index b8fb76194969101f4d74d0ff5b471a08cd054901..19d100fa6e24fd1f41625ed68e29eb29b74679cc 100644 (file)
@@ -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)
index e44898b60abac25af196d6249cef1dc91bcf812d..2e38ba5e8e9b6c3452656839c07ae8269ceb689b 100644 (file)
@@ -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
 
index e49643519416f164e2918af8bf924e5b098f1790..bea91f0f00e8dd09eb25d532cb80548308258d84 100644 (file)
@@ -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 (file)
index 0000000..038466d
--- /dev/null
@@ -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 (file)
index 0000000..ebac23f
--- /dev/null
@@ -0,0 +1,5 @@
+# prog_error due to invalid $REQUIRED.
+
+use Automake::Version;
+
+Automake::Version::check ('1.2.3', '');