fb8b40136628cbd11a2e8f875b77ab79aa875d19
[p5sagit/Class-Accessor-Grouped.git] / t / strict.t
1 use strict;
2 use warnings;
3
4 BEGIN {
5   use lib 't/lib';
6   use Test::More;
7   use File::Find;
8   use File::Basename;
9
10   plan skip_all => 'set TEST_AUTHOR to enable this test' unless $ENV{TEST_AUTHOR};
11
12   eval 'use Test::Strict';
13   plan skip_all => 'Test::Strict not installed' if $@;
14   plan skip_all => 'Need untaint in newer File::Find' if $] <= 5.006;
15 };
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. ;-)
19 my @files;
20 my %trusted = (
21   'NotReallyAClass.pm' => 1
22 );
23
24 find({
25   wanted => \&wanted,
26   untaint => 1,
27   untaint_pattern => qr|^([-+@\w./]+)$|,
28   untaint_skip => 1,
29   no_chdir => 1
30 }, qw(lib t));
31
32 sub 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
43 if (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
50 foreach (@files) {
51   strict_ok($_);
52 };