Permalink
Browse files

test version numbers

  • Loading branch information...
1 parent 7d23aa8 commit 5b3e550dcb100e59e5e283b9ad6b488e27344bd3 @szabgab szabgab committed Dec 23, 2012
Showing with 29 additions and 4 deletions.
  1. +3 −2 Makefile.PL
  2. +2 −1 lib/Task/DWIM.pm
  3. +24 −1 t/00-load.t
View
@@ -4,8 +4,9 @@ use Task::DWIM;
name 'Task-DWIM';
all_from 'lib/Task/DWIM.pm';
-#build_requires 'Test::More' => '0.42';
-#build_requires 'File::Spec' => '0.80';
+
+build_requires 'Test::More' => '0.42';
+build_requires 'Perl::Version' => '1.011';
requires perl => 5.008;
View
@@ -2,6 +2,7 @@ package Task::DWIM;
use 5.008;
use strict;
+use warnings;
our $VERSION = '0.06';
my %modules;
@@ -51,7 +52,7 @@ sub get_modules {
sub read_modules {
my ($file) = @_;
- my $file = "lists/$file";
+ $file = "lists/$file";
return if not -e '.git' and not -e $file;
View
@@ -5,23 +5,46 @@ use warnings;
use Test::More;
use Task::DWIM;
+use Perl::Version;
my %modules = Task::DWIM::get_modules();
-plan tests => 1 + 2 * scalar keys %modules;
+plan tests => 1 + 3 * scalar keys %modules;
ok(1, 'loaded Task::DWIM');
my %SKIP = (
'Readonly::XS' => 'Readonly::XS is not stand alone module.',
+ # use did not work well
+
+ 'Devel::NYTProf' => 'No need to profile ourselves',
+
+ 'strictures' => 'Invalid version format (version required) at strictures.pm line 21.'
+ # strictures::VERSION(** Incomplete caller override detected in &Hook::LexWrap::__ANON__[Hook/LexWrap.pm:21]; @DB::args were not set **) called at t/00-load.t line 30
+ # The use statement was OK, but checking the VERSION blew it up
+
);
foreach my $name (keys %modules) {
+
+ # Check if the module can be loaded
SKIP: {
skip $SKIP{$name}, 1 if $SKIP{$name};
no warnings 'redefine';
eval "use $name ()";
is $@, '', $name;
}
+
+ # Check if the version number at least the one we asked for
+ SKIP: {
+ skip $SKIP{$name}, 1 if $SKIP{$name};
+ if ($name->VERSION =~ /v/ or split(/\./, $name->VERSION) > 2) {
+ cmp_ok( Perl::Version->new($name->VERSION), '>=', Perl::Version->new($modules{$name}), "Version of $name");
+ } else {
+ cmp_ok( $name->VERSION, '>=', $modules{$name}, "Version of $name");
+ }
+ }
+
+ # Check if the version number is exactly the one we asked for
SKIP: {
skip $SKIP{$name}, 1 if $SKIP{$name};
skip "Need ENV variable VERSION to check exact version ", 1 if not $ENV{VERSION};

0 comments on commit 5b3e550

Please sign in to comment.