8 use Thread::Pool::Simple;
13 $testcount = scalar @Support::Files::testitems;
16 use Test::More tests => $testcount;
18 # Capture the TESTOUT from Test::More or Test::Builder for printing errors.
19 # This will handle verbosity for us automatically.
22 local $^W = 0; # Don't complain about non-existent filehandles
23 if (-e \*Test::More::TESTOUT) {
24 $fh = \*Test::More::TESTOUT;
25 } elsif (-e \*Test::Builder::TESTOUT) {
26 $fh = \*Test::Builder::TESTOUT;
32 my @testitems = @Support::Files::testitems;
34 # at last, here we actually run the test...
36 my @common_errors = ([ '^\s*my\s+%[a-z0-9_]+\s*=\s*shift' ],
37 [ '^\s*my\s+\(.*\)\s*=\s*shift' ],
38 [ '^\s*my\s+\$[^=]*=\s*@_' ],
46 $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
47 return if (!$file); # skip null entries
49 if (open (FILE, $file)) { # open the file for reading
50 $_->[1] = [] foreach @common_errors;
53 while (my $file_line = <FILE>) {
56 foreach my $re (@common_errors) {
57 push @{ $re->[1] }, $line_number if $file_line =~ /$re->[0]/i;
63 my $errors = join(' ', map { $_->[0] . ' (' . join(' ', @{ $_->[1] }) . ')' } grep { scalar @{ $_->[1] } } @common_errors);
65 ok(0,"$file: found common errors: $errors");
67 ok(1,"$file does not contain common errors");
70 ok(0,"could not open $file for common errors check --WARNING");
74 my $pool = Thread::Pool::Simple->new(
76 max => Sys::CPU::cpu_count() + 1,
77 do => [ \&test_file ],
81 $pool->add($_) for @testitems;