add trailing_whitespace option and release (3 times)
[catagits/Test-EOL.git] / t / 12-fail.t
index ae58908..91cc6b8 100644 (file)
@@ -15,11 +15,10 @@ $inc = "-I $inc" if $inc;
     local $/ = undef;
     open my $fh, '<', $outfile or die $!;
     my $content = <$fh>;
-    like( $content, qr/^not ok 1 - No tabs in '[^']*' on line 4/m, 'windows EOL found in tmp file 1' );
-    #unlink $outfile;
-    #system("rm -rf $dir");
+    like( $content, qr/^not ok 1 - No windows line endings in '[^']*' on line 4/m, 'windows EOL found in tmp file 1' );
+    unlink $outfile;
+    system("rm -rf $dir");
 }
-
 {
     my $dir = make_bad_file_2();
     my (undef, $outfile) = tempfile();
@@ -27,11 +26,10 @@ $inc = "-I $inc" if $inc;
     open my $fh, '<', $outfile or die $!;
     local $/ = undef;
     my $content = <$fh>;
-    like( $content, qr/^not ok 1 - No tabs in '[^']*' on line 12/m, 'windows EOL found in tmp file2 ' );
+    like( $content, qr/^not ok 1 - No windows line endings in '[^']*' on line \d+/m, 'windows EOL found in tmp file2 ' );
     unlink $outfile;
     system("rm -rf $dir");
 }
-
 {
     my ($dir, $file) = make_bad_file_3();
     my (undef, $outfile) = tempfile();
@@ -39,7 +37,19 @@ $inc = "-I $inc" if $inc;
     open my $fh, '<', $outfile or die $!;
     local $/ = undef;
     my $content = <$fh>;
-    like( $content, qr/^not ok 1 - No tabs in '[^']*' on line 6/m, 'windows EOL found in tmp file 3' );
+    like( $content, qr/^not ok 1 - No windows line endings in '[^']*' on line \d+/m, 'windows EOL found in tmp file 3' );
+    unlink $outfile;
+    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");
 }
@@ -68,7 +78,7 @@ sub make_bad_file_2 {
 =head1 NAME
 
 test.pL -      A test script
-\r
+\r\r\r\r\r\r\r\r
 =cut
 
 sub main {
@@ -90,7 +100,8 @@ sub new {
     my (\$class) = @_;\r
     my \$self = bless { }, \$class;\r
     return \$self;\r
-}\r
+}\r\r\r\r
+
 \r
 1;\r
 DUMMY
@@ -98,3 +109,26 @@ DUMMY
   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;
+}
+