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;
30 if ($check{strict} or $check{warnings} or $check{shebang} or $check{bps_tag}) {
32 open my $fh, '<', $file or die $!;
37 qr/^use strict(?:;|\s+)/m,
38 "$file has 'use strict'"
43 qr/^use warnings(?:;|\s+)/m,
44 "$file has 'use warnings'"
45 ) if $check{warnings};
47 if ($check{shebang} == 1) {
48 like( $content, qr/^#!/, "$file has shebang" );
49 } elsif ($check{shebang} == -1) {
50 unlike( $content, qr/^#!/, "$file has no shebang" );
53 $check{bps_tag} = -1 if $check{bps_tag} == 1
54 and not $content =~ /Copyright\s+\(c\)\s+\d\d\d\d-\d\d\d\d Best Practical Solutions/i
55 and $file =~ /(?:ckeditor|scriptaculous|superfish|tablesorter|farbtastic)/i;
56 $check{bps_tag} = -1 if $check{bps_tag} == 1
57 and not $content =~ /Copyright\s+\(c\)\s+\d\d\d\d-\d\d\d\d Best Practical Solutions/i
58 and ($content =~ /\b(copyright|GPL|Public Domain)\b/i
59 or /\(c\)\s+\d\d\d\d(?:-\d\d\d\d)?/i);
60 if ($check{bps_tag} == 1) {
61 like( $content, qr/[B]EGIN BPS TAGGED BLOCK {{{/, "$file has BPS license tag");
62 } elsif ($check{bps_tag} == -1) {
63 unlike( $content, qr/[B]EGIN BPS TAGGED BLOCK {{{/, "$file has no BPS license tag");
67 my $executable = ( stat $file )[2] & 0100;
68 if ($check{exec} == 1) {
69 if ( $file =~ /\.in$/ ) {
70 ok( !$executable, "$file permission is u-x (.in will add +x)" );
72 ok( $executable, "$file permission is u+x" );
74 } elsif ($check{exec} == -1) {
75 ok( !$executable, "$file permission is u-x" );
79 check( $_, shebang => -1, exec => -1, warnings => 1, strict => 1, bps_tag => 1 )
80 for grep {m{^lib/.*\.pm$}} @files;
82 check( $_, shebang => -1, exec => -1, warnings => 1, strict => 1, bps_tag => -1 )
83 for grep {m{^t/.*\.t$}} @files;
85 check( $_, shebang => 1, exec => 1, warnings => 1, strict => 1, bps_tag => 1 )
86 for grep {m{^s?bin/}} @files;
88 check( $_, shebang => 1, exec => 1, warnings => 1, strict => 1, bps_tag => 1 )
89 for grep {m{^devel/tools/} and not m{/(localhost\.(crt|key)|mime\.types)$}} @files;
91 check( $_, exec => -1, bps_tag => not m{\.(png|gif|jpe?g)$} )
92 for grep {m{^share/html/}} @files;
94 check( $_, exec => -1 )
95 for grep {m{^share/(po|fonts)/}} @files;
97 check( $_, exec => -1 )
98 for grep {m{^t/data/}} @files;
100 check( $_, exec => -1, bps_tag => -1 )
101 for grep {m{^etc/upgrade/[^/]+/}} @files;