[t/spec] Properly fudge that last test.
[pugs.git] / t / test-file-summary.pl
blob288f315156f599ef5791bf63ba3b6a4fa258e612
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
5 use File::Find;
6 use Data::Dumper;
7 use List::Util qw(min);
10 my %search = (
11 'spec' => {},
12 'pugs' => {},
13 'xx-uncategorized' => {},
14 'unspecced' => {},
15 '01-sanity' => {},
16 '02-test-pm' => {},
18 my $re = join '|', keys %search;
19 $re = qr{/($re)/};
20 #print $re, $/;
22 find(\&wanted, (shift @ARGV) || '.');
23 my @others;
24 sub wanted {
25 if (m/\.(?:svn|git)\b/) {
26 $File::Find::prune = 1;
27 return
29 return unless m/\.t$/;
30 my $n = $File::Find::name;
32 my $plan = 0;
33 open (my $h, '<', $_) or die "Can't open '$_': $!";
35 local $/ = undef;
36 my $f = <$h>;
37 if ($f =~ m/plan\s+(\d+)/){
38 $plan = $1;
41 close $h;
43 if ( $n =~ m{$re} ) {
44 $search{$1}{files}++;
45 $search{$1}{plan} += $plan;
46 } else {
47 $search{other}{files}++;
48 $search{other}{plan} += $plan;
49 push @others, [$plan, $n];
53 print " Category Files Plan\n";
54 print "---------------------------------\n";
55 for (sort keys %search) {
56 printf "%18s %5d %6d\n", $_, $search{$_}{files}, $search{$_}{plan};
58 print "\n";
60 @others = reverse sort { $a->[0] <=> $b->[0] } @others;
61 for (0..min(12, $#others)) {
62 printf "%4d %s\n", $others[$_]->[0], $others[$_]->[1];
65 #print Dumper \%search;