Permalink
Browse files

move module reading function to Task::DWIM and test all the modules

  • Loading branch information...
1 parent 16a054b commit 555c82e929706bd1b18e4cbab52d8e8b5602f3f6 @szabgab szabgab committed Dec 13, 2012
Showing with 34 additions and 21 deletions.
  1. +1 −0 CHANGES
  2. +5 −19 Makefile.PL
  3. +18 −0 lib/Task/DWIM.pm
  4. +10 −2 t/00-load.t
View
@@ -7,6 +7,7 @@ v0.03
Add Task::Kensho::DBDev
Add Task::Kensho::ExcelCSV
Add Task::Kensho::ModuleDev
+ Add self testing of all the modules
v0.02 2012.12.13
View
@@ -1,11 +1,15 @@
use inc::Module::Install;
+use lib 'lib';
+use Task::DWIM;
name 'Task-DWIM';
all_from 'lib/Task/DWIM.pm';
#build_requires 'Test::More' => '0.42';
#build_requires 'File::Spec' => '0.80';
-my $modules = read_modules();
+requires perl => 5.008;
+
+my $modules = Task::DWIM::read_modules();
foreach my $name (keys %$modules) {
requires $name => $modules->{$name};
}
@@ -15,21 +19,3 @@ repository 'https://github.com/dwimperl/Task-DWIM';
WriteAll;
-sub read_modules {
- my %modules;
- open my $fh, '<', 'modules.txt' or die;
- while (my $line = <$fh>) {
- chomp $line;
- next if $line =~ /^\s*(#.*)?$/;
- $line =~ s/\s*#.*//;
- my ($name, $version) = split /\s*=\s*/, $line;
- if (exists $modules{$name}) {
- die "Module '$name' has 2 entries. One with '$modules{$name}' and the other one with '$version'";
- }
- $modules{$name} = $version;
- }
- close $fh;
- return \%modules;
-}
-
-
View
@@ -4,6 +4,24 @@ use 5.008;
use strict;
our $VERSION = '0.02';
+sub read_modules {
+ my %modules;
+ open my $fh, '<', 'modules.txt' or die;
+ while (my $line = <$fh>) {
+ chomp $line;
+ next if $line =~ /^\s*(#.*)?$/;
+ $line =~ s/\s*#.*//;
+ my ($name, $version) = split /\s*=\s*/, $line;
+ if (exists $modules{$name}) {
+ die "Module '$name' has 2 entries. One with '$modules{$name}' and the other one with '$version'";
+ }
+ $modules{$name} = $version;
+ }
+ close $fh;
+ return \%modules;
+}
+
+
1;
__END__
View
@@ -3,6 +3,14 @@
use strict;
use warnings;
-use Test::More tests => 1;
+use Test::More;
use Task::DWIM;
-ok(1);
+
+my $modules = Task::DWIM::read_modules();
+plan tests => scalar keys %$modules;
+
+foreach my $name (keys %$modules) {
+ no warnings 'redefine';
+ eval "use $name ()";
+ is $@, '', $name;
+}

0 comments on commit 555c82e

Please sign in to comment.