From: Olivier Mengué Date: Sat, 8 Sep 2012 06:36:24 +0000 (+0200) Subject: 12-fail.t: fix most tests on Win32 X-Git-Tag: 1.4~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c0662b43b1c86733553afed7453012f25c6360e9;p=catagits%2FTest-EOL.git 12-fail.t: fix most tests on Win32 Fix almost all tests on Win32 by NEVER using raw ^M. The rule: DO NOT USE RAW ^M IN SOURCE CODE. That's not portable! Avoiding those problems is the point of disallowing ^M with Test:EOL. I can't understand why the Test::EOL maintainers didn't apply that rule to themselves. Test 'make_bad_file_3' is so broken that I don't understand what it is supposed to do, so I just translated raw ^M to "\r" for now. --- diff --git a/t/12-fail.t b/t/12-fail.t index 0ba17c6..78238be 100644 --- a/t/12-fail.t +++ b/t/12-fail.t @@ -19,7 +19,7 @@ $inc = "-I $inc" if $inc; { my $dir = make_bad_file_1(); run_ok( "all_perl_files_ok( '$dir' )", - qr/^not ok 1 - No incorrect line endings in '[^']*' \Qon line 4: [\r]/m, + qr/^not ok 1 - No incorrect line endings in '[^']*' \Qon line 5: [\r]/m, 'windows EOL found in tmp file 1' ); } { @@ -38,7 +38,8 @@ $inc = "-I $inc" if $inc; { my $dir = make_bad_file_4(); run_ok( "all_perl_files_ok({trailing_whitespace => 1}, '$dir' )", - qr/^not ok 1 - No incorrect line endings in '[^']*' \Qon line 13: [\s][\t][\s][\s]/m, + # Note that line number will be 13 + qr/^not ok 1 - No incorrect line endings in '[^']*' \Qon line 12: [\s][\t][\s][\s]/m, 'Trailing ws EOL found in tmp file 4' ); } @@ -79,6 +80,7 @@ sub make_bad_file_1 { #!perl sub main { + # Note that the generated file will have the CRLF expanded in the source print "Hello!\r\n"; } DUMMY @@ -99,11 +101,11 @@ sub make_bad_file_2 { =head1 NAME test.pL - A test script - +\r\r\r\r\r\r\r\r =cut sub main { - print "Hello!\n"; + print "Hello!\\n"; } DUMMY return $tmpdir; @@ -114,18 +116,18 @@ sub make_bad_file_3 { my ($fh, $filename) = tempfile( DIR => $tmpdir, SUFFIX => '.pm' ); binmode $fh, ':raw'; print $fh <<"DUMMY"; -use strict; - -package My::Test; - -sub new { - my (\$class) = @_; - my \$self = bless { }, \$class; - return \$self; -} - - -1; +use strict;\r +\r +package My::Test;\r +\r +sub new {\r + my (\$class) = \@_;\r + my \$self = bless { }, \$class;\r + return \$self;\r +}\r\r\r\r + +\r +1;\r DUMMY close $fh; return ($tmpdir, $filename); @@ -135,7 +137,7 @@ sub make_bad_file_4 { my $tmpdir = tempdir( CLEANUP => 1 ); my ($fh, $filename) = tempfile( DIR => $tmpdir, SUFFIX => '.pL' ); binmode $fh, ':raw'; - print $fh <<"DUMMY"; + print $fh <<'DUMMY'; #!perl =pod @@ -149,7 +151,7 @@ test.pL - A test script sub main { DUMMY -print $fh qq{ print "Hello!\n"; \t \n}; # <-- whitespace +print $fh qq{ print "Hello!\\n"; \t \n}; # <-- whitespace print $fh '}'; return $tmpdir;