« blib/lib/auto/share/dist/Module-Provision/boilerplate.pm
↑ Summary
lib/Module/Provision/Config.pm »
| 1 | package t::boilerplate; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use File::Spec::Functions qw( catdir catfile updir ); | ||
| 6 | use FindBin qw( $Bin ); | ||
| 7 | use lib catdir( $Bin, updir, 'lib' ), catdir( $Bin, 'lib' ); | ||
| 8 | |||
| 9 | use Module::Build; | ||
| 10 | use Sys::Hostname; | ||
| 11 | |||
| 12 | sub plan (;@) { | ||
| 13 | $_[ 0 ] eq 'skip_all' and print '1..0 # SKIP '.$_[ 1 ]."\n" and exit 0; | ||
| 14 | } | ||
| 15 | |||
| 16 | my ($builder, $host, $notes, $perl_ver); | ||
| 17 | |||
| 18 | BEGIN { | ||
| 19 | $host = lc hostname; | ||
| 20 | $builder = eval { Module::Build->current }; | ||
| 21 | $notes = $builder ? $builder->notes : {}; | ||
| 22 | $perl_ver = $notes->{min_perl_version} || 5.008; | ||
| 23 | |||
| 24 | eval { require Test::Requires }; $@ and plan skip_all => 'No Test::Requires'; | ||
| 25 | |||
| 26 | $Bin =~ m{ : .+ : }mx and plan skip_all => 'Two colons in $Bin path'; | ||
| 27 | |||
| 28 | if ($notes->{testing}) { | ||
| 29 | my $dumped = catfile( 't', 'whitelist.dd' ); | ||
| 30 | my $include = {}; -f $dumped and $include = do $dumped; | ||
| 31 | my $hit = 0; | ||
| 32 | |||
| 33 | for my $key (keys %{ $include }) { | ||
| 34 | $host =~ m{ $key \z }mx and $hit = 1 and last; | ||
| 35 | } | ||
| 36 | |||
| 37 | $hit or plan skip_all => 'Not a whitelisted smoker'; | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | use Test::Requires "${perl_ver}"; | ||
| 42 | use Test::Requires { version => 0.88 }; | ||
| 43 | |||
| 44 | use version; our $VERSION = qv( '0.4' ); | ||
| 45 | |||
| 46 | sub import { | ||
| 47 | strict->import; | ||
| 48 | $] < 5.008 ? warnings->import : warnings->import( NONFATAL => 'all' ); | ||
| 49 | return; | ||
| 50 | } | ||
| 51 | |||
| 52 | 1; | ||
| 53 | |||
| 54 | # Local Variables: | ||
| 55 | # mode: perl | ||
| 56 | # tab-width: 3 | ||
| 57 | # End: | ||
| 58 | # vim: expandtab shiftwidth=3: |