r51306 - in /branches/upstream/libtest-eol-perl/current: Changes META.yml README lib/Test/EOL.pm t/11-all.t t/12-fail.t

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Thu Jan 21 22:02:25 UTC 2010


Author: jawnsy-guest
Date: Thu Jan 21 22:01:40 2010
New Revision: 51306

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=51306
Log:
[svn-upgrade] Integrating new upstream version, libtest-eol-perl (0.6)

Modified:
    branches/upstream/libtest-eol-perl/current/Changes
    branches/upstream/libtest-eol-perl/current/META.yml
    branches/upstream/libtest-eol-perl/current/README
    branches/upstream/libtest-eol-perl/current/lib/Test/EOL.pm
    branches/upstream/libtest-eol-perl/current/t/11-all.t
    branches/upstream/libtest-eol-perl/current/t/12-fail.t

Modified: branches/upstream/libtest-eol-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-eol-perl/current/Changes?rev=51306&op=diff
==============================================================================
--- branches/upstream/libtest-eol-perl/current/Changes (original)
+++ branches/upstream/libtest-eol-perl/current/Changes Thu Jan 21 22:01:40 2010
@@ -1,4 +1,15 @@
-Revision history for Test-NoTabs
+Revision history for Test-EOL
+
+0.6  2010-01-19
+     - I'm so bad at this!  Fix another logic error that made all files fail
+       when using trailing_whitespace option (fREW)
+
+0.5  2010-01-19
+     - Fix logic fail that made all filenames the same if a user uses the
+       trailing_whitespace option (fREW)
+
+0.4  2010-01-19
+     - Add checks for trailing whitespace (fREW)
 
 0.3  2009-07-18
      - Fix File::Find regex which I had broken.

Modified: branches/upstream/libtest-eol-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-eol-perl/current/META.yml?rev=51306&op=diff
==============================================================================
--- branches/upstream/libtest-eol-perl/current/META.yml (original)
+++ branches/upstream/libtest-eol-perl/current/META.yml Thu Jan 21 22:01:40 2010
@@ -26,4 +26,4 @@
 resources:
   license: http://dev.perl.org/licenses/
   repository: git://github.com/bobtfish/perl-test-eol.git
-version: 0.3
+version: 0.6

Modified: branches/upstream/libtest-eol-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-eol-perl/current/README?rev=51306&op=diff
==============================================================================
--- branches/upstream/libtest-eol-perl/current/README (original)
+++ branches/upstream/libtest-eol-perl/current/README Thu Jan 21 22:01:40 2010
@@ -7,6 +7,11 @@
 
       use Test::EOL tests => 1;
       eol_unix_ok( 'lib/Module.pm', 'Module is ^M free');
+
+    and to add checks for trailing whitespace:
+
+      use Test::EOL tests => 1;
+      eol_unix_ok( 'lib/Module.pm', 'Module is ^M and trailing whitespace free', { trailing_whitespace => 1 });
 
     Module authors can include the following in a t/eol.t and have
     "Test::EOL" automatically find and check all perl files in a module
@@ -20,6 +25,16 @@
       use Test::EOL;
       all_perl_files_ok( @mydirs );
 
+    and if authors would like to check for trailing whitespace:
+
+      use Test::EOL;
+      all_perl_files_ok({ trailing_whitespace => 1 });
+
+    or
+
+      use Test::EOL;
+      all_perl_files_ok({ trailing_whitespace => 1 }, @mydirs );
+
 DESCRIPTION
     This module scans your project/distribution for any perl files (scripts,
     modules, etc) for the presence of windows line endings.
@@ -29,7 +44,7 @@
     you don't export anything, such as for a purely object-oriented module.
 
 FUNCTIONS
-  all_perl_files_ok( [ @directories ] )
+  all_perl_files_ok( [ \%options ], [ @directories ] )
     Applies "eol_unix_ok()" to all perl files found in @directories (and sub
     directories). If no <@directories> is given, the starting point is one
     level above the current running script, that should cover all the files
@@ -43,7 +58,7 @@
 
     the total number of files tested must be specified.
 
-  eol_unix_ok( $file [, $text] )
+  eol_unix_ok( $file [, $text] [, \%options ]  )
     Run a unix EOL check on $file. For a module, the path (lib/My/Module.pm)
     or the name (My::Module) can be both used.
 

Modified: branches/upstream/libtest-eol-perl/current/lib/Test/EOL.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-eol-perl/current/lib/Test/EOL.pm?rev=51306&op=diff
==============================================================================
--- branches/upstream/libtest-eol-perl/current/lib/Test/EOL.pm (original)
+++ branches/upstream/libtest-eol-perl/current/lib/Test/EOL.pm Thu Jan 21 22:01:40 2010
@@ -10,7 +10,7 @@
 
 use vars qw( $VERSION $PERL $UNTAINT_PATTERN $PERL_PATTERN);
 
-$VERSION = '0.3';
+$VERSION = '0.6';
 
 $PERL    = $^X || 'perl';
 $UNTAINT_PATTERN  = qr|^([-+@\w./:\\]+)$|;
@@ -64,13 +64,22 @@
 
 sub eol_unix_ok {
     my $file = shift;
-    my $test_txt = shift || "No windows line endings in '$file'";
+    my $test_txt;
+    $test_txt   = shift if !ref $_[0];
+    $test_txt ||= "No windows line endings in '$file'";
+    my $options = shift if ref $_[0] eq 'HASH';
+    $options ||= {
+        trailing_whitespace => 0,
+    };
     $file = _module_to_path($file);
     open my $fh, $file or do { $Test->ok(0, $test_txt); $Test->diag("Could not open $file: $!"); return; };
     my $line = 0;
     while (<$fh>) {
         $line++;
-        if ( /\r$/ ) {
+        if (
+           (!$options->{trailing_whitespace} && /\r$/) ||
+           ( $options->{trailing_whitespace} && /(\r|[ \t]+)$/)
+        ) {
           $Test->ok(0, $test_txt . " on line $line");
           return 0;
         }
@@ -78,12 +87,12 @@
     $Test->ok(1, $test_txt);
     return 1;
 }
-
 sub all_perl_files_ok {
+    my $options = shift if ref $_[0] eq 'HASH';
     my @files = _all_perl_files( @_ );
     _make_plan();
     foreach my $file ( @files ) {
-      eol_unix_ok($file);
+      eol_unix_ok($file, $options);
     }
 }
 
@@ -142,6 +151,11 @@
   use Test::EOL tests => 1;
   eol_unix_ok( 'lib/Module.pm', 'Module is ^M free');
 
+and to add checks for trailing whitespace:
+
+  use Test::EOL tests => 1;
+  eol_unix_ok( 'lib/Module.pm', 'Module is ^M and trailing whitespace free', { trailing_whitespace => 1 });
+
 Module authors can include the following in a t/eol.t and have C<Test::EOL>
 automatically find and check all perl files in a module distribution:
 
@@ -153,6 +167,16 @@
   use Test::EOL;
   all_perl_files_ok( @mydirs );
 
+and if authors would like to check for trailing whitespace:
+
+  use Test::EOL;
+  all_perl_files_ok({ trailing_whitespace => 1 });
+
+or
+
+  use Test::EOL;
+  all_perl_files_ok({ trailing_whitespace => 1 }, @mydirs );
+
 =head1 DESCRIPTION
 
 This module scans your project/distribution for any perl files (scripts,
@@ -165,7 +189,7 @@
 
 =head1 FUNCTIONS
 
-=head2 all_perl_files_ok( [ @directories ] )
+=head2 all_perl_files_ok( [ \%options ], [ @directories ] )
 
 Applies C<eol_unix_ok()> to all perl files found in C<@directories> (and sub
 directories). If no <@directories> is given, the starting point is one level
@@ -180,7 +204,7 @@
 
 the total number of files tested must be specified.
 
-=head2 eol_unix_ok( $file [, $text] )
+=head2 eol_unix_ok( $file [, $text] [, \%options ]  )
 
 Run a unix EOL check on C<$file>. For a module, the path (lib/My/Module.pm) or the
 name (My::Module) can be both used.

Modified: branches/upstream/libtest-eol-perl/current/t/11-all.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-eol-perl/current/t/11-all.t?rev=51306&op=diff
==============================================================================
--- branches/upstream/libtest-eol-perl/current/t/11-all.t (original)
+++ branches/upstream/libtest-eol-perl/current/t/11-all.t Thu Jan 21 22:01:40 2010
@@ -18,7 +18,10 @@
 my $file3 = make_file3();
 eol_unix_ok( $file3 );
 
-unlink foreach ( $file1, $file2, $file3 );
+my $file4 = make_file3();
+eol_unix_ok( $file3, { trailing_whitespace => 1 });
+
+unlink foreach ( $file1, $file2, $file3, $file4 );
 
 sub make_file1 {
   my ($fh, $filename) = tempfile();

Modified: branches/upstream/libtest-eol-perl/current/t/12-fail.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-eol-perl/current/t/12-fail.t?rev=51306&op=diff
==============================================================================
--- branches/upstream/libtest-eol-perl/current/t/12-fail.t (original)
+++ branches/upstream/libtest-eol-perl/current/t/12-fail.t Thu Jan 21 22:01:40 2010
@@ -42,6 +42,18 @@
     system("rm -rf $dir");
 }
 
+{
+    my $dir = make_bad_file_4();
+    my (undef, $outfile) = tempfile();
+    ok( `$perl $inc -MTest::EOL -e "all_perl_files_ok({trailing_whitespace => 1}, '$dir' )" 2>&1 > $outfile` );
+    open my $fh, '<', $outfile or die $!;
+    local $/ = undef;
+    my $content = <$fh>;
+    like( $content, qr/^not ok 1 - No windows line endings in '[^']*' on line \d+/m, 'windows EOL found in tmp file 4' );
+    unlink $outfile;
+    system("rm -rf $dir");
+}
+
 sub make_bad_file_1 {
   my $tmpdir = tempdir();
   my ($fh, $filename) = tempfile( DIR => $tmpdir, SUFFIX => '.pL' );
@@ -50,7 +62,7 @@
 
 sub main {
     print "Hello!\r\n";
-}
+}
 DUMMY
   return $tmpdir;
 }
@@ -97,3 +109,26 @@
   return ($tmpdir, $filename);
 }
 
+sub make_bad_file_4 {
+  my $tmpdir = tempdir();
+  my ($fh, $filename) = tempfile( DIR => $tmpdir, SUFFIX => '.pL' );
+  print $fh <<"DUMMY";
+#!perl
+
+=pod
+
+=head1 NAME
+
+test.pL -	A test script
+
+=cut
+
+sub main {
+DUMMY
+
+print $fh qq{    print "Hello!\n";   \n}; # <-- whitespace
+print $fh '}';
+
+  return $tmpdir;
+}
+




More information about the Pkg-perl-cvs-commits mailing list