Fix misleading diag when looking for trailing whitespace
Peter Rabbitson [Wed, 4 Jan 2012 05:35:14 +0000 (06:35 +0100)]
Changes
lib/Test/EOL.pm
t/12-fail.t

diff --git a/Changes b/Changes
index b9153d3..33305e8 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,8 +1,11 @@
 Revision history for Test-EOL
 
+    - Fix misleading test failure diagnostics when only issue are
+      trailing whitespaces
+
 0.9  2010-06-16
-     - Fix warnings on very old perls (paul@city-fan.org)
-       (Closes: RT#58442)
+    - Fix warnings on very old perls (paul@city-fan.org)
+      (Closes: RT#58442)
 
 0.8  2010-06-11
     - Use binmode :raw for input/output. Solves win32 translating the
index 25628c3..1b5b8c4 100644 (file)
@@ -79,7 +79,7 @@ sub _show_whitespace {
 sub _debug_line {
     my ( $options, $line ) = @_;
     $line->[2] =~ s/\n\z//g;
-    return "line $line->[1] : $line->[0] " . (
+    return "line $line->[1]: $line->[0] " . (
       $options->{show_lines} ? qq{: } . _show_whitespace( $line->[2] )  : q{}
     );
 }
@@ -88,7 +88,7 @@ sub eol_unix_ok {
     my $file = shift;
     my $test_txt;
     $test_txt   = shift if !ref $_[0];
-    $test_txt ||= "No windows line endings in '$file'";
+    $test_txt ||= "No incorrect line endings in '$file'";
     my $options = shift if ref $_[0] eq 'HASH';
     $options ||= {
         trailing_whitespace => 0,
index eef773b..0665344 100644 (file)
@@ -23,7 +23,7 @@ $inc = "-I $inc" if $inc;
     local $/ = undef;
     open my $fh, '<', $outfile or die $!;
     my $content = <$fh>;
-    like( $content, qr/^not ok 1 - No windows line endings in '[^']*' on line 4/m, 'windows EOL found in tmp file 1' );
+    like( $content, qr/^not ok 1 - No incorrect line endings in '[^']*' \Qon line 4: [\r]/m, 'windows EOL found in tmp file 1' );
     unlink $outfile;
 }
 {
@@ -33,7 +33,7 @@ $inc = "-I $inc" if $inc;
     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 file2 ' );
+    like( $content, qr/^not ok 1 - No incorrect line endings in '[^']*' \Qon line 8: [\r][\r][\r][\r][\r][\r][\r]/m, 'windows EOL found in tmp file2 ' );
     unlink $outfile;
 }
 {
@@ -43,7 +43,7 @@ $inc = "-I $inc" if $inc;
     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 3' );
+    like( $content, qr/^not ok 1 - No incorrect line endings in '[^']*' \Qon line 9: [\r][\r][\r]/m, 'windows EOL found in tmp file 3' );
     unlink $outfile;
 }
 
@@ -54,7 +54,7 @@ $inc = "-I $inc" if $inc;
     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' );
+    like( $content, qr/^not ok 1 - No incorrect line endings in '[^']*' \Qon line 13: [\s][\t][\s][\s]/m, 'Trailing ws EOL found in tmp file 4' );
     unlink $outfile;
 }
 
@@ -151,7 +151,7 @@ test.pL -   A test script
 sub main {
 DUMMY
 
-print $fh qq{    print "Hello!\n";   \n}; # <-- whitespace
+print $fh qq{    print "Hello!\n"; \t  \n}; # <-- whitespace
 print $fh '}';
 
   return $tmpdir;