diff -ur Test-PerlTidy-20070911.orig/lib/Test/PerlTidy.pm Test-PerlTidy-20070911/lib/Test/PerlTidy.pm
--- Test-PerlTidy-20070911.orig/lib/Test/PerlTidy.pm 2007-09-11 17:50:39.000000000 +0000
+++ Test-PerlTidy-20070911/lib/Test/PerlTidy.pm 2009-09-21 09:57:39.000000000 +0000
@@ -28,8 +28,11 @@
# Skip all tests if instructed to.
$Test->skip_all("All tests skipped.") if $args{skip_all};
+ $args{top} ||= '.';
+ $MUTE ||= $args{mute};
+
# Get files to work with and set the plan.
- my @files = list_files('.');
+ my @files = list_files(%args);
$Test->plan( tests => scalar @files );
# Check ech file in turn.
@@ -80,7 +83,24 @@
}
sub list_files {
- my $path = shift;
+ my $args_ref = \@_;
+ my %args;
+
+ my $path;
+ my $exclude = [ './blib/' ]; # filter out blib by default
+
+ if(scalar(@$args_ref) > 1) {
+ %args=@$args_ref;
+
+ $Test->BAIL_OUT( 'exclude should be an array' )
+ if( $args{exclude} && ref $args{exclude} ne 'ARRAY' );
+
+ $exclude = $args{exclude};
+ $path=$args{top};
+ } else {
+ $path = $args_ref->[0];
+ }
+
die "You need to specify which directory to scan"
unless defined $path && length $path;
@@ -92,6 +112,24 @@
# Find files using File::Finder.
@files = File::Finder->type('f')->in($path);
+ if($exclude) {
+ my @removed;
+ my @include;
+
+ foreach my $item(@$exclude) {
+ push(@removed, grep{ m|^$item| } @files );
+ push(@include, grep{ !m|^$item| } @files );
+
+ @files=@include;
+ @include = ();
+ }
+
+ if( $args{debug}) {
+ $Test->diag( 'Files excluded: ', join("\n\t", @removed),$/ );
+ $Test->diag( 'Files remaining ', join("\n\t", @files),$/ );
+ }
+ }
+
return
# Sort the output so that it is repeatable
@@ -100,8 +138,7 @@
# Filter out only the files that end in .pl, .pm, .PL or .t
grep { m/\.(pl|pm|PL|t)$/; }
- # Filter out blib
- grep { !m|^\./blib/|; } @files;
+ @files;
}
sub load_file {
@@ -124,6 +161,8 @@
# In a file like 't/perltidy.t'
use Test::PerlTidy;
run_tests();
+ # or
+ run_tests( top => '.', exclude => [ './blib/' ], debug => 0, mute => 0 );
=head1 DESCRIPTION
diff -ur Test-PerlTidy-20070911.orig/t/list_files.t Test-PerlTidy-20070911/t/list_files.t
--- Test-PerlTidy-20070911.orig/t/list_files.t 2007-09-11 18:09:53.000000000 +0000
+++ Test-PerlTidy-20070911/t/list_files.t 2009-09-21 09:33:31.000000000 +0000
@@ -9,6 +9,8 @@
(
'./Makefile.PL', #
'./lib/Test/PerlTidy.pm', #
+ './t/exclude_files.t', #
+ './t/exclude_perltidy.t', #
'./t/list_files.t', #
'./t/perltidy.t', #
'./t/is_file_tidy.t', #