4 use RT::Test nodb => 1;
8 find( sub { push @files, $File::Find::name if -f },
9 qw{etc lib share t bin sbin devel/tools} );
10 if ( my $dir = `git rev-parse --git-dir 2>/dev/null` ) {
11 # We're in a git repo, use the ignore list
14 $ignores{ $_ }++ for grep $_, split /\n/,
15 `git ls-files -o -i --exclude-standard .`;
16 @files = grep {not $ignores{$_}} @files;
31 if ($check{strict} or $check{warnings} or $check{shebang} or $check{bps_tag} or $check{no_tabs}) {
33 open my $fh, '<', $file or die $!;
38 qr/^use strict(?:;|\s+)/m,
39 "$file has 'use strict'"
44 qr/^use warnings(?:;|\s+)/m,
45 "$file has 'use warnings'"
46 ) if $check{warnings};
48 if ($check{shebang} == 1) {
49 like( $content, qr/^#!/, "$file has shebang" );
50 } elsif ($check{shebang} == -1) {
51 unlike( $content, qr/^#!/, "$file has no shebang" );
54 $check{bps_tag} = -1 if $check{bps_tag} == 1
55 and not $content =~ /Copyright\s+\(c\)\s+\d\d\d\d-\d\d\d\d Best Practical Solutions/i
56 and $file =~ /(?:ckeditor|scriptaculous|superfish|tablesorter|farbtastic)/i;
57 $check{bps_tag} = -1 if $check{bps_tag} == 1
58 and not $content =~ /Copyright\s+\(c\)\s+\d\d\d\d-\d\d\d\d Best Practical Solutions/i
59 and ($content =~ /\b(copyright|GPL|Public Domain)\b/i
60 or /\(c\)\s+\d\d\d\d(?:-\d\d\d\d)?/i);
61 if ($check{bps_tag} == 1) {
62 like( $content, qr/[B]EGIN BPS TAGGED BLOCK {{{/, "$file has BPS license tag");
63 } elsif ($check{bps_tag} == -1) {
64 unlike( $content, qr/[B]EGIN BPS TAGGED BLOCK {{{/, "$file has no BPS license tag");
68 my $executable = ( stat $file )[2] & 0100;
69 if ($check{exec} == 1) {
70 if ( $file =~ /\.in$/ ) {
71 ok( !$executable, "$file permission is u-x (.in will add +x)" );
73 ok( $executable, "$file permission is u+x" );
75 } elsif ($check{exec} == -1) {
76 ok( !$executable, "$file permission is u-x" );
80 check( $_, shebang => -1, exec => -1, warnings => 1, strict => 1, bps_tag => 1 )
81 for grep {m{^lib/.*\.pm$}} @files;
83 check( $_, shebang => -1, exec => -1, warnings => 1, strict => 1, bps_tag => -1 )
84 for grep {m{^t/.*\.t$}} @files;
86 check( $_, shebang => 1, exec => 1, warnings => 1, strict => 1, bps_tag => 1 )
87 for grep {m{^s?bin/}} @files;
89 check( $_, shebang => 1, exec => 1, warnings => 1, strict => 1, bps_tag => 1 )
90 for grep {m{^devel/tools/} and not m{/(localhost\.(crt|key)|mime\.types)$}} @files;
92 check( $_, exec => -1, bps_tag => not m{\.(png|gif|jpe?g)$} )
93 for grep {m{^share/html/}} @files;
95 check( $_, exec => -1 )
96 for grep {m{^share/(po|fonts)/}} @files;
98 check( $_, exec => -1 )
99 for grep {m{^t/data/}} @files;
101 check( $_, exec => -1, bps_tag => -1 )
102 for grep {m{^etc/[^/]+$}} @files;
104 check( $_, exec => -1, bps_tag => -1 )
105 for grep {m{^etc/upgrade/[^/]+/}} @files;
107 check( $_, warnings => 1, strict => 1, compile_perl => 1, no_tabs => 1 )
108 for grep {m{^etc/upgrade/.*/content$}} @files;
110 check( $_, shebang => 1, exec => 1, warnings => 1, strict => 1, bps_tag => 1, no_tabs => 1 )
111 for grep {m{^etc/upgrade/[^/]+$}} @files;
113 check( $_, compile_perl => 1, exec => 1 )
114 for grep{ -f $_} map {s/\.in$//; $_} grep {m{^etc/upgrade/[^/]+$}} @files;
116 check( $_, exec => -1 )
117 for grep {m{^(devel/)?docs/}} @files;