Subject: | [PATCH] t/file_contains.t breaks with perl < 5.8.9 |
$ make test
/usr/bin/perl "-MTest::Manifest" "-e" "run_t_manifest(0, 'blib/lib',
'blib/arch', )"
t/load........................ok
t/pod.........................ok
t/pod_coverage................ok
t/normalize...................ok
t/dm_skeleton.................# MSWin32
ok
3/19 skipped: only works on a multi-user OS!
t/win32.......................ok
t/obviously_non_multi_user....ok
t/test_files..................ok
t/test_dirs...................ok
t/links.......................ok
t/link_counts.................ok
6/14 skipped: setup already done
t/line_counters...............ok
t/file_sizes..................ok
t/file_contains...............# Failed test (t/file_contains.t at
line 78)
# STDOUT is:
# ok 1 - min_file contains (?mx-is:^ xxxxxxxxxxx $)
# not ok 2 - min_file contains (?mx-is:^
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx $)
#
# not:
# ok 1 - min_file contains (?mx-is:^ xxxxxxxxxxx $)
# ok 2 - min_file contains (?mx-is:^
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx $)
#
# as expected
Use of uninitialized value in concatenation (.) or string at
/usr/lib/perl5/vendor_perl/5.8.6/Test/Builder/Tester.pm line 557.
# STDERR is:
# # Failed test (t/file_contains.t at line 77)
# # 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# # xxxxxxxxxxx
# # '
# # doesn't match '(?mx-is:^
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx $)'
#
# not:
#
# as expected
# Failed test (t/file_contains.t at line 83)
# STDOUT is:
# ok 1 - file has the goods
# not ok 2 - file has the goods
#
# not:
# ok 1 - file has the goods
# ok 2 - file has the goods
#
# as expected
Use of uninitialized value in concatenation (.) or string at
/usr/lib/perl5/vendor_perl/5.8.6/Test/Builder/Tester.pm line 557.
# STDERR is:
# # Failed test (t/file_contains.t at line 82)
# # 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# # xxxxxxxxxxx
# # '
# # doesn't match '(?mx-is:^
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx $)'
#
# not:
#
# as expected
FAILED tests 15-16
Failed 2/24 tests, 91.67% okay
t/owner.......................ok
t/rt/30346....................ok
Failed 1/16 test scripts, 93.75% okay. 2/233 subtests failed, 99.14% okay.
Failed Test Stat Wstat Total Fail Failed List of Failed
-------------------------------------------------------------------------------
t/file_contains.t 24 2 8.33% 15-16
9 subtests skipped.
make: *** [test_dynamic] Error 255
I believe this is due to a bug in older perls that makes the '$' anchor
not work properly in qr//m regexes, as mentioned at
http://www.perlmonks.org/bare/?node_id=676601
I think the underlying bug is
https://rt.perl.org/rt3/Public/Bug/Display.html?id=3038
The attached patch fixes this for me, without breaking current perls.
Subject: | Test-File-1.30-old-perl.patch |
Perls prior to 5.8.9 don't handle the '$' anchor in multi-line regexps
properly, as shown at http://www.perlmonks.org/bare/?node_id=676601
I think this is https://rt.perl.org/rt3/Public/Bug/Display.html?id=3038
--- Test-File-1.30/t/file_contains.t
+++ Test-File-1.30/t/file_contains.t
@@ -15,9 +15,9 @@
my $file = 'min_file';
my $contents = do { open FH, $file; local $/; <FH> }; close FH;
-my $pattern1 = 'x' x 11; $pattern1 = qr/^ $pattern1 $/mx;
-my $pattern2 = 'x' x 40; $pattern2 = qr/^ $pattern2 $/mx;
-my $bad_pattern = 'x' x 20; $bad_pattern = qr/^ $bad_pattern $/mx;
+my $pattern1 = 'x' x 11; $pattern1 = qr/(?mx:^ $pattern1 $)/;
+my $pattern2 = 'x' x 40; $pattern2 = qr/(?mx:^ $pattern2 $)/;
+my $bad_pattern = 'x' x 20; $bad_pattern = qr/(?mx:^ $bad_pattern $)/;
# like : single pattern