Modified source files and compiled any and armel versions of packages
[pkg-perl] / deb-src / libperl-critic-perl / libperl-critic-perl-1.088 / xt / author / 93_version.t
1 #!perl -w
2 use warnings;
3 use strict;
4
5 use File::Find;
6 use Test::More;
7
8 plan 'no_plan';
9
10 my $last_version = undef;
11 find({wanted => \&check_version, no_chdir => 1}, 'blib');
12 if (! defined $last_version) {
13    fail('Failed to find any files with $VERSION');
14 }
15
16 sub check_version {
17    return if (! m{blib/script/}xms && ! m{\.pm \z}xms);
18
19    local $/ = undef;
20    my $fh;
21    open $fh, '<', $_ or die $!;
22    my $content = <$fh>;
23    close $fh;
24
25    # Skip POD
26    $content =~ s/^__END__.*//xms;
27
28    # only look at perl scripts, not sh scripts
29    return if (m{blib/script/}xms && $content !~ m/\A \#![^\r\n]+?perl/xms);
30
31    my @version_lines = $content =~ m/ ( [^\n]* \$VERSION [^\n]* ) /gxms;
32    # Special cases for printing/documenting version numbers
33    @version_lines = grep {! m/(?:\\|\"|\'|C<|v)\$VERSION/xms} @version_lines;
34    @version_lines = grep {! m/^\s*\#/xms} @version_lines;
35    if (@version_lines == 0) {
36       fail($_);
37    }
38    for my $line (@version_lines) {
39       if (!defined $last_version) {
40          $last_version = shift @version_lines;
41          pass($_);
42       }
43       else {
44          is($line, $last_version, $_);
45       }
46    }
47 }
48
49 # Local Variables:
50 #   mode: cperl
51 #   cperl-indent-level: 4
52 #   fill-column: 78
53 #   indent-tabs-mode: nil
54 #   c-indentation-style: bsd
55 # End:
56 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :