1use strict; 2use warnings; 3use Test::More; 4 5BEGIN { 6 plan skip_all => 'Need untaint in newer File::Find' if $] <= 5.006; 7} 8 9BEGIN { 10 eval 'use Test::Strict; 1' 11 or plan skip_all => 'Test::Strict not installed'; 12} 13 14use File::Find; 15use File::Basename; 16 17## I hope this can go away if Test::Strict or File::Find::Rule 18## finally run under -T. Until then, I'm on my own here. ;-) 19my @files; 20my %trusted = ( 21 'NotReallyAClass.pm' => 1 22); 23 24find({ 25 wanted => \&wanted, 26 untaint => 1, 27 untaint_pattern => qr|^([-+@\w./]+)$|, 28 untaint_skip => 1, 29 no_chdir => 1 30}, qw(lib t)); 31 32sub wanted { 33 my $name = $File::Find::name; 34 my $file = fileparse($name); 35 36 return if $name =~ /TestApp/; 37 38 if ($name =~ /\.(pm|pl|t)$/i && !exists($trusted{$file})) { 39 push @files, $name; 40 }; 41}; 42 43if (scalar @files) { 44 plan tests => scalar @files; 45} else { 46 plan tests => 1; 47 fail 'No perl files found for Test::Strict checks!'; 48}; 49 50foreach (@files) { 51 strict_ok($_); 52} 53