From: Peter Rabbitson Date: Wed, 4 Jan 2012 05:35:14 +0000 (+0100) Subject: Fix misleading diag when looking for trailing whitespace X-Git-Tag: 1.0~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FTest-EOL.git;a=commitdiff_plain;h=939ef6135463a53256f555cf9bc6846c5d4c6b31 Fix misleading diag when looking for trailing whitespace --- diff --git a/Changes b/Changes index b9153d3..33305e8 100644 --- 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 diff --git a/lib/Test/EOL.pm b/lib/Test/EOL.pm index 25628c3..1b5b8c4 100644 --- a/lib/Test/EOL.pm +++ b/lib/Test/EOL.pm @@ -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, diff --git a/t/12-fail.t b/t/12-fail.t index eef773b..0665344 100644 --- a/t/12-fail.t +++ b/t/12-fail.t @@ -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;