10 $testcount = scalar @Support::Files::testitems;
13 use Test::More tests => $testcount;
15 # Capture the TESTOUT from Test::More or Test::Builder for printing errors.
16 # This will handle verbosity for us automatically.
19 local $^W = 0; # Don't complain about non-existent filehandles
20 if (-e \*Test::More::TESTOUT) {
21 $fh = \*Test::More::TESTOUT;
22 } elsif (-e \*Test::Builder::TESTOUT) {
23 $fh = \*Test::Builder::TESTOUT;
29 my @testitems = @Support::Files::testitems;
31 # at last, here we actually run the test...
33 my @common_errors = ([ '^\s*my\s+%[a-z0-9_]+\s*=\s*shift' ],
34 [ '^\s*my\s+\(.*\)\s*=\s*shift' ],
35 [ '^\s*my\s+\$[^=]*=\s*@_' ],
41 foreach my $file (@testitems) {
42 $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
43 next if (!$file); # skip null entries
45 if (open (FILE, $file)) { # open the file for reading
46 $_->[1] = [] foreach @common_errors;
49 while (my $file_line = <FILE>) {
52 foreach my $re (@common_errors) {
53 push @{ $re->[1] }, $line_number if $file_line =~ /$re->[0]/i;
59 my $errors = join(' ', map { $_->[0] . ' (' . join(' ', @{ $_->[1] }) . ')' } grep { scalar @{ $_->[1] } } @common_errors);
61 ok(0,"$file: found common errors: $errors");
63 ok(1,"$file does not contain common errors");
66 ok(0,"could not open $file for common errors check --WARNING");