From: Vincent Pit Date: Sun, 19 Aug 2012 15:17:13 +0000 (+0200) Subject: Test installed prereqs X-Git-Tag: v0.930.0~1 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=ce944712f5232aac857a6a435f27d5e954617d53;p=perl%2Fmodules%2FTask-Devel-Cover-Recommended.git Test installed prereqs --- diff --git a/MANIFEST b/MANIFEST index e06241a..37f1a31 100644 --- a/MANIFEST +++ b/MANIFEST @@ -7,6 +7,7 @@ README lib/Task/Devel/Cover/Recommended.pm samples/generate.pl t/00-load.t +t/01-deps.t t/91-pod.t t/92-pod-coverage.t t/95-portability-files.t diff --git a/samples/generate.pl b/samples/generate.pl index e93562e..0c5307c 100644 --- a/samples/generate.pl +++ b/samples/generate.pl @@ -226,6 +226,7 @@ my %vars = ( sorthr $prereqs{run}, $target_pkg => $target_version, ), + TESTED_PREREQS => deplist_to_perl(sorthr $prereqs{run}), BUG_EMAIL => $bug_email, BUG_QUEUE => $bug_queue, YEARS => $years, @@ -353,6 +354,34 @@ WriteMakefile( FILES => "$dist-* *.gcov *.gcda *.gcno cover_db Debian_CPANTS.txt*" } ); +TEMPLATE + # ---------------------------------------------------------------------------- + 't/01-deps.t' => <<'TEMPLATE', +#!perl + +use strict; +use warnings; + +use Test::More; + +my $TESTED_PREREQS = __TESTED_PREREQS__; + +plan tests => keys(%$TESTED_PREREQS) + 1; + +my @tests = map [ $_ => $TESTED_PREREQS->{$_} ], keys %$TESTED_PREREQS; +push @tests, [ '__TARGET_PKG__' => '__TARGET_VERSION__' ]; + +for my $test (@tests) { + my ($module, $version) = @$test; + local $@; + if ($version && $version !~ /^[0._]*$/) { + eval "use $module $version ()"; + is $@, '', "$module v$version is available"; + } else { + eval "use $module ()"; + is $@, '', "any version of $module is available"; + } +} TEMPLATE ); diff --git a/t/01-deps.t b/t/01-deps.t new file mode 100644 index 0000000..0859332 --- /dev/null +++ b/t/01-deps.t @@ -0,0 +1,35 @@ +#!perl + +use strict; +use warnings; + +use Test::More; + +my $TESTED_PREREQS = { + 'Browser::Open' => '0', + 'Digest::MD5' => '0', + 'JSON::PP' => '0', + 'PPI::HTML' => '1.07', + 'Parallel::Iterator' => '0', + 'Pod::Coverage' => '0.06', + 'Pod::Coverage::CountParents' => '0', + 'Storable' => '0', + 'Template' => '2.00', +}; + +plan tests => keys(%$TESTED_PREREQS) + 1; + +my @tests = map [ $_ => $TESTED_PREREQS->{$_} ], keys %$TESTED_PREREQS; +push @tests, [ 'Devel::Cover' => '0.93' ]; + +for my $test (@tests) { + my ($module, $version) = @$test; + local $@; + if ($version && $version !~ /^[0._]*$/) { + eval "use $module $version ()"; + is $@, '', "$module v$version is available"; + } else { + eval "use $module ()"; + is $@, '', "any version of $module is available"; + } +}