Author: paultcochrane
Date: Wed Jan 31 15:32:10 2007
New Revision: 16861

Modified:
   trunk/t/codingstd/perlcritic.t

Log:
[t] Added a new argument --listfiles which lists the files to be tested by
perlcritic.t.  Also moved the file-finding code above the policy defining
code.


Modified: trunk/t/codingstd/perlcritic.t
==============================================================================
--- trunk/t/codingstd/perlcritic.t      (original)
+++ trunk/t/codingstd/perlcritic.t      Wed Jan 31 15:32:10 2007
@@ -22,7 +22,7 @@
 
 my $perl_tidy_conf = 'tools/util/perltidy.conf';
 
-my ( @files, %policies, $list_policies );
+my ( @files, %policies, $list_policies, $list_files );
 
 while (@ARGV) {
     my $arg = $ARGV[0];
@@ -34,6 +34,10 @@
         $list_policies = 1;
         shift @ARGV;    # discard
     }
+    elsif ( $arg eq '--listfiles' ) {
+        $list_files = 1;
+        shift @ARGV;    #discard
+    }
     elsif ( $arg =~ /^--(.*)/ ) {
         $policies{$1} = 1;
         shift @ARGV;    # discard
@@ -43,6 +47,45 @@
     }
 }
 
+# get the files to check
+my $DIST = Parrot::Distribution->new();
+if ( [EMAIL PROTECTED] ) {
+    @files = map { $_->path } $DIST->get_perl_language_files();
+}
+else {
+
+    # does the first
+
+    # if we're passed a directory, find all the matching files
+    # under that directory.
+
+    # use $_ for the check below, as File::Find chdirs on us.
+    foreach my $file (@ARGV) {
+        ( -d $file )
+            ? find(
+            sub {
+                if ( -d $_ and $_ eq '.svn' ) {
+                    $File::Find::prune = 1;
+                    return;
+                }
+                if ( is_perl($_) ) {
+                    push @files, $File::Find::name;
+                }
+            },
+            $file
+            )
+            : push @files, $file;
+    }
+}
+
+if ( $list_files ) {
+    print "Files to be tested by perlcritic:\n";
+    for my $file ( @files ) {
+        print $file, "\n";
+    }
+    exit;
+}
+
 # Add in the few cases we should care about.
 # For a list of available policies, perldoc Perl::Critic
 if ( !keys %policies ) {
@@ -86,37 +129,6 @@
     exit;
 }
 
-# get the files to check
-my $DIST = Parrot::Distribution->new();
-if ( [EMAIL PROTECTED] ) {
-    @files = map { $_->path } $DIST->get_perl_language_files();
-}
-else {
-
-    # does the first
-
-    # if we're passed a directory, find all the matching files
-    # under that directory.
-
-    # use $_ for the check below, as File::Find chdirs on us.
-    foreach my $file (@ARGV) {
-        ( -d $file )
-            ? find(
-            sub {
-                if ( -d $_ and $_ eq '.svn' ) {
-                    $File::Find::prune = 1;
-                    return;
-                }
-                if ( is_perl($_) ) {
-                    push @files, $File::Find::name;
-                }
-            },
-            $file
-            )
-            : push @files, $file;
-    }
-}
-
 # the number of tests is the number of policies
 if ( keys %policies ) {
     plan tests => scalar keys %policies;

Reply via email to